Add unsupported claude code beta headers in json#20578
Add unsupported claude code beta headers in json#20578Sameerlite merged 5 commits intolitellm_opus_4.6_thinkingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile OverviewGreptile Summary
Confidence Score: 2/5
|
| 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
| # 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: |
There was a problem hiding this comment.
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.
Additional Comments (2)
In |
Add unsupported claude code beta headers in json
Relevant issues
Pre-Submission checklist
Please complete all items before asking a LiteLLM maintainer to review your PR
tests/litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitCI (LiteLLM team)
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