fix(memory): add quality gates to heuristic fact extractor (#84)#88
fix(memory): add quality gates to heuristic fact extractor (#84)#88kagura-agent wants to merge 1 commit intoghostwright:mainfrom
Conversation
…ht#84) - Add word count filter (5-150 words) to reject short Slack fragments and long 'thinking out loud' messages - Add truncation detection to reject messages ending mid-word - Add text-based deduplication within same session - Lower heuristic confidence from 0.8/0.9 to 0.4 (appropriate for pattern-based extraction without LLM validation) - Add 18 tests covering all quality gates and edge cases
|
The four gates land cleanly and read very close to the directions on issue #84. The 18-test new file plus the boundary cases (exactly 5 / exactly 150 words, every accepted punctuation type) is the right shape for a heuristic with this many tunable knobs. Two notes worth surfacing before merge.
A test for whichever invariant ends up canonical on (1) would close the loop. Something like The 0.4 confidence floor reads cleanly as the "heuristic-without-LLM-validation" tier; it'll re-rank correctly if the LLM consolidation path comes back behind a flag (direction #4 from the issue), and stays sensible even without it. |
|
Thanks for the detailed review! On point 1 — good catch on the cross-pattern overlap. The intended invariant from #84 is one-fact-per-message, so I'll add a break after the first match to prevent a single fragment producing two facts. Will add the test case you described ( On point 2 — agreed on the punctuation regex. I'll relax it to Pushing the updates shortly. |
Problem
The heuristic fact extractor in
extractFactsFromSession()promotes raw Slack fragments to Known Facts. Short conversational messages like "No did you see the images or no?" match correction/preference regex patterns and get stored with high confidence (0.8-0.9), displacing real accumulated knowledge in every prompt build.Reported in #84.
Changes
Quality gates (src/memory/consolidation.ts)
.!?;:)Tests (src/memory/tests/consolidation-facts.test.ts)
18 new tests covering:
Existing test fix (src/memory/tests/consolidation.test.ts)
Added sentence-ending punctuation to 4 test messages that the truncation gate now correctly filters.
Verification
All 82 memory tests pass. Biome lint clean.
Closes #84