Skip to content

fix(bedrock): drop unsupported Anthropic fields and beta flags#58

Open
warren830 wants to merge 2 commits into
aws-samples:mainfrom
warren830:main
Open

fix(bedrock): drop unsupported Anthropic fields and beta flags#58
warren830 wants to merge 2 commits into
aws-samples:mainfrom
warren830:main

Conversation

@warren830
Copy link
Copy Markdown

Problem

Bedrock recently started strictly validating request fields and beta header values, rejecting unknown ones with 400 invalid beta flag or 400 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_MODELS from 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-20250219
  • context-1m-2025-08-07
  • interleaved-thinking-2025-05-14
  • context-management-2025-06-27
  • effort-2025-11-24

3. Drop context_management and output_config request fields (bedrock_service.py)

Claude Code now sends context_management (compact context beta) and output_config (effort level) in the request body. Bedrock rejects these with 400 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 the 400 errors no longer appear after deploying this fix. Claude Code sessions connecting through the proxy work correctly.

warren830 added 2 commits May 17, 2026 10:21
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.
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.

1 participant