The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(memory): point empty-batch refusal at single remove() calls (#103419)
Halldrix7602b33d79d9
diff --git a/tests/tools/test_memory_tool.py b/tests/tools/test_memory_tool.pyindex 6b7346ccf23..f1823f05231 100644--- a/tests/tools/test_memory_tool.py+++ b/tests/tools/test_memory_tool.py@@ -733,6 +733,7 @@ class TestBatchRefusesToEmptyNonEmptyStore:assert result["success"] is Falseassert "current_entries" in result # actionable, counts toward degrade budget+ assert "single remove()" in result["error"] # points at the deliberate-wipe pathassert seed in path.read_text(encoding="utf-8") # nothing writtenassert path.read_text(encoding="utf-8") == beforeassert seed in store._entries_for(target)diff --git a/tools/memory_tool_store.py b/tools/memory_tool_store.pyindex 4dcc3b57018..50d8ae141ee 100644--- a/tools/memory_tool_store.py+++ b/tools/memory_tool_store.py@@ -322,14 +322,16 @@ class MemoryStore:# store (#103419): a background consolidation that removes the# last entry would otherwise commit an empty USER.md/MEMORY.md# as a normal successful write. Refuse all-or-nothing so the- # model keeps at least one entry; a deliberate wipe is a manual- # file edit, not a consolidation side effect.+ # model keeps at least one entry; deleting the final entry on+ # purpose is what single remove() calls are for, not a+ # consolidation side effect.label = "USER.md" if target == "user" else "MEMORY.md"return self._failure_with_entries(target, (f"Refusing to empty {label}: this batch would remove every entry from a "f"previously non-empty profile. Nothing was applied (batch is all-or-nothing). "f"Keep at least one entry — merge overlapping entries into a shorter one instead "- f"of removing the last one (see current_entries below)."))+ f"of removing the last one (see current_entries below). To delete the final entry "+ f"deliberately, use single remove() calls."))new_total = len(ENTRY_DELIMITER.join(working)) # budget check against the FINAL state onlyif new_total > limit:return self._failure_with_entries(target, (