[Feat]Add new claude 4-6 feat for v1/messages - #20733
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Greptile OverviewGreptile SummaryThis PR extends LiteLLM’s Key changes:
The main correctness concern is in the Vertex AI context management detection: it can add the context-management beta header even when edits are empty/invalid (e.g., Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| docs/my-website/blog/claude_opus_4_6/index.md | Adds a new section documenting /v1/messages usage and feature matrix; contains a misleading compaction support statement for Bedrock Invoke. |
| litellm/llms/azure_ai/anthropic/messages_transformation.py | Filters Anthropic beta headers for Azure AI by calling the centralized header filtering helper after updating beta features. |
| litellm/llms/bedrock/chat/invoke_transformations/anthropic_claude3_transformation.py | Replaces inline Bedrock beta whitelist filtering with centralized filter_and_transform_beta_headers(provider='bedrock'). |
| litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/experimental_pass_through/transformation.py | Adds context-management/compaction beta header injection based on optional_params['context_management'].edits; current logic can add context-management header for empty/invalid edits. |
| litellm/model_prices_and_context_window_backup.json | Removes duplicate claude-opus-4-6-v1/regional pricing entries from backup pricing JSON (de-duplication). |
| model_prices_and_context_window.json | Removes duplicate claude-opus-4-6-v1/global/regional entries from pricing JSON (fixes duplicate keys that were previously present). |
| tests/test_litellm/llms/vertex_ai/vertex_ai_partner_models/anthropic/test_vertex_ai_partner_models_anthropic_messages_config.py | Adds tests asserting Vertex AI adds compact-2026-01-12 and/or context-management-2025-06-27 to anthropic-beta header when context_management.edits are present. |
Sequence Diagram
sequenceDiagram
participant Client
participant LiteLLM
participant AzureAI as Azure AI Anthropic Adapter
participant Bedrock as Bedrock Anthropic Adapter
participant Vertex as Vertex AI Anthropic Adapter
Client->>LiteLLM: POST /v1/messages (Claude 4.6 params)
alt Azure AI
LiteLLM->>AzureAI: messages_transformation.py
AzureAI-->>LiteLLM: provider-formatted payload
else Bedrock
LiteLLM->>Bedrock: anthropic_claude3_transformation.py
Bedrock-->>LiteLLM: provider-formatted payload
else Vertex AI Partner Model
LiteLLM->>Vertex: pass_through/transformation.py
Vertex-->>LiteLLM: provider-formatted payload
end
LiteLLM-->>Client: Anthropic-style response
| context_management_param = optional_params.get("context_management") | ||
| if context_management_param is not None: | ||
| # Check edits array for compact_20260112 type | ||
| edits = context_management_param.get("edits", []) |
There was a problem hiding this comment.
Context management header misfire
When context_management is present but edits is empty (or contains non-dict entries), this logic sets has_other=True for every non-compact_20260112 element (including {} / missing type), which will incorrectly add the context-management-2025-06-27 beta header even though no meaningful edits were requested. Consider only treating an edit as “other” when it’s a dict with a non-empty type (and not equal to compact_20260112).
| { | ||
| "role": "user", | ||
| "content": "Explain why the sum of two even numbers is always even." | ||
| } |
There was a problem hiding this comment.
Incorrect provider support claim
This section states: Compaction is supported on Anthropic, Bedrock Invoke Azure AI, and Vertex AI. but /v1/messages compaction is typically not supported on Bedrock Invoke (it requires anthropic_beta support for the compact feature, which Bedrock Invoke filters/whitelists). Given the code in litellm/llms/bedrock/.../anthropic_claude3_transformation.py explicitly filters provider betas, this doc line is misleading and should be corrected (and also add the missing comma: “Bedrock Invoke, Azure AI”).
…ions/test_bedrock_chat_invoke_transformations_anthropic_claude3_transformation.py
[Feat]Add new claude 4-6 feat for v1/messages
[Feat]Add new claude 4-6 feat for v1/messages
[Feat]Add new claude 4-6 feat for v1/messages
…ude_4_6 [Feat]Add new claude 4-6 feat for v1/messages
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
Changes