← Back to Pull requests

Record Anthropic server tool blocks as tool call parts #2642

Open
unknown opened this pull request with 249 lines diff across 3 files
View on GitHub
unknown unknown commented on Oct 21, 2026 17:16 UTC
Author

convert_response_to_semconv handled text and tool_use blocks and dumped every other block as a raw dict. Server-side tools (web search, web fetch, code execution, ...) therefore showed up in gen_ai.output.messages as server_tool_use and web_search_tool_result dicts instead of message parts, and the same happened to those blocks in an assistant message sent back as input.

A server_tool_use block is now a tool_call part and a *_tool_result block (anything that carries a tool_use_id) a tool_call_response part, converted from the SDK models to plain data. The streamed response goes through the same conversion.

Parts for server tools reuse tool_call and tool_call_response, since the semconv module here has no separate server-tool part; happy to switch if you'd rather have one. The result content is passed through as plain data, including the encrypted_content of web search results, exactly what the raw block dump already carried; dropping that field to keep spans smaller is a one-line change if you prefer. Tests use the SDK's own ServerToolUseBlock, WebSearchToolResultBlock and WebSearchResultBlock for a response, and dicts for the input side; they fail on main.

This change was made with Claude Code (AI-assisted); the tests above were run, but no request was made to the Anthropic API.

🤖 Generated with Claude Code

<!-- This is an auto-generated description by cubic. -->
<a href="https://cubic.dev/pr/pydantic/logfire/pull/2642?utm_source=github" target="_blank" rel="noopener noreferrer" data-no-image-dialog="true"><picture><source media="(prefers-color-scheme: dark)" srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source media="(prefers-color-scheme: light)" srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img alt="View guided diff" src="https://www.cubic.dev/buttons/review-in-cubic-light.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->

Diff: 249 lines (+186 / -63) across 3 files Reviewer: pcbeingused333 Review duration: 51690m
All Vouch review confidence checks passed
Residual risk 0.25 = Change Risk (0.46) × (1 − Review Confidence (0.45)). Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.46 · 249 lines diff across 3 files
0.46
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
0.02
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
44%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth shallow_review_depth
0.344
Diff Size diff_size
0.330
Real PR Conversation Timeline
1 comments
"Review active on #2642"
general weight: 0.35
Assignees
Unassigned
Labels
risk: low confidence: 44.7% reviewed
Vouch Risk Breakdown
AI-powered review risk analysis
Change Risk
Change Risk · Model 1 (XGBoost)
Predicted defect probability (0.00–1.00) based on diff churn, modified sensitive files, and author risk history.
Score: 46.0% (MEDIUM) · Higher = larger blast radius
46.0%
Review Confidence
Review Confidence · Models 2 & 3
Scrutiny score (0.00–1.00) combining DistilBERT semantic review depth with reviewer familiarity and session dwell time.
Score: 44.7% · Lower = rushed or shallow review
44.7%
Residual Risk
Residual Risk · Core Equation
Residual = Change × (1 − Confidence)
Unmitigated risk surviving review. ≥ 0.65 triggers an automated re-queue to protect production.
Score: 25.4% · Safe to merge
25.4%