Skip to content

The agent that grows with you

fix(memory): show patch edits in the activity feed

emozillaf7c920fc2034
diff --git a/agent/display.py b/agent/display.py
index 46bf04a0346..d9efb9c0afc 100644
--- a/agent/display.py
+++ b/agent/display.py
@@ -423,9 +423,9 @@ def _preview_memory(args: dict, _max_len: int) -> str:
action, target = args.get("action", ""), args.get("target", "")
if action == "add":
return f"+{target}: \"{_clip(_oneline(args.get('content', '')), 25)}\""
- if action in ("replace", "remove"):
+ if action in ("replace", "patch", "remove"):
old = _oneline(args.get("old_text") or "") or t("display.preview.missing_old_text")
- return f"{'~' if action == 'replace' else '-'}{target}: \"{old[:20]}\""
+ return f"{'-' if action == 'remove' else '~'}{target}: \"{old[:20]}\""
return action
@@ -1093,9 +1093,9 @@ def _cute_memory(a: dict, _r) -> str:
action, target = a.get("action", "?"), a.get("target", "")
if action == "add":
return _cute_row("🧠", "memory", f"+{target}: \"{_cute_trunc(a.get('content', ''))}\"")
- if action in ("replace", "remove"):
+ if action in ("replace", "patch", "remove"):
old = a.get("old_text") or t("display.preview.missing_old_text")
- return _cute_row("🧠", "memory", f"{'~' if action == 'replace' else '-'}{target}: \"{_cute_trunc(old)}\"")
+ return _cute_row("🧠", "memory", f"{'-' if action == 'remove' else '~'}{target}: \"{_cute_trunc(old)}\"")
return _cute_row("🧠", "memory", str(action))
diff --git a/tests/agent/test_display.py b/tests/agent/test_display.py
index 8b43fa84d25..ac4e2b06c8d 100644
--- a/tests/agent/test_display.py
+++ b/tests/agent/test_display.py
@@ -52,6 +52,11 @@ class TestBuildToolPreview:
+ def test_memory_patch_preview_shows_the_span_being_edited(self):
+ args = {"action": "patch", "target": "memory", "old_text": "port 8080", "content": "port 9090"}
+ assert build_tool_preview("memory", args) == '~memory: "port 8080"'
+ assert '~memory: "port 8080"' in get_cute_tool_message("memory", args, 0.1)
+
def test_browser_type_preview_redacts_api_key(self):
secret = "sk-proj-ABCD1234567890EFGH"
result = build_tool_preview("browser_type", {"ref": "@e3", "text": secret})