Repository navigation
Conversation
Greptile SummaryThis PR makes the agentic-loop web search response match the native Anthropic block shape. The main changes are:
Confidence Score: 5/5Safe to merge based on the narrow response-shape change and focused test coverage. The change is isolated to native web search block construction and tests cover the paired block ordering and matching tool-use IDs.
What T-Rex did
Reviews (1): Last reviewed commit: "fix: emit server_tool_use block on agent..." | Re-trigger Greptile |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
9ee8b7a to
d690712
Compare
Builds ghcr.io/haha1903/litellm on push of a patched-v* tag, carrying the agentic-loop web_search server_tool_use fix on top of upstream until it lands upstream (PR BerriAI#31687).
d690712 to
0ab94c8
Compare
26ac40c to
cca71a0
Compare
The agentic-loop web search path (providers with native Anthropic Messages support — anthropic, bedrock, vertex_ai, azure_ai) built only a web_search_tool_result block per tool_call via _build_native_result_blocks, omitting the paired server_tool_use block. Anthropic-native clients (Claude Code, Claude Desktop, the SDK) need both to render citation cards, so without it the client reports "Did 0 searches". The short-circuit path already emits the pair (BerriAI#27886); this brings the agentic-loop path to parity. Each result block is now preceded by a server_tool_use block carrying the query, with a matching tool_use_id.
0ab94c8 to
9df0fa5
Compare
|
Hi @krrish-berri-2 — friendly ping for review when you have a moment. This is a small follow-up to #31669 (which you merged): that PR added the native
Thanks! |
Relevant issues
Follow-up to #27886, which added native
server_tool_use+web_search_tool_resultblocks on the short-circuit web search path. This PR brings the agentic-loop path to parity.Pre-Submission checklist
Type
🐛 Bug Fix
Changes
WebSearchInterceptionLogger._build_native_result_blocks(used by the agentic-loop path for providers that have native Anthropic Messages support —anthropic,bedrock,vertex_ai,azure_ai) emitted only aweb_search_tool_resultblock per tool call, omitting the pairedserver_tool_useblock.Anthropic-native clients (Claude Code, Claude Desktop, the Anthropic SDK) require both blocks to render citation cards. Without the
server_tool_useblock the client reports "Did 0 searches" even though the search ran and results were returned.The short-circuit path already emits the pair (added in #27886). This makes the two paths consistent: each
web_search_tool_resultis now preceded by aserver_tool_useblock carrying the query, with a matchingtool_use_id.for i, tool_call in enumerate(tool_calls): tool_use_id = tool_call.get("id") or "" + tool_input = tool_call.get("input") or {} + query = tool_input.get("query") if isinstance(tool_input, dict) else None structured = structured_results[i] if i < len(structured_results) else None + blocks.append({ + "type": "server_tool_use", "id": tool_use_id, + "name": "web_search", + "input": {"query": query} if query is not None else {}, + }) blocks.append(WebSearchTransformation.build_web_search_tool_result_block(...))Tests
Updated
test_websearch_native_blocks.pyto assert the paired shape on both the plan path and the legacy path, including thatserver_tool_use.id == web_search_tool_result.tool_use_id.Proof of fix
Running a proxy that routes Claude requests through the agentic-loop web search path, a
web_search_20250305request now returns the full native shape:Before this fix the same request returned only
['web_search_tool_result', 'text'], and Claude Code showed "Did 0 searches" with no citation card. After, the client renders citation cards normally.