Bedrock gateway mode: 'invalid beta flag' / tools.N.custom.defer_loading 400s from Claude Desktop (also affects first-party gateway, not just proxies)
Summary
Claude Desktop / Claude Code (v2.1.220) sends anthropic-beta header values and tool-schema fields (e.g. defer_loading for deferred/lazy tool loading) that AWS Bedrock rejects outright with a 400, even when talking through the official claude gateway mode (not a third-party proxy). This matches the pattern already reported in #49490 and #30926, but confirms it also affects the first-party Bedrock gateway path, not just third-party proxies like LiteLLM.
Environment
- Client: Claude Desktop, "custom third-party inference" mode (
inferenceProvider: gateway), backed by AWS Bedrock via application inference profiles - Gateway: official
claude gatewaybinary, pinned to v2.1.220 (also reproduced on v2.1.215) - Models:
claude-sonnet-4-6andclaude-haiku-4-5via Bedrock application inference profiles, us-east-1 - Auth: OIDC/Okta via the gateway's own auth server (not API-key based)
Errors observed (from gateway logs, forwarded verbatim from Bedrock)
400 invalid beta flag
400 tools.11.custom.defer_loading: Extra inputs are not permitted
Both errors are intermittent — some requests to the same models/session succeed (200), others fail, depending on which tools/beta features get included in that particular turn.
What we tried (none resolved it)
- Bumping the gateway's pinned Claude CLI version (2.1.215 → 2.1.220) — no change.
ENABLE_TOOL_SEARCH=false(vialaunchctl setenvon macOS, full app relaunch) — no change.CLAUDE_CODE_DISABLE_EXPERIMENTAL_BETAS=1(same method) — no change; matches reports in #30926 that this flag doesn't reliably strip all beta headers.- Confirmed via AWS Bedrock model-invocation logging that Bedrock returns
ValidationExceptionfor these requests, but Bedrock's own logging does not capture the specific invalid field/header for validation-layer rejections, so we can't get more detail from the AWS side either.
Repro conditions
Occurs when a user has a moderate-to-large number of registered MCP tools/connectors (20+, mix of claude.ai-managed connectors and one user-scope custom MCP server added via claude mcp add --scope user). Requests with fewer active tools appear less likely to trigger it, suggesting a tool-count or tool-schema-size threshold interacts with whichever beta feature is being negotiated.
Ask
Could the Bedrock-target request path in claude gateway (and Claude Desktop/Code generally) strip beta headers and tool-schema fields that Bedrock doesn't yet support, the same way the LiteLLM incident fix did (anthropic_beta_headers per-provider mapping)? Happy to provide more repro detail if useful.