From 54e1864577655aadc870d09e79aebbbcf8a812d5 Mon Sep 17 00:00:00 2001 From: kshitijk4poor <82637225+kshitijk4poor@users.noreply.github.com> Date: Fri, 10 Jul 2026 19:07:21 +0530 Subject: [PATCH] fix(acp): unwrap web extract object titles --- acp_adapter/tools.py | 7 ++++++- tests/acp/test_tools.py | 12 ++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/acp_adapter/tools.py b/acp_adapter/tools.py index cbf7d15b3b8..fce98cf54e6 100644 --- a/acp_adapter/tools.py +++ b/acp_adapter/tools.py @@ -110,7 +110,12 @@ def build_tool_title(tool_name: str, args: Dict[str, Any]) -> str: if tool_name == "web_extract": urls = args.get("urls", []) if urls: - return f"extract: {urls[0]}" + (f" (+{len(urls)-1})" if len(urls) > 1 else "") + first = urls[0] + if isinstance(first, dict): + first = first.get("url") or first.get("href") or "?" + elif not isinstance(first, str): + first = "?" + return f"extract: {first}" + (f" (+{len(urls)-1})" if len(urls) > 1 else "") return "web extract" if tool_name == "process": action = str(args.get("action") or "").strip() or "manage" diff --git a/tests/acp/test_tools.py b/tests/acp/test_tools.py index 1da33df1ed4..b291b36531a 100644 --- a/tests/acp/test_tools.py +++ b/tests/acp/test_tools.py @@ -116,6 +116,18 @@ class TestBuildToolTitle: title = build_tool_title("web_search", {"query": "python asyncio"}) assert "python asyncio" in title + def test_web_extract_title_unwraps_search_result_object(self): + title = build_tool_title("web_extract", { + "urls": [ + {"url": "https://example.com/a", "title": "A"}, + {"href": "https://example.org/b"}, + ] + }) + assert title == "extract: https://example.com/a (+1)" + + def test_web_extract_title_handles_malformed_object(self): + assert build_tool_title("web_extract", {"urls": [{"title": "missing"}]}) == "extract: ?" + def test_skill_view_title_includes_skill_name(self): title = build_tool_title("skill_view", {"name": "github-pitfalls"}) assert title == "skill view (github-pitfalls)"