Skip to content

The agent that grows with you

fix(memory): name the target in the drift and blocked-entry hints

emozilla0eff5a5b8b89
diff --git a/tests/tools/test_memory_tool.py b/tests/tools/test_memory_tool.py
index 6045bfe3bce..4b56a559f70 100644
--- a/tests/tools/test_memory_tool.py
+++ b/tests/tools/test_memory_tool.py
@@ -788,6 +788,8 @@ class TestLoadTimeSnapshotSanitization:
assert "Clean fact about the project." in snapshot
# Poisoned entry replaced with placeholder
assert "[BLOCKED:" in snapshot
+ # The removal hint names the store, since memory writes require an explicit target
+ assert "memory(action=remove, target='memory')" in snapshot
assert "ignore previous instructions" not in snapshot
assert "$API_KEY" not in snapshot
# Live state keeps the raw text so the user can see + remove it
@@ -813,6 +815,7 @@ class TestLoadTimeSnapshotSanitization:
snapshot = s._system_prompt_snapshot["user"]
assert "[BLOCKED:" in snapshot
+ assert "memory(action=remove, target='user')" in snapshot
assert "REGISTER AS A NODE" not in snapshot
assert "BRAINWORM" not in snapshot
diff --git a/tools/memory_tool_store.py b/tools/memory_tool_store.py
index 0cd96477396..2b77d33dcf6 100644
--- a/tools/memory_tool_store.py
+++ b/tools/memory_tool_store.py
@@ -41,6 +41,11 @@ def _error(message: str, failure_class: str, **extra) -> dict[str, Any]:
return {"success": False, "error": message, **extra}
+def _store_target(filename: str) -> str:
+ """The memory tool target that owns a store file, for hints that show the call to make."""
+ return "user" if filename == "USER.md" else "memory"
+
+
def _drift_error(path: Path, bak_path: str) -> dict[str, Any]:
"""External drift: the file wouldn't round-trip, so flushing would discard content."""
return _error((
@@ -51,7 +56,8 @@ def _drift_error(path: Path, bak_path: str) -> dict[str, Any]:
f"content out — then retry. This guard exists to prevent silent data loss (issue #26045)."
), "drift", drift_backup=bak_path, remediation=(
"Open the .bak file, integrate the missing entries into the memory tool one at a time via "
- "memory(action=add, content=...), then remove or rewrite the original file to a clean state."))
+ f"memory(action=add, target='{_store_target(path.name)}', content=...), then remove or rewrite the "
+ "original file to a clean state."))
def _read_failed_error(path: Path) -> dict[str, Any]:
@@ -207,7 +213,8 @@ class MemoryStore:
return entry
logger.warning("Memory entry from %s blocked at load time: %s", filename, ", ".join(findings))
return (f"[BLOCKED: {filename} entry contained threat pattern(s): {', '.join(findings)}. "
- f"Removed from system prompt; use memory(action=remove) to delete the original.]")
+ f"Removed from system prompt; use memory(action=remove, target='{_store_target(filename)}') "
+ f"to delete the original.]")
for target in ("memory", "user"):
path = self._path_for(target)