iachat/enterprise/app/services/captain
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
..
assistant fix(captain): wrap runner.run in Timeout to guard HTTP hangs 2026-04-19 11:40:59 -03:00
codex fix(captain): translate response_format to text.format on Codex proxy 2026-04-22 22:47:09 -03:00
contact_memories fix(captain): route embeddings to legacy OpenAI + retry transient errors 2026-04-22 17:42:31 -03:00
contact_stats feat(retention): foundation for customer retention metrics 2026-04-22 09:50:23 -03:00
copilot feat: Migrate ruby llm captain (#12981) 2025-12-04 18:26:10 +05:30
hermes feat(captain/hermes): camada 2 — gating de saída factual sem tool call 2026-05-02 17:58:17 -03:00
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 fix(captain): força provider :openai quando há config dedicada de embedding 2026-05-01 16:18:50 -03:00
mcp feat(captain/mcp): tool check_suite_availability — bridge PlugPlay 2026-05-02 17:10:57 -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 feat(captain/hermes): payload enriquecido + humanizadores + notif Pix proativa 2026-05-01 20:15:50 -03:00
reports fix(retention): cohort endpoint 500 — Pundit policy + SQL binding 2026-04-26 12:46:20 -03:00
reserva fix(captain): provision unit via RPC SECURITY DEFINER (RLS bypass) 2026-05-01 09:11:57 -03:00
reservations chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
roleta fix(captain): Accept-Encoding identity nos clients Supabase (gzip silencioso) 2026-04-30 23:21:10 -03:00
tools fix(captain): captain_inbox.unit -> captain_unit (bug bloqueante roleta + tools) 2026-04-30 23:11:00 -03:00
hermes.rb fix(captain/hermes): subscription_name e secret usam profile_name (slug) 2026-05-02 13:42:22 -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