rm caller field from Anthropic `tool_use` blocks

Merged
SE
1y ago
+13-3

why

what changed

  • Strip Anthropic’s beta-only caller field from tool_use blocks before persisting conversation history so subsequent beta.messages.create calls don’t send invalid keys.
  • The _process_provider_response path now model_dump()s each response.content block, removes caller, and falls back gracefully if serialization fails.
  • Fix ensures Stagehand agents can complete multi-step Claude sessions without the 400 "messages.*.tool_use.caller: Extra inputs are not permitted" error

test plan


Summary by cubic

Strip Anthropic’s beta-only caller field from tool_use blocks when saving conversation history, so we don’t resend invalid keys on the next call. Fixes the 400 “messages.*.tool_use.caller: Extra inputs are not permitted” error in multi-step Claude sessions (addresses #249).

  • Bug Fixes
    • In _process_provider_response, serialize each content block, remove caller, and handle serialization failures gracefully.
    • Prevent invalid keys in beta.messages.create to keep multi-step sessions running.