diff --git a/agent/display.py b/agent/display.py index 474595d76c..7afb9db12b 100644 --- a/agent/display.py +++ b/agent/display.py @@ -223,7 +223,8 @@ def build_tool_preview(tool_name: str, args: dict, max_len: int | None = None) - target = args.get("target", "") if action == "add": content = _oneline(args.get("content", "")) - return f"+{target}: \"{content[:25]}{'...' if len(content) > 25 else ''}\"" + target_prefix = f"+{target}: " if target else "+" + return f"{target_prefix}\"{content[:25]}{'...' if len(content) > 25 else ''}\"" elif action == "replace": old = _oneline(args.get("old_text") or "") or "" return f"~{target}: \"{old[:20]}\"" diff --git a/tests/agent/test_display.py b/tests/agent/test_display.py index 4c1309a44c..76b257438b 100644 --- a/tests/agent/test_display.py +++ b/tests/agent/test_display.py @@ -82,6 +82,11 @@ class TestBuildToolPreview: result = build_tool_preview("memory", {"action": "add", "target": "user", "content": "test note"}) assert result is not None assert "user" in result + assert "\n" not in result + + def test_memory_tool_add_without_target_stays_one_line(self): + result = build_tool_preview("memory", {"action": "add", "content": "User identifies as a cutie patootie."}) + assert result == '+"User identifies as a cuti..."' def test_memory_replace_missing_old_text_marked(self): # Avoid empty quotes "" in the preview when old_text is missing/None.