fix: filter extra fields from tool_use blocks to prevent Anthropic API rejection
PS
1y ago+13+13+01234567890123456789-2-2-0123456789
Summary
- Filters
tool_useblocks to only include fields that Anthropic accepts in requests:type,id,name, andinput - Prevents agent failures on step 2+ caused by the
callerfield being rejected
Problem
Anthropic's API returns a caller field in tool_use response blocks (introduced with programmatic tool calling), but rejects this field when sent back in subsequent requests. The current model_dump() preserves all fields, causing validation errors.
Test plan
- Unit tests pass
- Manual test with multi-step agent execution
🤖 Generated with Claude Code
Summary by cubic
Strip unsupported fields from tool_use blocks before sending to Anthropic to prevent validation errors and multi-step agent failures. Only type, id, name, and input are kept; caller is removed.