iachat/enterprise/app/services/captain
Rodribm10 e5d186c689 fix(captain): stop scenario->orchestrator handoff + narrow FAQ guardrail
Two behavioural regressions caught in live testing with a real customer
conversation:

1. Ping-pong scenario -> orchestrator -> scenario

   build_and_wire_agents was calling scenario_agents.register_handoffs(
   assistant_agent), which exposed handoff_to_jasmine as a tool INSIDE
   every scenario. Daniela (reservation scenario) kept calling it mid
   flow, the orchestrator resumed the turn, and customers got messages
   like "Vou te encaminhar para a Daniela..." after ALREADY being with
   Daniela. The back-edge is removed. When a customer legitimately
   changes topic mid-scenario, pick_starting_agent on the next turn
   already routes back to the orchestrator based on conversation state,
   so no manual handoff from the scenario side is needed.

2. FAQ_PRICE_PATTERNS was hijacking legitimate routing responses

   The previous regex matched the bare words "pernoite", "sinal",
   "diaria" WITHOUT requiring a numeric price nearby. A legitimate
   handoff response like "Vou transferir para a Daniela para confirmar
   a Stilo para pernoite" tripped the guardrail, which then substituted
   the response with raw FAQ content about rates. Narrowed to: R$
   values, numbers followed by "reais", and the explicit price-noun
   variants (preco/preço/valor/preços/valores/custo/custa). Incidental
   mentions of stay types no longer trigger.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 10:51:45 -03:00
..
assistant fix(captain): stop scenario->orchestrator handoff + narrow FAQ guardrail 2026-04-19 10:51:45 -03:00
contact_memories fix(captain-memory): temporal memory model + aggressive dedup 2026-04-19 08:30:42 -03:00
copilot feat: Migrate ruby llm captain (#12981) 2025-12-04 18:26:10 +05:30
inter chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
lifecycle feat(lifecycle): add Dispatcher service with guards→render→send pipeline 2026-04-15 01:53:01 -03:00
llm feat(captain): add AI reports page with insights generation 2026-02-27 07:05:58 -03:00
notifications feat: sistema de notificações de reserva com templates configuráveis 2026-03-01 21:53:11 -03:00
onboarding feat: legacy features to ruby llm (#12994) 2025-12-11 14:17:28 +05:30
payments chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
reservations chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
tools fix(captain): aceita DD/MM sem ano e amplia tratamento de requires_input no generate_pix 2026-04-18 18:37:17 -03:00
open_ai_message_builder_service.rb feat(ai): implement dynamic debounce with sidekiq and concurrency locking with redis 2026-03-01 02:04:55 -03:00
tool_registry_service.rb feat: Update UI for Copilot (#11561) 2025-06-02 22:02:03 -05:00