The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix: mirror successful memory alias writes to providers
Teknium4fbb25390417
diff --git a/agent/memory_manager.py b/agent/memory_manager.pyindex 44ca6f930e8..bc23f6617b4 100644--- a/agent/memory_manager.py+++ b/agent/memory_manager.py@@ -759,7 +759,7 @@ class MemoryManager:old_text = op.get("old_text")if old_text:metadata["old_text"] = str(old_text)- self.on_memory_write(action, target, str(op.get("content") or ""), metadata=metadata)+ self.on_memory_write(action, target, str(op.get("content") or op.get("new_text") or ""), metadata=metadata)except Exception as e:logger.debug("notify_memory_tool_write failed for op %s: %s", action, e)diff --git a/tests/agent/test_inline_tool_executors_memory_args.py b/tests/agent/test_inline_tool_executors_memory_args.pyindex 7154110f90f..5304ffe0457 100644--- a/tests/agent/test_inline_tool_executors_memory_args.py+++ b/tests/agent/test_inline_tool_executors_memory_args.py@@ -10,7 +10,23 @@ from tools.memory_tool_store import MemoryStoredef test_memory_alias_persists_with_content_precedence(tmp_path, monkeypatch):monkeypatch.setenv("HERMES_HOME", str(tmp_path))store = MemoryStore(memory_char_limit=500, user_char_limit=300)- agent = SimpleNamespace(_memory_store=store, _memory_manager=None)+ from agent.memory_manager import MemoryManager++ class Sink:+ name = "test-sink"+ writes = []++ def get_tool_schemas(self):+ return []++ def on_memory_write(self, action, target, content, metadata=None):+ self.writes.append((action, target, content))++ sink = Sink()+ manager = MemoryManager()+ manager.add_provider(sink)+ agent = SimpleNamespace(_memory_store=store, _memory_manager=manager,+ _build_memory_write_metadata=lambda **kwargs: kwargs)ctx = InlineToolContext(effective_task_id="task-1", tool_call_id="call-1")def call(**args):@@ -22,6 +38,7 @@ def test_memory_alias_persists_with_content_precedence(tmp_path, monkeypatch):assert result["success"], resultpath = tmp_path / "memories" / "USER.md"assert "Household owns a saloon." in path.read_text(encoding="utf-8")+ assert sink.writes[-1] == ("replace", "user", "Household owns a saloon.")result = call(action="replace", target="user", old_text="Household owns a saloon.",content="Household owns a hatchback.", new_text="Household owns a van.")assert result["success"], result@@ -29,3 +46,8 @@ def test_memory_alias_persists_with_content_precedence(tmp_path, monkeypatch):assert "Household owns a hatchback." in persistedassert "van" not in persistedassert "saloon" not in persisted+ assert sink.writes[-1] == ("replace", "user", "Household owns a hatchback.")+ result = call(target="user", operations=[{"action": "replace", "old_text": "Household owns a hatchback.",+ "new_text": "Household owns a coupe."}])+ assert result["success"], result+ assert sink.writes[-1] == ("replace", "user", "Household owns a coupe.")