Record Anthropic server tool blocks as tool call parts
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