feat: bulk delete by project name #14
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Problem
There is currently no way to delete all memories belonging to a project in a single operation. The only deletion path is
forgetwhich operates on individual keys.This became a real problem during the LongMemEval benchmark run (~500 items × 53 sessions = ~26,500 memories). The cleanup strategy in the runner used
recall_indexwithproject_filterto find keys, then deleted them one by one. This has two failure modes:After the benchmark run, OmniMem had 24,176 memories instead of the expected ~200, requiring a separate cleanup script to recover.
Proposed solution
Add a
delete_projectMCP tool (and corresponding internal method) that:confirm=Trueas a safety gate (consistent withforget)Optionally also support a
delete_by_tagvariant for similar bulk cleanup use cases.Why not just use forget_project workaround?
The current workaround of querying semantically then deleting is fundamentally broken for this use case — you can't reliably find memories by querying for them if the whole point is that recall doesn't work well on that content. Direct project-scoped deletion needs to bypass the search layer entirely and operate on the metadata index.
Context
Discovered during the OmniMem × LongMemEval benchmark project. Related to issue #11 (Valkey index drift).
Workaround until this is implemented
Direct Valkey Lua script — bypasses OmniMem entirely and operates on the hash fields directly. Clears 24k memories in seconds.
Step 1 — write the script into the container:
Step 2 — run it:
Returns the count of deleted keys. The prefix match (
bench_) can be adjusted for other project naming patterns.Note: this only deletes the raw hash keys. A proper
delete_projectimplementation in OmniMem should also handle the search index cleanup to avoid the index drift described in issue #11.Shipped in v5.4.0 on branch
v5(commit08b1554).delete_project(project_name, confirm=False, include_context=False)is now a registered MCP tool:project/project_namefields with a projected batch fetch, so it catches everything, including memories recall can't surface (the failure mode that left ~24k orphans after the benchmark run).ValkeyStore.delete_many()deletes in batches of 500 per pipeline round-trip. Verified live against valkey-search: 1,200 keys in ~15ms, so the 26,500-memory cleanup that took ~45 minutes would now finish in well under a second.confirm=False(default) returns a preview with per-namespace counts; the project context entry (mem:project:<name>) is kept unless you passinclude_context=True; project names are validated against the standard allowlist.The optional
delete_by_tagvariant mentioned in the proposal wasn't included — happy to raise a separate issue if it's still wanted, butdelete_projectcovers the benchmark-cleanup case that motivated this.589 tests pass (8 new covering preview counts, cross-namespace deletion, context-entry handling, cache invalidation, and name validation).