feat(memory): add audit action and update memory review prompt (#59823) - #59919
webtecnica wants to merge 2 commits into
Conversation
Adds a new read-only "audit" action to the memory tool that returns the current state of memory entries including usage stats and entry previews. Changes: - Add "audit" to the action enum in MEMORY_SCHEMA (single-op schema) - Add "audit" to the action enum in the batch operations schema - Add "audit" to the non-mutating action set in _apply_write_gate() - Add audit handler in memory_tool() that returns JSON with target, usage, usage_pct, entry_count, and entries list (idx, chars, preview)
Three changes for memory self-cleaning (Issue NousResearch#59823): 1. Add memory(action='audit') — read-only action that returns current entries with preview, char count, usage %, and index. Skips the write gate (non-mutating). 2. Rewrite _MEMORY_REVIEW_PROMPT from simple 'save to memory' to a 3-phase workflow: Audit → Classify (durable-fact vs task-residue) → Clean → Save. Prevents task residue accumulation. 3. Update MEMORY_SCHEMA description to document the 'audit' action. Sub-tasks A (audit tool) and B (prompt rewrite) built in parallel via delegate_task. Closes NousResearch#59823
|
@teknium1 Ready for review. New feature — |
Duplicate of #59826 — same author, same feature: |
|
Closing as duplicate — the sweeper identified this as already covered by another PR. Thanks for the contribution! |
Summary
Memory tool currently has no read-only action — the model can only add/replace/remove entries, never inspect what's already there. This causes task residue accumulation and prevents proactive self-cleaning.
Changes
1.
memory(action="audit")— read-only inspection (tools/memory_tool.py)New action returns current memory state without mutating:
{ "target": "memory", "usage": "1,062/2,200 chars", "usage_pct": "48%", "entry_count": 8, "entries": [ {"idx": 0, "chars": 120, "preview": "hermes config set não..."}, {"idx": 1, "chars": 280, "preview": "PR operation red lines..."} ] }2. Updated
_MEMORY_REVIEW_PROMPT(agent/background_review.py)From simple "save to memory" to a 3-phase workflow:
memory(action='audit')remove/replacememory(action='add')3. Schema description updated
MEMORY_SCHEMA now lists all 4 actions (audit, add, replace, remove).
Files Changed
tools/memory_tool.pyagent/background_review.pyBuilt with parallel delegation
Sub-tasks A (audit tool) and B (prompt rewrite) were developed independently via Hermes
delegate_taskand merged into one PR.Closes #59823