Skip to content

feat(memory): add audit action and update memory review prompt (#59823) - #59919

Closed
webtecnica wants to merge 2 commits into
NousResearch:mainfrom
webtecnica:feat/59823-memory-audit
Closed

webtecnica wants to merge 2 commits into
NousResearch:mainfrom
webtecnica:feat/59823-memory-audit

Conversation

@webtecnica

Copy link
Copy Markdown
Contributor

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..."}
  ]
}
  • Added to schema enums (singleton + batch)
  • Skips write gate (non-mutating)
  • Placed before validation so no content/old_text required

2. Updated _MEMORY_REVIEW_PROMPT (agent/background_review.py)

From simple "save to memory" to a 3-phase workflow:

Phase Action Description
1 — Audit memory(action='audit') List current entries, classify each
2 — Clean remove / replace Remove task residue, consolidate duplicates
3 — Save memory(action='add') Save new durable facts from conversation

3. Schema description updated

MEMORY_SCHEMA now lists all 4 actions (audit, add, replace, remove).

Files Changed

File Δ Description
tools/memory_tool.py +12/-5 Audit handler + schema updates
agent/background_review.py +21/-7 3-phase memory review prompt

Built with parallel delegation

Sub-tasks A (audit tool) and B (prompt rewrite) were developed independently via Hermes delegate_task and merged into one PR.

Closes #59823

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
@webtecnica

Copy link
Copy Markdown
Contributor Author

@teknium1 Ready for review. New feature — memory(action='audit') read-only action + updated memory review prompt with 3-phase Classify → Clean → Save workflow. Built with parallel sub-agents. 21 lines total, CI should be clean. 🙏

@alt-glitch alt-glitch added type/feature New feature or request comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint tool/memory Memory tool and memory providers P3 Low — cosmetic, nice to have duplicate This issue or pull request already exists labels Jul 7, 2026
@alt-glitch

Copy link
Copy Markdown
Contributor

This was generated by AI during triage.

Duplicate of #59826 — same author, same feature: memory(action='audit') read-only handler in tools/memory_tool.py plus the 3-phase _MEMORY_REVIEW_PROMPT rewrite in agent/background_review.py. #59826 is the earlier-open version and additionally ships tests (tests/tools/test_memory_audit.py, tests/tools/test_memory_tool_schema.py). Both close #59823 (the feature spec); a maintainer should pick one.

@webtecnica

Copy link
Copy Markdown
Contributor Author

Closing as duplicate — the sweeper identified this as already covered by another PR. Thanks for the contribution!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/agent Core agent runtime: loop, agent_init, prompt builder, context-compression, responses endpoint duplicate This issue or pull request already exists P3 Low — cosmetic, nice to have tool/memory Memory tool and memory providers type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat(memory): add audit action for self-cleaning — stop memory entropy

2 participants