Skip to content

The agent that grows with you

fix(compression): mark failures in web_extract, browser, vision and unmapped-tool stubs

kshitijk4poord70dfa87266f
diff --git a/agent/context_compressor.py b/agent/context_compressor.py
index d203e6881f3..b7ec971b6fe 100644
--- a/agent/context_compressor.py
+++ b/agent/context_compressor.py
@@ -1716,7 +1716,7 @@ def _sum_search_files(name, args, content, content_len, line_count):
def _sum_browser(name, args, content, content_len, line_count):
url, ref = args.get("url", ""), args.get("ref", "")
detail = f" {url}" if url else (f" ref={ref}" if ref else "")
- return f"[{name}]{detail} ({content_len:,} chars)"
+ return f"[{name}]{detail} ({content_len:,} chars)" + _skill_result_failure_suffix(content)
def _sum_web_extract(name, args, content, content_len, line_count):
@@ -1730,7 +1730,7 @@ def _sum_web_extract(name, args, content, content_len, line_count):
first = "?"
if isinstance(urls, list) and len(urls) > 1:
first += f" (+{len(urls) - 1} more)"
- return f"[web_extract] {first} ({content_len:,} chars)"
+ return f"[web_extract] {first} ({content_len:,} chars)" + _skill_result_failure_suffix(content)
def _sum_delegate_task(name, args, content, content_len, line_count):
@@ -1975,6 +1975,7 @@ _TOOL_RESULT_SUMMARIZERS = {
"skill_manage": _sum_skill_manage,
"vision_analyze": lambda name, args, content, content_len, line_count: (
f"[vision_analyze] '{_str_arg(args, 'question')[:50]}' ({content_len:,} chars)"
+ + _skill_result_failure_suffix(content)
),
"memory": _sum_template("[memory] {action} on {target}", action="?", target="?"),
"todo_list": lambda *a: "[todo] updated task list",
@@ -2006,7 +2007,7 @@ def _summarize_tool_result_unguarded(tool_name: str, tool_args: str, tool_conten
if summarizer is not None:
return summarizer(tool_name, args, content, content_len, line_count)
first_arg = "".join(f" {k}={str(v)[:40]}" for k, v in list(args.items())[:2])
- return f"[{tool_name}]{first_arg} ({content_len:,} chars result)"
+ return f"[{tool_name}]{first_arg} ({content_len:,} chars result)" + _skill_result_failure_suffix(content)
def _model_threshold_key_rank(key: str, model: str, provider: str) -> "tuple[int, int] | None":
diff --git a/tests/agent/test_templated_tool_result_outcome.py b/tests/agent/test_templated_tool_result_outcome.py
index 17333f9c05c..275260cc1b9 100644
--- a/tests/agent/test_templated_tool_result_outcome.py
+++ b/tests/agent/test_templated_tool_result_outcome.py
@@ -29,6 +29,8 @@ def _stub(tool_name, args, payload):
"agent exited with code 1"),
("process_manage", {"action": "poll", "session_id": "p1"},
{"status": "exited", "exit_code": 1, "completion_reason": "nonzero_exit"}, "exit code 1"),
+ # Every MCP/plugin tool falls through to the generic stub.
+ ("some_mcp_tool", {"a": 1}, {"error": "boom"}, "boom"),
],
)
def test_failed_call_stub_is_marked_failed(tool_name, args, payload, reason):