The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(memory): treat serialized-empty content as unset for the new_text alias
liuhao102426dd1ddfb3b1
diff --git a/tests/tools/test_memory_tool.py b/tests/tools/test_memory_tool.pyindex da4bff3d56b..533209953a3 100644--- a/tests/tools/test_memory_tool.py+++ b/tests/tools/test_memory_tool.py@@ -478,6 +478,28 @@ class TestMemoryToolDispatcher:assert result["success"] is Trueassert "added via new_text" in store.memory_entries+ def test_new_text_alias_used_when_content_serialized_empty(self, store):+ # Runtimes that materialize an omitted optional string as "" (#90468)+ # used to bypass the alias and fail 'content is required'.+ store.add("memory", "fact A")+ result = json.loads(+ memory_tool(+ action="replace",+ old_text="fact A",+ content="",+ new_text="fact A refined",+ store=store,+ )+ )+ assert result["success"] is True+ assert "fact A refined" in store.memory_entries++ result_add = json.loads(+ memory_tool(action="add", content="", new_text="added despite empty", store=store)+ )+ assert result_add["success"] is True+ assert "added despite empty" in store.memory_entries+def test_content_wins_when_both_content_and_new_text_set(self, store):result = json.loads(memory_tool(action="add", content="the real one", new_text="ignored", store=store)diff --git a/tools/memory_tool.py b/tools/memory_tool.pyindex a768f015b18..288c1102721 100644--- a/tools/memory_tool.py+++ b/tools/memory_tool.py@@ -225,7 +225,8 @@ def _applied(result: Dict[str, Any]) -> Tuple[str, str]:def _memory_tool(action, target, content, old_text, new_text, operations, store) -> Tuple[str, str]:"""``(outcome, result_json)``: ``rejected`` when refused or held before touching the store."""- if content is None and new_text is not None:+ # An omitted optional string can arrive as "" (#90468): let the new_text alias fill it.+ if not content and new_text:content = new_text# Strict providers send JSON null for optional fields; treat as omitted.target = "memory" if target is None else target