Skip to content

fix(bedrock): trim beta names when copying anthropic-beta into the body - #2024

Open
sebxt wants to merge 1 commit into
anthropics:mainfrom
sebxt:fix/bedrock-beta-header-whitespace
Open

sebxt wants to merge 1 commit into
anthropics:mainfrom
sebxt:fix/bedrock-beta-header-whitespace

Conversation

@sebxt

@sebxt sebxt commented Oct 18, 2026

Copy link
Copy Markdown

_prepare_options in the Bedrock client copies the anthropic-beta header into the body as anthropic_beta by splitting on , without trimming. A header such as "context-1m-2025-08-07, other-beta" became ["context-1m-2025-08-07", " other-beta"], and a trailing comma added an empty entry, so Bedrock received beta names it does not recognise.

This change strips each entry and drops empty ones, which matches the TypeScript Bedrock client and the other places in this SDK that parse the header. A header that is already comma separated without spaces produces the same list as before. If nothing is left after stripping, anthropic_beta is not set, as before for an empty header.

Test: test_prepare_options_strips_whitespace_from_anthropic_beta_header in tests/lib/test_bedrock.py fails on main and passes with the fix. The rest of tests/lib passes.

No public names or signatures change.

Fixes #2023

Signed-off-by: Sebastian Turner <sebastiant3484@gmail.com>
@sebxt
sebxt requested a review from a team as a code owner October 18, 2026 01:09

This branch has not been deployed

No deployments
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.

Bedrock: anthropic_beta body field keeps whitespace and empty entries from the anthropic-beta header

1 participant