fix(acp): unwrap web extract object titles

This commit is contained in:
kshitijk4poor 2026-07-10 19:07:21 +05:30 committed by kshitij
parent 0b753d8918
commit 54e1864577
2 changed files with 18 additions and 1 deletions

View file

@ -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"

View file

@ -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)"