iachat/app/controllers/webhooks
Rodribm10 ed99f67525 feat(captain/hermes): camada 2 — gating de saída factual sem tool call
Detecta alucinação de memória: se resposta do Hermes contém info
factual (preço/senha/horário/regra/política) E o LLM NÃO chamou
nenhuma tool MCP entre dispatch e callback, bloqueia entrega + dispara
system_message forçando consulta a tool. 1 retry; persistindo, escala.

Implementação:
- McpController: incrementa Rails.cache hermes_tool_calls:<conv_id>
  em cada tools/call.
- OutgoingJob: snapshot do contador como hermes_tool_calls_baseline
  ANTES de despachar pro Hermes.
- HermesCallbackController.gate_factual_no_tool!: compara baseline vs
  current; se igual + FACTUAL_PATTERNS bate, intercepta. Patterns
  cobrem R$, %, "senha", check-in/out + horário, política de
  cancelamento, "permitido", "pode levar pet/animal".

Caso real: cliente pede senha do Wi-Fi → Hermes responde de cabeça
"é passada presencialmente" sem chamar faq_lookup → callback intercepta,
não entrega pro cliente, manda [SISTEMA: force_factual_tool] pro Hermes
com instrução de chamar faq_lookup. Se faq_lookup vier vazio → frase-
âncora handoff.

Auto-react ambient: removido filtro de "?" que barrava em prod.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-05-02 17:58:17 -03:00
..
captain feat(captain/hermes): camada 2 — gating de saída factual sem tool call 2026-05-02 17:58:17 -03:00
instagram_controller.rb fix: Add delay to instagram/messenger echo events to prevent duplicate messages (#12032) 2025-07-24 21:11:02 +04:00
line_controller.rb feat: Line Channel (#2904) 2021-09-11 01:31:17 +05:30
shopify_controller.rb feat(shopify): Add mandatory compliance webhooks with HMAC verification (#13549) 2026-02-17 16:52:13 +05:30
sms_controller.rb chore: Provider APIs for SMS Channel - Bandwidth (#3889) 2022-02-03 15:22:13 -08:00
telegram_controller.rb feat: Telegram Channel (#2901) 2021-09-10 00:00:52 +05:30
tiktok_controller.rb feat: TikTok channel (#12741) 2025-12-17 07:54:50 -08:00
whatsapp_controller.rb Fix Wuzapi webhook handling 2026-02-26 10:49:00 -03:00
wuzapi_controller.rb chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00