Repository navigation
fix(memory): keep one copy of a sensitive fact, and forget every copy by id - #7212
Conversation
… by id
Before: "Remember that I am allergic to mango" saved a sensitive memory, and
seconds later the turn's extraction saved the same fact again, not sensitive.
Forgetting it by id erased only the first copy, so the Memory page still
listed it and a new chat still answered "you're allergic to mango". After:
the second save merges into the first and stays sensitive, and forgetting by
id erases every copy of the same words.
- Dedup treated the remember tool's entity tag ("user", "health") and
extraction's missing tag as different subjects. Only a person: tag now
names someone else; distinct facts that share most words still stay apart.
- forget(knowledge_id) now also forgets current rows with the same words
about the same subject, as forgetting by words already did.
Refs amd/gaia finding F9
|
Verdict: Approve with suggestions This fixes a real privacy bug: a sensitive fact like "I am allergic to mango" was saved twice, once marked sensitive and once not, and forgetting it by id left the second copy behind. Now the second save merges into the first and stays sensitive, and the Two things are worth fixing before or soon after merge:
Real-world evidenceN/A: the evidence harness produced no bundle for this PR. The change is in the memory store and agent tool layer, which ships inside the downloaded agent binary. The verdict rests on static review and the PR's unit and integration runs. The author lists an in-app replay on the next RC as still to do. 🔍 Technical details🟡 Non-person typed tags are folded into the user's subject (
The rule is also asymmetric. An untagged lookup matches every non-person tag, while a tagged lookup matches only its own tag or NULL. Suggested scope: a tag is the user's own when it has no A test with 🟡 Sibling path: Memory page delete still removes one copy ( 🟢 Stale "entity" wording (nits)
Strengths
|
… the Memory page The first fix treated every tag but person: as the user's own, so an untagged "Uses dark mode" could merge into an app:vscode fact, and forgetting one could erase the other. Now only no tag, a bare label or a user: tag is the user; any other type:name tag is its own subject. Deleting a fact on the Memory page now also forgets its copies, as the forget tool does, so a duplicate saved before this release no longer keeps the fact alive. Refs amd/gaia finding F9
|
Both review points are in the new commit. A tag now counts as the user's own only when it is missing, a bare label, or |
…sitive copy's words out of the forgotten list
Forgetting by the user's words still left a copy behind when the two were
worded apart ("User is allergic to mango" and "Allergic to mango."):
the lookup counted them as two memories and erased neither. Copies are now
the same words bar filler on both paths, as the store's dedup already says.
Forgetting an unflagged copy of a sensitive fact also wrote the fact's
full text into the forgotten list, where it stayed on disk. When any copy
is sensitive, every copy is now recorded as word stems only. The tool and
the Memory page share one store call, forget_with_copies, for both.
|
Two gaps closed in a new commit: forgetting by words now takes a reworded copy too, and forgetting an unflagged copy of a sensitive fact no longer leaves the fact's full text in the forgotten list. 🔍 Technical details
|
Resolves the conflict with #7212 in MemoryStore.forget: the superseded-chain walk keeps main's sensitive argument, and if any version in the chain is sensitive every version is kept as stems only, so an unflagged old version can't leave a sensitive fact's words in forgotten. Adds tests for that, for a supersede cycle, and for forget_with_copies taking a copy's older versions with it.
…md#7269) When the user forgot a fact that had replaced an older version, only the current version was erased. The older versions stayed on disk with their full text. Recall and the Memory page hid them, but they were still stored, which broke the promise that "forget" erases the fact. Now forget erases every older version too, and records each one as forgotten so it isn't learned again from old chats. A sensitive version is recorded as word stems only. Closes amd#7266 ## Test plan - [x] `python -m pytest tests/unit/test_memory_forget_superseded.py` passes (2 of its 4 tests fail on `main`) - [x] `python util/lint.py --all` passes - [x] Memory/forget unit tests pass (`pytest tests/unit -k "memory or forget"`: 2572 passed; 25 collection errors are modules this runner lacks, `responses`/`matplotlib`) - [ ] Tell GAIA a fact, then correct it so the newer memory supersedes the old one. Forget it, then open `~/.gaia/memory.db` and confirm neither version is in `knowledge` <details> <summary>🔍 Technical details</summary> - `MemoryStore.forget` gathers the target plus every row that reaches it through `superseded_by`, using a recursive CTE. `UNION` rather than `UNION ALL`, so a cycle (consolidation can link two rows either way) terminates. Each row is checked against the privileged-category rule, removed from `knowledge_fts` and `knowledge`, and written to `forgotten` (stems if sensitive), all in one transaction. - Forgetting an older version leaves the newer one untouched: the walk only follows rows that were superseded. - No vector-index change is needed. Superseded rows are dropped from FAISS when they're superseded (`_faiss_remove(old_id)`), and the index is rebuilt from active rows only. - This may conflict textually with amd#7212, which also edits `forget`. The two changes are complementary. </details> Co-authored-by: claude[bot] <41898282+claude[bot]@users.noreply.github.com> Co-authored-by: Kalin Ovtcharov <[email protected]>
Asking GAIA to remember a sensitive fact ("I am allergic to mango") saved it twice: once marked sensitive by the remember tool, and again a few seconds later, unmarked, by the turn's own extraction. Forgetting it by id then removed only the first copy, so the Memory page still listed it and a new chat still answered with it. Now the second save merges into the first and stays sensitive, and forgetting by id removes every copy.
Closes #7175
Test plan
python -m pytest tests/unit/test_memory_sensitive_copy.py: runs the real remember tool, then extraction's save, then forget by id, then recall. 11 of 12 fail without the fix, 12 pass with itmemory,gaia_memory,context_retention🔍 Technical details
user,health) and auser:tag now count as the user; any othertype:nametag (person:,app:,project:) is its own subject.tooltollm_extract, as it already did when the tags matched, so the Memory page labels it "Picked up in a chat".