Closed
Conversation
…ClaudeMessagesConfig
…daptive thinking for Opus 4.6 models
The daily spend tables store dates in UTC, but the UI sends dates in the user's local timezone. This causes a mismatch where records from the user's evening (stored as the next UTC day) don't appear when filtering by "today". Changes: - Add `_adjust_dates_for_timezone()` helper to expand date range based on timezone offset - Add `timezone` query parameter to `/user/daily/activity` and `/user/daily/activity/aggregated` endpoints - Frontend sends `timezone` using `Date.getTimezoneOffset()` For users west of UTC (e.g., PST), end_date is extended by 1 day. For users east of UTC (e.g., IST), start_date is extended by 1 day earlier. This ensures all records within the user's local date range are captured.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile OverviewGreptile SummaryThis PR updates Anthropic/Claude parameter mapping to support Opus 4.6’s GA “adaptive thinking” API by:
New tests exercise the mapping logic, model detection, beta header behavior, and Bedrock Converse handling for Opus 4.6. Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/chat/transformation.py | Adds Opus 4.6 model detection and maps reasoning_effort / deprecated thinking(enabled) to adaptive thinking + output_config.effort; includes Opus 4.6 in native output_format allowlist. |
| litellm/llms/anthropic/common_utils.py | Updates beta-header feature detection; treats Opus 4.6 as not requiring the effort beta header by short-circuiting is_effort_used(model). |
| litellm/llms/base_llm/chat/transformation.py | Extends is_thinking_enabled to recognize thinking.type='adaptive' in addition to 'enabled'. |
| litellm/llms/bedrock/chat/converse_transformation.py | Bedrock Converse reasoning_effort mapping uses adaptive thinking for Opus 4.6 model strings; otherwise keeps prior enabled-thinking mapping. |
| litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py | Adds Opus 4.6 model patterns to Bedrock extended thinking supported_patterns list. |
| litellm/types/llms/anthropic.py | Extends AnthropicThinkingParam.type literal to include 'adaptive' and minor formatting tweaks/newline fix. |
| poetry.lock | Updates locked dependency versions (e.g., aiohttp 3.13.2→3.13.3). |
| tests/test_litellm/llms/anthropic/chat/test_anthropic_opus_4_6_adaptive_thinking.py | Adds unit tests for Opus 4.6 adaptive thinking/effort mapping and beta header behavior; modifies sys.path at runtime which may break test runner assumptions. |
Sequence Diagram
sequenceDiagram
participant Client
participant LiteLLM as LiteLLM (OpenAI params)
participant ATrans as AnthropicConfig.map_openai_params
participant Base as BaseConfig.is_thinking_enabled
participant Headers as AnthropicModelInfo.get_anthropic_headers
participant Bedrock as AmazonConverseConfig._handle_reasoning_effort_parameter
participant Anthropic as Anthropic API
Client->>LiteLLM: ChatCompletion(model=opus-4-6, reasoning_effort/thinking)
LiteLLM->>ATrans: map_openai_params(non_default_params, optional_params, model)
ATrans->>Base: is_thinking_enabled(non_default_params)
alt model is Opus 4.6 && reasoning_effort provided
ATrans-->>ATrans: set thinking={type:"adaptive"}
ATrans-->>ATrans: set output_config={effort: low|medium|high}
else model is Opus 4.6 && thinking.type=="enabled"
ATrans-->>ATrans: convert thinking to {type:"adaptive"}
ATrans-->>ATrans: optionally derive effort from budget_tokens
else other models
ATrans-->>ATrans: keep existing thinking mapping
end
LiteLLM->>Headers: get_anthropic_headers(optional_params, model)
alt model is Opus 4.6
Headers-->>Headers: is_effort_used() returns false (no effort beta header)
else effort used on other models
Headers-->>Headers: add anthropic-beta: effort-2025-11-24
end
LiteLLM->>Anthropic: POST /messages (thinking + output_config)
Anthropic-->>LiteLLM: Response
%% Bedrock path
Client->>LiteLLM: Bedrock Converse call (model contains opus-4-6)
LiteLLM->>Bedrock: _handle_reasoning_effort_parameter(model, reasoning_effort)
alt Opus 4.6
Bedrock-->>Bedrock: set thinking={type:"adaptive"}
else
Bedrock-->>Bedrock: set thinking via _map_reasoning_effort
end
…al import for Options Changes: - Updated the type hint for `decode_options` to use `Options` from `jwt.types`. - Added a conditional import for `Options` to improve type checking without runtime overhead.
Member
|
@Sameerlite do your PR's already address this? |
Collaborator
|
Covered all this here: #20551 |
6 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Relevant issues
Fixes #20519
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
Changes
Migrate Claude Opus 4.6 from the deprecated
thinking: {type: "enabled", budget_tokens: N}tothinking: {type: "adaptive"}+output_config: {effort: "high"|"medium"|"low"}. Theeffort-2025-11-24beta header is no longer needed for Opus 4.6 since effort is GA.Summary of changes
litellm/types/llms/anthropic.py—AnthropicThinkingParam.typenow accepts"adaptive"in addition to"enabled"litellm/llms/base_llm/chat/transformation.py—is_thinking_enabledrecognizestype: "adaptive"litellm/llms/anthropic/chat/transformation.py— Core logic:_is_claude_opus_4_6()model detection_get_adaptive_thinking_param()and_budget_tokens_to_effort()helpersmap_openai_params: for Opus 4.6,reasoning_effortmaps to adaptive thinking + effort; deprecatedthinking: {type: "enabled"}is auto-converted to adaptiveresponse_formatnativeoutput_formatmodel listlitellm/llms/anthropic/common_utils.py—is_effort_usedreturnsFalsefor Opus 4.6 (no beta header needed)litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py— Added Opus 4.6 to extended thinking support on Bedrocklitellm/llms/bedrock/chat/converse_transformation.py— Bedrock Converse uses adaptive thinking for Opus 4.6Test plan
Added 16 tests in
tests/test_litellm/llms/anthropic/chat/test_anthropic_opus_4_6_adaptive_thinking.py:reasoning_effort→ adaptive thinking + effort mapping (high, medium, low, minimal)thinking: {type: "enabled"}auto-conversion for Opus 4.6thinking: {type: "adaptive"}passthrough_budget_tokens_to_effortthreshold mappingis_thinking_enabledrecognizes adaptive typeLinting
https://github.com/BerriAI/litellm/actions/runs/21727820552/job/62674426851