fix(bedrock): drop unsupported Anthropic fields and beta flags#58
Open
warren830 wants to merge 2 commits into
Open
fix(bedrock): drop unsupported Anthropic fields and beta flags#58warren830 wants to merge 2 commits into
warren830 wants to merge 2 commits into
Conversation
Bedrock now strictly validates beta header values and returns 400 for unrecognized flags. Previously, the proxy passed unknown beta values through verbatim. This caused breakage when Claude Code clients automatically send Anthropic-specific headers (interleaved-thinking-2025-05-14, context-1m-2025-08-07, etc.) that Bedrock does not support. Changes: - Drop unknown beta flags in both converters instead of passing through - Add Claude Code client headers to the default blocklist: claude-code-20250219, context-1m-2025-08-07, interleaved-thinking-2025-05-14, context-management-2025-06-27, effort-2025-11-24
…orted by Bedrock These are Anthropic-specific fields (compact-2026-01-12 beta and effort level) that Claude Code clients now send but Bedrock rejects with 400 Extra inputs.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Bedrock recently started strictly validating request fields and beta header values, rejecting unknown ones with
400 invalid beta flagor400 Extra inputs are not permitted. This broke Claude Code clients which automatically inject several Anthropic-specific headers and fields that Bedrock doesn't support.Root cause: A prior refactor (ae0d395) changed
BETA_HEADER_SUPPORTED_MODELSfrom an exact model ID list to a keyword substring match (claude). This widened the matching scope, causing previously-ignored beta flags to now be forwarded to Bedrock.Changes
1. Drop unknown beta flags instead of passthrough (
anthropic_to_bedrock.py,bedrock_service.py)Previously, any beta flag not in the blocklist or mapping was forwarded to Bedrock verbatim. Bedrock now rejects unrecognized values. Changed to drop unknown flags with a warning log.
2. Extend beta headers blocklist (
config.py)Added Claude Code client headers that Bedrock doesn't support:
claude-code-20250219context-1m-2025-08-07interleaved-thinking-2025-05-14context-management-2025-06-27effort-2025-11-243. Drop
context_managementandoutput_configrequest fields (bedrock_service.py)Claude Code now sends
context_management(compact context beta) andoutput_config(effort level) in the request body. Bedrock rejects these with400 Extra inputs are not permitted. Both fields are now dropped before forwarding to Bedrock's native InvokeModel API.Testing
Verified via CloudWatch logs (
/ecs/anthropic-proxy-prod) that the400errors no longer appear after deploying this fix. Claude Code sessions connecting through the proxy work correctly.