iachat/spec/enterprise/services/captain
Rodribm10 6330bec857 fix(captain-memory): temporal memory model + aggressive dedup
User feedback revealed a fundamental design issue: the memory model was
accumulating contradictory "Prefere X" facts because a single choice was
being treated as a permanent preference. Result: 3 different
"Prefere suite X" entries coexisting, all at 90% confidence, with
reservation patterns over time (2hrs, 4hrs, pernoite) all claiming to be
the customer's "preferred" duration.

Corrections:

1. ExtractionService prompt — preferencia now requires EXPLICIT
  declaration words ("prefiro", "gosto mais de", "sempre escolho",
  "adoro", "favorita"). A mere choice in one conversation is NO LONGER
  extracted as preferencia — instead it goes to padrao_comportamental
  WITH THE DATE in the content (e.g. "Reservou Alexa para pernoite em
  23/05/2026"). This makes memory temporal and auditable instead of
  imposing fake consistency.

2. Reference date is passed to the LLM prompt via the latest message
  timestamp, used as the anchor date the LLM must embed in every
  padrao_comportamental content.

3. ContradictionCheckerService — dual threshold:
  - cosine < 0.15 → auto-supersede without LLM (pure duplicate)
  - 0.15 to 0.6 → ask LLM if contradicts, supersede if yes
  - > 0.6 → ignore, unrelated facts
  Previously only the middle band existed, so near-duplicate facts like
  two "aniversário 23/05" entries or three "prefere suite X" entries
  were never cleaned up.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
2026-04-19 08:30:42 -03:00
..
assistant chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
contact_memories fix(captain-memory): temporal memory model + aggressive dedup 2026-04-19 08:30:42 -03:00
copilot chore: fix linting 2025-12-20 12:55:27 -03:00
inter chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
lifecycle test(lifecycle): add end-to-end integration spec for scheduler→dispatch→send flow 2026-04-15 09:29:52 -03:00
llm fix: captain assistant image comprehension (#13390) 2026-01-28 16:07:13 -08:00
onboarding feat: legacy features to ruby llm (#12994) 2025-12-11 14:17:28 +05:30
reservations chore(style): fix rubocop offenses and update typing indicators 2026-02-25 15:06:58 -03:00
tools ajuste galeria de imagens 2026-02-26 15:27:25 -03:00
open_ai_message_builder_service_spec.rb Merge branch 'main' into chatwoot/develop 2025-07-16 09:37:08 -03:00
tool_registry_service_spec.rb feat: Update UI for Copilot (#11561) 2025-06-02 22:02:03 -05:00