-
Notifications
You must be signed in to change notification settings - Fork 79
Open
Description
When using the web search tool (web_search_20250305), the Go SDK's Message.ToParam() method fails to properly convert WebSearchToolResultBlock and ServerToolUseBlock content, resulting in empty content blocks that cause API errors in multi-turn conversations.
Steps to reproduce:
- Enable web search tool in API request
- Send a message that triggers web search (e.g., "What's the latest news about AI?")
- Store the assistant's response using message.ToParam()
- Send a follow-up message in the same conversation
- API returns error: "messages.1: all messages must have non-empty content except for the optional final assistant message"
Root Cause
The SDK's ToParam() method (in message.go:664-680) only handles:
- TextBlock
- ToolUseBlock
- ThinkingBlock
- RedactedThinkingBlock
It does NOT handle:
- ServerToolUseBlock (used for web search invocation)
- WebSearchToolResultBlock (contains search results)
When encountering these unhandled types, it returns an empty ContentBlockParamUnion{}.
Impact
Applications cannot use web search in multi-turn conversations without implementing custom message conversion logic to filter out or properly handle these blocks.
Suggested Fix
Update the SDK's ToParam() method to properly handle ServerToolUseBlock and WebSearchToolResultBlock
mrzahrada and JanRuettinger
Metadata
Metadata
Assignees
Labels
No labels