Repository navigation
fix(memory): keep one entry when a fact is remembered again - #235
Open
chuiwenwei wants to merge 1 commit into
Open
chuiwenwei wants to merge 1 commit into
chuiwenwei wants to merge 1 commit into
Conversation
remember_fact derived the row id from the thread and message, so confirming the same fact in a later turn inserted a second row with the same text. Derive the id from the trimmed text instead, and reuse a matching row saved under an older id so the first repeat after an upgrade does not add a copy either. insertIfAbsent keeps the original row, its source and its createdAt when two turns race. Adds a regression test for repeated, legacy, distinct and blank facts.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changed
remember_factbuilt its row id from the conversation turn (requestKeyincludes the thread id and latest message id). Confirming the same preference in a later turn therefore inserted a second row with identical text, and every duplicate was sent back to the model in later task prompts.The tool now delegates to
AgentService.rememberFact. It trims the fact, reuses a matching row (including rows saved under the old id scheme), and otherwise derives the id from the text alone, soinsertIfAbsentkeeps the first row, source andcreatedAteven when two turns race.Verification
pnpm lintpnpm typecheckpnpm --dir apps/worker typecheckpnpm build:serverpnpm test— 527 passingNew
tests/memory-dedupe.test.tscovers: a fact repeated in a later turn, a legacy row with the old id, two distinct facts, and blank text.Integration limits
None. Server-side state only; no provider credentials or platform checks are involved. Existing duplicate rows are not deleted, but a new confirmation with that text reuses one instead of adding another.