From 2ac55c8728747ba655a0cb2d8d1aee8a0578a70f Mon Sep 17 00:00:00 2001 From: Aakash Bakhle <48802744+aakashb95@users.noreply.github.com> Date: Tue, 14 Jul 2026 19:38:43 +0530 Subject: [PATCH] fix(captain): honor mandatory handoff guidelines (#15003) Ensures Captain follows explicit mandatory-transfer rules from active Response Guidelines and Guardrails instead of allowing the generic consent-first fallback to override those rules. ## What changed - Made explicit transfer requirements take precedence over generic consent-first handoff defaults only when their condition matches. - Added explicit Response Guideline and Guardrail transfer rules to the human-handoff protocol. - Added focused prompt regression coverage. ## How to reproduce Configure a Response Guideline or Guardrail that requires immediate transfer for a specific condition, then send a request matching that condition. Captain should invoke the human-handoff path without asking the user to consent again. Unmatched requests continue to use the existing consent-first fallback. The assistant prompt renderer, agent prompt context, and focused regression specs pass locally. --- enterprise/lib/captain/prompts/assistant.liquid | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/enterprise/lib/captain/prompts/assistant.liquid b/enterprise/lib/captain/prompts/assistant.liquid index 821d9d472..a8f1dada3 100644 --- a/enterprise/lib/captain/prompts/assistant.liquid +++ b/enterprise/lib/captain/prompts/assistant.liquid @@ -48,6 +48,8 @@ Always respect these boundaries: {% endfor %} {% endif -%} +When a Response Guideline or Guardrail explicitly requires transfer for a matched condition, follow it instead of the generic consent-first handoff defaults below. + # Decision Framework ## 1. Analyze the Request @@ -88,7 +90,8 @@ Handle the request yourself in the following way Transfer to a human agent when: - User explicitly requests human assistance - User accepts an offer to speak with a human +- A Response Guideline or Guardrail explicitly requires transfer for the matched condition - The issue requires specialized knowledge or permissions you don't have - Multiple attempts to help have been unsuccessful -If you cannot find needed information after checking the available information and clarifying context, ask whether the user wants to talk to another support agent. Use the `captain--tools--handoff` tool only after the user explicitly requests human assistance or accepts your offer to speak with a human. When using the tool, provide a clear reason that helps the human agent understand the context. +If you cannot find needed information after checking the available information and clarifying context, ask whether the user wants to talk to another support agent. Use the `captain--tools--handoff` tool only after the user explicitly requests human assistance, accepts your offer to speak with a human, or a Response Guideline or Guardrail explicitly requires transfer for the matched condition. When using the tool, provide a clear reason that helps the human agent understand the context.