iachat/enterprise/app/services
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
..
captain fix(captain): stop scenario->orchestrator handoff + narrow FAQ guardrail 2026-04-19 10:51:45 -03:00
cloudflare Merge branch 'main' into chore/merge-upstream-4.5.0 2025-08-20 11:20:31 -03:00
companies Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
contacts Chore/merge upstream 4.8.0 (#150) 2025-11-19 16:25:58 -03:00
enterprise feat(ai): implement dynamic debounce with sidekiq and concurrency locking with redis 2026-03-01 02:04:55 -03:00
internal Merge branch main into chore/merge-upstream 2025-12-20 12:44:31 -03:00
llm feat: add global config for captain settings (#13141) 2026-01-12 19:54:19 +05:30
messages fix(messages): reduce audio transcription 400 retry noise (#13487) 2026-02-17 13:25:13 +05:30
sla chore: fix sla email notifications (#9192) 2024-04-04 21:16:49 +05:30
twilio chore: apply rubocop 2025-09-19 19:44:02 -03:00
voice chore: fix linting 2025-12-20 12:55:27 -03:00
page_crawler_service.rb feat: Response Bot using GPT and Webpage Sources (#7518) 2023-07-21 18:11:51 +03:00