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.
49 lines
992 B
Ruby
49 lines
992 B
Ruby
class Captain::AssistantMigration::InstructionAuditor < Captain::BaseTaskService
|
|
AUDITOR_MODEL = 'gpt-5.2'.freeze
|
|
pattr_initialize [:assistant!, :source_payload!, :draft!, :available_additions!]
|
|
|
|
def perform
|
|
make_api_call(
|
|
model: AUDITOR_MODEL,
|
|
messages: messages,
|
|
schema: Captain::AssistantMigration::InstructionAuditorSchema.for(available_additions)
|
|
)
|
|
end
|
|
|
|
private
|
|
|
|
def account
|
|
assistant.account
|
|
end
|
|
|
|
def messages
|
|
[
|
|
{ role: 'system', content: system_prompt },
|
|
{
|
|
role: 'user',
|
|
content: JSON.pretty_generate(source: source_payload, generated_draft: draft, available_additions: available_additions)
|
|
}
|
|
]
|
|
end
|
|
|
|
def system_prompt
|
|
Captain::PromptRenderer.render('instruction_auditor')
|
|
end
|
|
|
|
def event_name
|
|
'assistant_migration_instruction_auditor'
|
|
end
|
|
|
|
def captain_tasks_enabled?
|
|
true
|
|
end
|
|
|
|
def counts_toward_usage?
|
|
false
|
|
end
|
|
|
|
def build_follow_up_context?
|
|
false
|
|
end
|
|
end
|