fix(display): render <missing old_text> in memory previews instead of empty quotes (#12852)

When the model omits old_text on memory replace/remove, the tool preview
rendered as '~memory: ""' / '-memory: ""', which obscured what went wrong.
Render '<missing old_text>' in that case so the failure mode is legible
in the activity feed.

Narrow salvage from #12456 / #12831 — only the display-layer fix, not the
schema/API changes.
This commit is contained in:
Teknium
2026-04-19 22:45:47 -07:00
committed by GitHub
parent 6a228d52f7
commit fc5fda5e38
2 changed files with 17 additions and 4 deletions

View File

@@ -83,6 +83,13 @@ class TestBuildToolPreview:
assert result is not None
assert "user" in result
def test_memory_replace_missing_old_text_marked(self):
# Avoid empty quotes "" in the preview when old_text is missing/None.
result = build_tool_preview("memory", {"action": "replace", "target": "memory"})
assert result == '~memory: "<missing old_text>"'
result = build_tool_preview("memory", {"action": "remove", "target": "memory", "old_text": None})
assert result == '-memory: "<missing old_text>"'
def test_session_search_preview(self):
result = build_tool_preview("session_search", {"query": "find something"})
assert result is not None