feat(agent-memory): Phase 3 — forget / forgetByScope#250
Open
jamby77 wants to merge 2 commits into
Open
Conversation
50a2011 to
13a2279
Compare
dad22d0 to
a102ad0
Compare
- forget(id): DEL {name}:mem:{id}, idempotent (returns whether it existed)
- forgetByScope(scope+tags): FT.SEARCH by escaped scope/tag filter, DEL the
matches, return count; throws when no filter is given (prevents mass delete)
- Extract shared buildScopeFilter() used by recall + forget; escapeTag prevents
glob over-match (a threadId of '*' matches literally, not everything)
13a2279 to
df17cbd
Compare
a102ad0 to
3dc84bb
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 3dc84bb. Configure here.
A scope larger than FORGET_MAX_BATCHES would stop deleting and return a partial count that reads as a completed operation. Emit a warning so the silent cap is observable and callers know to re-run.
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.

Agent Memory — Phase 3:
forget/forgetByScopeStacked on #249 (Phase 2).
What's new
forget(id)→ DEL{name}:mem:{id}; idempotent (returns whether the memory existed).forgetByScope(scope & {tags?})→ finds matches via an escaped scope/tagFT.SEARCHfilter, DELs them in batches, returns the count. Throws when no scope field or tag is given (prevents an accidental delete-everything).buildScopeFilter(used by bothrecallandforget);escapeTagneutralizes glob chars so athreadIdof'*'matches literally, not everything.Design note
The plan says "SCAN-matches scope/tags", but scope/tags are HASH fields (TAG-indexed), not part of the key (
{name}:mem:{uuid}) — a keySCANcan't filter on them. SoforgetByScopeuses anFT.SEARCHfilter query, which is the correct mechanism.Tests
27 unit tests;
tsc --noEmit+ prettier clean.Review-driven change
FT.SEARCH(LIMIT 0 500)→ DEL batch → repeat, with aseenset so it terminates even under index-update lag.Next
Phase 4 (recall reinforcement — bump lastAccessedAt/accessCount on recalled items).
Note
Medium Risk
Introduces destructive bulk deletes against persisted agent memory, though scoped filters, empty-scope errors, and batch-cap warnings reduce accidental data loss risk.
Overview
Adds memory deletion to
MemoryStore:forget(id)removes one hash viaDELand returns whether it existed;forgetByScopefinds memories with the same escaped scope/tagFT.SEARCHfilter used for recall, deletes them in 500-key batches (loop until empty or no progress), and returns the total deleted count.buildScopeFilteris extracted frombuildRecallQueryso recall and forget share identical filter semantics (includingescapeTagfor literal*etc.).forgetByScoperejects an empty scope so callers cannot wipe the index by accident; hitting the 10k-batch safety cap logs a warning when more matches may remain.New unit tests cover idempotency, filter shape, glob escaping, pagination, and the cap warning.
Reviewed by Cursor Bugbot for commit 8ab239a. Bugbot is set up for automated code reviews on this repo. Configure here.