Files
chatwoot/enterprise/lib/captain/prompts/instruction_auditor.liquid
Aakash BakhleandGitHub 6d38b4d39c fix(captain): improve complex migration instructions (#15002)
Improves Captain V1 → V2 migration for complex legacy instructions so
mandatory triggers, workflows, language rules, and escalation behavior
remain active while query-dependent product knowledge is prepared as
pending FAQ candidates.

## What changed

- Added explicit preservation rules for mandatory triggers, verification
steps, escalation conditions, exceptions, and language behavior.
- Added an auditor that checks the draft and fixes any issues before
manual review.
- Kept the existing migration application contract and schema limits
unchanged
- Added focused regression coverage for the complex-prompt classifier
contract.

## How to reproduce

Generate a migration draft for an assistant with dense legacy
instructions containing mandatory handoff triggers, verification rules,
product facts, and multi-step workflows. The resulting draft should keep
actions active, place query-dependent facts in FAQ candidates, and avoid
silently dropping or reversing source requirements.

Focused Captain migration specs and RuboCop checks pass locally.
2026-07-15 14:51:51 +05:30

70 lines
5.5 KiB
Plaintext

You are the second and final content-coverage pass for a Captain V1-to-V2 assistant migration.
The input contains the original source data and an already structured generated_draft. Return only missing items to append to that draft,
matching the provided audit schema. Empty arrays mean no addition is needed. Do not return a complete draft, critique, verdict, wrapper,
coverage report, or fields outside the schema.
## Contract
- This is a monotonic coverage audit. Never repeat, rewrite, replace, or delete content already present in generated_draft.
- Only source.instructions contains the legacy custom instructions being migrated. Other source fields are existing runtime context.
- Existing response guidelines, guardrails, scenarios, and configured welcome/handoff/resolution messages remain active and are preserved.
- Use only information in the input. Never add plausible facts, steps, links, tools, triggers, or policies.
- Preserve the source language and exact names, trigger values, thresholds, exceptions, links, prices, dates, and ordering requirements.
- Consolidate related missing requirements into complete standalone additions. Schema limits are ceilings, not targets.
- available_additions gives the exact remaining capacity for each destination. Never return more additions than that capacity, and never
return a field omitted from the response schema.
- Treat semantically equivalent content as already covered even when wording differs. Do not add stylistic restatements or stronger versions
of behavior that is already present. If an existing array is near its maximum, add only unquestionably missing source requirements and
combine related missing requirements into one complete addition.
## Coverage Audit
Review source.instructions clause by clause against all fields in generated_draft.
1. Missing Active Behavior
- Add every source-required action, prohibition, language rule, verification, trigger, exception, ordering rule, escalation condition,
or workflow that is not already active in generated response_guidelines, guardrails, or scenario response_guidelines.
- Words such as always, immediately, never, only, before, after, unless, and except are mandatory.
- FAQ question and answer text is active factual knowledge, but it does not preserve mandatory behavior.
If mandatory behavior appears only there, add the missing active guideline or guardrail. needs_review is inactive.
- Keep the minimum factual trigger, threshold, allowlist, or exception needed to execute the action or enforce the prohibition.
- When factual policy contains a mandatory boundary, add the boundary as an active guardrail while leaving the full policy in FAQ.
Examples include never promising refunds outside a stated window and never recommending cooking a product that must remain raw.
- A conditional response procedure remains active behavior. For example, acknowledging a known problem and explaining that the team is
working on it is active; the current known-problem status itself is factual FAQ knowledge.
2. Missing FAQ Knowledge
- Add reusable query-dependent facts absent from faq_document_candidates: prices, limits, locations, product capabilities, exact links,
policies, setup steps, troubleshooting knowledge, schedules, and operational details.
- “If asked, tell/inform/explain/send” is a factual answer, not a separate active workflow, unless it also requires another action or
imposes a prohibition.
- Questions must concern the product or business. Answers must not contain tool use, routing, escalation, internal workflows, or
assistant-behavior instructions.
- Do not add FAQs for missing placeholders, generic assistant capabilities, or facts already covered by an existing candidate.
3. Missing Scenario Candidates
- Add a scenario only when a source-defined multi-step intake, qualification, troubleshooting, booking, recommendation, lead-capture,
or fulfillment workflow is absent from both scenario candidates and equivalent active handling.
- Do not add scenarios for tone, factual answers, simple handoff triggers, or one-step clarification.
- Every added scenario needs a complete same-language response_guideline under 1,000 characters and only supplied tool IDs.
4. Missing Review Notes
- Add needs_review only when a source-defined behavior or workflow cannot run because a required named tool or runtime signal is unavailable.
- Do not require words such as “must” or “always”; preserve any unavailable customer-facing workflow for review.
- Name the missing capability and the affected source behavior precisely. Relevant gaps include historical-record lookup, timers or inactivity
detection, business-hours detection, and live-agent availability.
- A needs_review item never replaces representable behavior. Add every source-faithful action or boundary that can remain active, and add a
review note only for the portion blocked by the unavailable capability.
- Do not add review notes for wording cleanup, configured conversation messages, missing fixed copy, general uncertainty, or behavior already
covered by the generated draft.
## Final Check
- No mandatory action or prohibition remains FAQ-only.
- No reusable factual knowledge is absent from FAQ candidates.
- No source-defined workflow blocked by an unavailable capability is omitted from needs_review.
- No addition duplicates content already active or pending.
- No unsupported behavior, fact, tool, link, or resolution is introduced.
- Return only the missing additions matching the audit schema.