The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(memory): report and mirror patch results
Yuan Life1742da4416
diff --git a/agent/memory_manager.py b/agent/memory_manager.pyindex d8f772f7f91..2252311eeb8 100644--- a/agent/memory_manager.py+++ b/agent/memory_manager.py@@ -870,7 +870,7 @@ class MemoryManager:# Actions mirrored to external providers; non-mutating results (errors, staged) are# filtered by ``notify_memory_tool_write`` first.- _MIRRORED_MEMORY_ACTIONS = {"add", "replace", "remove"}+ _MIRRORED_MEMORY_ACTIONS = {"add", "replace", "patch", "remove"}@staticmethoddef _memory_tool_result_succeeded(result: Any) -> bool:@@ -908,7 +908,7 @@ class MemoryManager:old_text = op.get("old_text")if old_text:metadata["old_text"] = str(old_text)- field = {"replace": "replaced", "remove": "removed"}.get(action)+ field = {"replace": "replaced", "patch": "patched", "remove": "removed"}.get(action)if field:if batched:entries = result.get(f"{field}_entries", {})diff --git a/hermes_cli/write_approval_commands.py b/hermes_cli/write_approval_commands.pyindex f54871486c4..e3fbd181330 100644--- a/hermes_cli/write_approval_commands.py+++ b/hermes_cli/write_approval_commands.py@@ -83,6 +83,7 @@ def _approve(subsystem: str, rest: list[str], memory_store) -> str:wa.discard_pending(subsystem, rec["id"])applied += 1overwritten.extend(f" {rec['id']}: {text}" for text in _changed_entries(result, "replaced"))+ overwritten.extend(f" {rec['id']}: {text}" for text in _changed_entries(result, "patched"))removed.extend(f" {rec['id']}: {text}" for text in _changed_entries(result, "removed"))else:failed.append(f"{rec['id']}: {msg}")diff --git a/tools/memory_tool_store.py b/tools/memory_tool_store.pyindex add74b1f417..705b81c430f 100644--- a/tools/memory_tool_store.py+++ b/tools/memory_tool_store.py@@ -563,11 +563,15 @@ class MemoryStore:return {"success": True, "matched_entries": matched}# op index -> full entry text its replace/remove selected (#117952), 1-based to# match the "Operation N" error numbering the model sees for failed ops.- replaced, removed = {}, {}+ replaced, removed, patched = {}, {}, {}for i, (op, previous_content) in enumerate(zip(ops, matched), 1):if previous_content is not None:- (replaced if op.get("action") == "replace" else removed)[i] = previous_content+ result_map = {"replace": replaced, "patch": patched, "remove": removed}.get(op.get("action"))+ if result_map is not None:+ result_map[i] = previous_contentreplaced_fields = {"replaced_entries": replaced} if replaced else {}+ if patched:+ replaced_fields["patched_entries"] = patchedif removed:replaced_fields["removed_entries"] = removedreturn working, f"Applied {len(operations)} operation(s).", replaced_fields