Skip to content

fix(bedrock): strip None values from message content blocks#1503

Open
xodn348 wants to merge 1 commit intoanthropics:mainfrom
xodn348:fix/issue-1454
Open

fix(bedrock): strip None values from message content blocks#1503
xodn348 wants to merge 1 commit intoanthropics:mainfrom
xodn348:fix/issue-1454

Conversation

@xodn348
Copy link
Copy Markdown

@xodn348 xodn348 commented May 6, 2026

Fixes #1454

What

Bedrock rejects null for optional fields (like ToolUseBlock.caller) that the Anthropic API silently ignores. When users roundtrip a ToolUseBlock response (where caller=None) back into a subsequent request via .to_dict() or .model_dump(), the serialized "caller": null causes Bedrock to return:

400 - messages.N.content.M.tool_use.caller: Input should be a valid dictionary or object to extract fields from

This adds a _strip_none_values helper and applies it to message content block dicts in the Bedrock _prepare_options function, removing None values before the request is sent.

Verification

  • Build: pass
  • Tests: pass (13 passed, including new test)
  • Lint: pass (ruff)
  • Type check: pass (pyright, 0 errors)

…cs#1454)

Bedrock rejects `null` for optional fields like `ToolUseBlock.caller`
that the Anthropic API silently ignores. When users roundtrip a
ToolUseBlock (with `caller: None`) back into a subsequent request,
the Bedrock API returns a 400 error.

Strip None values from message content block dicts in
`_prepare_options` before the request is sent.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@xodn348 xodn348 requested a review from a team as a code owner May 6, 2026 05:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ToolUseBlock and ToolUseBlockParam type conflict for caller nullability

1 participant