feat: add memory_purge_scope tool for batch scope cleanup#144
feat: add memory_purge_scope tool for batch scope cleanup#144baizenghu wants to merge 1 commit intoCortexReach:mainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Review: feat: add memory_purge_scope tool for agent-level scope cleanupVerdict: Fix-then-merge — zero test coverage on a destructive operation is the blocking issue. ✅ What's working
🔴 BlockingNo test file. Minimum coverage needed in a new // confirm guard
assert: calling with confirm=false → returns { error: "not_confirmed" }
// empty scope guard
assert: calling with scope="" → returns { error: "invalid_scope" }
// access control
assert: calling with an out-of-scope scope → returns { error: "scope_access_denied" }
// happy path
assert: calling with a valid scope → deletedCount matches actual records purgedAlso wire into 🟡 Suggested before mergeNo audit log on success. // after deletedCount is returned
context.logger?.debug?.(`memory_purge_scope: agentId=${agentId} scope=${scope} deleted=${deletedCount}`);⚪ Non-blocking
The four-layer guard sequence and |
Problem
Currently there is no way to delete all memories within a specific scope at once. Users who want to clean up stale or test data from a particular scope must delete entries one by one using
memory_delete, which is tedious and error-prone.This becomes especially painful when:
Solution
Add a new
memory_purge_scopetool that deletes all memories within a given scope in a single operation.Safety Features
scopeManager.isAccessible()before deletionconfirm: trueparameter to prevent accidental purgesTool Signature
Example Usage
Implementation
registerMemoryPurgeScopeTool()insrc/tools.tsstore.bulkDelete([scope])under the hoodTesting
Verified in production — agents can clean up their own scopes but cannot purge scopes they don't have access to.