Skip to content

bug: Anthropic-Beta header forwarded to Bedrock causes invalid beta flag errors #221

@blinkagent

Description

@blinkagent

Summary

When routing requests through Bedrock, AI Bridge forwards the Anthropic-Beta header from the client unchanged. Claude Code sends beta flags like adaptive-thinking-2026-01-28 that are not recognized by all Bedrock regions/models (particularly GovCloud us-gov-west-1), causing 400 errors:

API Error: 400 {"error":{"message":"POST \"https://bedrock-runtime.us-gov-west-1.amazonaws.com/v1/messages\": 400 Bad Request {\"message\":\"invalid beta flag\"}","type":"api_error"},"request_id":"","type":"error"}

Root Cause

The Anthropic-Beta header is listed in anthropicForwardHeaders in provider/anthropic.go and forwarded via BuildUpstreamHeaders() in intercept/client_headers.go. This works fine for the direct Anthropic API, but Bedrock has its own feature gating and does not accept all Anthropic beta flags.

Claude Code sends beta values like:

claude-code-20250219,adaptive-thinking-2026-01-28,context-management-2025-06-27,prompt-caching-scope-2026-01-05,effort-2025-11-24

Some of these flags are not supported on older Bedrock regions/models.

Expected Behavior

When routing through Bedrock, the Anthropic-Beta header should either be:

  • Stripped entirely (the Bedrock SDK/API handles feature gating differently), or
  • Filtered to only include flags known to be supported by Bedrock

Impact

This blocks usage of Claude Code through AI Bridge with Bedrock in GovCloud regions. The CLAUDE_CODE_DISABLE_ADAPTIVE_THINKING=1 workaround for AIGOV-103 does not help because it only changes the request body — Claude Code still sends the unsupported beta header.

Prior Art

LiteLLM encountered the same issue and solved it by maintaining a provider-specific beta header allowlist: https://docs.litellm.ai/blog/claude-code-beta-headers-incident

References


Created on behalf of @uzair-coder07

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions