Skip to content

Add unsupported claude code beta headers in json#20578

Merged
Sameerlite merged 5 commits intolitellm_opus_4.6_thinkingfrom
litellm_claude_code_beta_headers
Feb 6, 2026
Merged

Add unsupported claude code beta headers in json#20578
Sameerlite merged 5 commits intolitellm_opus_4.6_thinkingfrom
litellm_claude_code_beta_headers

Conversation

@Sameerlite
Copy link
Copy Markdown
Contributor

Relevant issues

Pre-Submission checklist

Please complete all items before asking a LiteLLM maintainer to review your PR

  • I have Added testing in the tests/litellm/ directory, Adding at least 1 test is a hard requirement - see details
  • My PR passes all unit tests on make test-unit
  • My PR's scope is as isolated as possible, it only solves 1 specific problem

CI (LiteLLM team)

CI status guideline:

  • 50-55 passing tests: main is stable with minor issues.
  • 45-49 passing tests: acceptable but needs attention
  • <= 40 passing tests: unstable; be careful with your merges and assess the risk.
  • Branch creation CI run
    Link:

  • CI run for the last commit
    Link:

  • Merge / cherry-pick CI run
    Links:

Type

🆕 New Feature
🐛 Bug Fix
🧹 Refactoring
📖 Documentation
🚄 Infrastructure
✅ Test

Changes

@vercel
Copy link
Copy Markdown

vercel bot commented Feb 6, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 6, 2026 1:06pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 6, 2026

Greptile Overview

Greptile Summary

  • Adds a centralized anthropic_beta_headers_manager + JSON config to drop unsupported anthropic-beta values per provider.
  • Wires the filter into Anthropic, Azure AI, Vertex AI, Bedrock Invoke, and Bedrock Converse transformation paths.
  • Replaces prior provider-specific filtering logic (Bedrock/Vertex) with the centralized config-driven approach.
  • Adds unit tests covering basic filtering/support checks and header update behavior.

Confidence Score: 2/5

  • This PR should not be merged until the Bedrock runtime regression and Opus 4.6 structured-outputs handling are fixed.
  • Centralizing beta header filtering is a reasonable refactor and tests cover the manager basics, but the Bedrock Converse change can raise UnboundLocalError at runtime and the Bedrock Invoke exception for Opus 4.6 structured-outputs is currently ineffective; both directly impact request correctness.
  • litellm/llms/bedrock/chat/converse_transformation.py; litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py; litellm/anthropic_beta_headers_config.json

Important Files Changed

Filename Overview
litellm/anthropic_beta_headers_config.json Adds JSON config listing provider-specific unsupported Anthropic beta headers; contains a duplicate entry in the bedrock list.
litellm/anthropic_beta_headers_manager.py Introduces a centralized loader/filter to drop unsupported values from the anthropic-beta header based on a JSON config; uses module-level caching.
litellm/llms/anthropic/experimental_pass_through/messages/transformation.py Calls centralized header filter in Anthropic messages environment validation.
litellm/llms/azure_ai/anthropic/transformation.py Filters anthropic-beta header for Azure AI requests via centralized manager.
litellm/llms/bedrock/chat/converse_transformation.py Replaces inline bedrock converse beta filtering with centralized filter and adds model-based computer-use header; introduces UnboundLocalError risk around computer_use_tools usage.
litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py Switches bedrock invoke beta filtering to centralized config and adds structured-outputs exception; current re-add logic is ineffective so Opus 4.6 won’t restore structured-outputs.
litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py Removes bespoke Vertex unsupported-beta removal and uses centralized filter; behavior depends on JSON config.
tests/test_litellm/test_anthropic_beta_headers_manager.py Adds unit tests for new header manager; tests don’t cover bedrock structured-outputs Opus 4.6 exception or converse computer_use_tools regression.

Sequence Diagram

sequenceDiagram
    participant Caller as LiteLLM caller
    participant ProviderCfg as Provider transform
    participant BetaMgr as anthropic_beta_headers_manager
    participant JSON as anthropic_beta_headers_config.json
    participant Upstream as Provider API

    Caller->>ProviderCfg: create request (headers/optional_params)

    alt Anthropic / Azure AI / Vertex AI
        ProviderCfg->>BetaMgr: update_headers_with_filtered_beta(headers, provider)
        BetaMgr->>BetaMgr: parse 'anthropic-beta' header (comma split)
        BetaMgr->>JSON: load unsupported list (cached)
        BetaMgr-->>ProviderCfg: headers updated (drop unsupported / delete if empty)
        ProviderCfg->>Upstream: send request
    else Bedrock Converse
        ProviderCfg->>BetaMgr: filter_and_transform_beta_headers(beta_headers, bedrock_converse)
        BetaMgr->>JSON: load unsupported list (cached)
        BetaMgr-->>ProviderCfg: filtered list
        ProviderCfg->>Upstream: send request with additional_request_params.anthropic_beta
    else Bedrock Invoke
        ProviderCfg->>ProviderCfg: map advanced-tool-use -> tool-search-tool (+tool-examples)
        ProviderCfg->>BetaMgr: filter_and_transform_beta_headers(beta_headers, bedrock)
        BetaMgr->>JSON: load unsupported list (cached)
        BetaMgr-->>ProviderCfg: filtered list
        ProviderCfg->>Upstream: send request
    end

Loading

Copy link
Copy Markdown
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

8 files reviewed, 3 comments

Edit Code Review Agent Settings | Greptile

Comment on lines +1099 to +1106
# Determine the correct computer-use beta header based on model
# "computer-use-2025-11-24" for Claude Opus 4.6, Claude Opus 4.5
# "computer-use-2025-01-24" for Claude Sonnet 4.5, Haiku 4.5, Opus 4.1, Sonnet 4, Opus 4, and Sonnet 3.7
# "computer-use-2024-10-22" for older models
model_lower = model.lower()
if "opus-4.6" in model_lower or "opus_4.6" in model_lower or "opus-4-6" in model_lower or "opus_4_6" in model_lower:
computer_use_header = "computer-use-2025-11-24"
elif "opus-4.5" in model_lower or "opus_4.5" in model_lower or "opus-4-5" in model_lower or "opus_4_5" in model_lower:
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Incorrect tool-use gating

anthropic_beta_list.append(computer_use_header) is inside if computer_use_tools:, but computer_use_tools is only defined in the if filtered_tools and self.is_computer_use_tool_used(...) branch. In the else-branch (no computer use tools), computer_use_tools is undefined, which can raise UnboundLocalError at runtime depending on control flow. Consider checking if filtered_tools and self.is_computer_use_tool_used(...): (or guarding with a local computer_use_tools = [] default) before referencing it.

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Feb 6, 2026

Additional Comments (2)

litellm/anthropic_beta_headers_config.json
Duplicate unsupported header

"code-execution-2025-08-25" appears twice in the bedrock unsupported list. This will cause inconsistent expectations (e.g., in tests that compare lengths) and makes the config harder to reason about. Please remove the duplicate entry so the JSON remains a clean source of truth.


litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py
Structured-outputs never re-added

In _filter_unsupported_beta_headers_for_bedrock, the re-add logic checks if is_opus_4_6 and "structured-outputs-2025-11-13" in beta_list:, but beta_list is built after filtering has already removed structured-outputs (since it’s in the provider unsupported list). This condition will therefore always be false, so Opus 4.6 will never get structured-outputs-2025-11-13 even if the user requested it. Preserve the pre-filter set/list (or check the original beta_set before filtering) for the re-add decision.

@Sameerlite Sameerlite merged commit eab7a99 into litellm_opus_4.6_thinking Feb 6, 2026
46 of 57 checks passed
@Sameerlite Sameerlite deleted the litellm_claude_code_beta_headers branch February 6, 2026 13:40
Sameerlite added a commit that referenced this pull request Feb 11, 2026
Add unsupported claude code beta headers in json
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