Skip to content

Migrate to Opus 4.6#20518

Closed
12458 wants to merge 15 commits intoBerriAI:mainfrom
12458:12458/migrate-opus-4-6
Closed

Migrate to Opus 4.6#20518
12458 wants to merge 15 commits intoBerriAI:mainfrom
12458:12458/migrate-opus-4-6

Conversation

@12458
Copy link

@12458 12458 commented Feb 5, 2026

Relevant issues

Fixes #20519

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

Changes

Migrate Claude Opus 4.6 from the deprecated thinking: {type: "enabled", budget_tokens: N} to thinking: {type: "adaptive"} + output_config: {effort: "high"|"medium"|"low"}. The effort-2025-11-24 beta header is no longer needed for Opus 4.6 since effort is GA.

Summary of changes

  • litellm/types/llms/anthropic.pyAnthropicThinkingParam.type now accepts "adaptive" in addition to "enabled"
  • litellm/llms/base_llm/chat/transformation.pyis_thinking_enabled recognizes type: "adaptive"
  • litellm/llms/anthropic/chat/transformation.py — Core logic:
    • Added _is_claude_opus_4_6() model detection
    • Added _get_adaptive_thinking_param() and _budget_tokens_to_effort() helpers
    • map_openai_params: for Opus 4.6, reasoning_effort maps to adaptive thinking + effort; deprecated thinking: {type: "enabled"} is auto-converted to adaptive
    • Added Opus 4.6 to the response_format native output_format model list
  • litellm/llms/anthropic/common_utils.pyis_effort_used returns False for 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 Bedrock
  • litellm/llms/bedrock/chat/converse_transformation.py — Bedrock Converse uses adaptive thinking for Opus 4.6

Test 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)
  • Deprecated thinking: {type: "enabled"} auto-conversion for Opus 4.6
  • thinking: {type: "adaptive"} passthrough
  • _budget_tokens_to_effort threshold mapping
  • Opus 4.5 behavior unchanged
  • Beta header not set for Opus 4.6, still set for Opus 4.5
  • is_thinking_enabled recognizes adaptive type
  • No auto max_tokens adjustment for adaptive (no budget_tokens)
  • Opus 4.6 response_format uses native output_format
  • Model name detection for various formats
  • Bedrock Converse adaptive thinking for Opus 4.6

Linting

https://github.com/BerriAI/litellm/actions/runs/21727820552/job/62674426851

12458 and others added 13 commits February 5, 2026 12:17
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.
@vercel
Copy link

vercel bot commented Feb 5, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Feb 5, 2026 8:46pm

Request Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Feb 5, 2026

Greptile Overview

Greptile Summary

This PR updates Anthropic/Claude parameter mapping to support Opus 4.6’s GA “adaptive thinking” API by:

  • Detecting Opus 4.6 model name variants and mapping reasoning_effort to thinking: {type: "adaptive"} plus output_config: {effort: ...}.
  • Auto-converting deprecated thinking: {type: "enabled", budget_tokens: N} to adaptive thinking for Opus 4.6 (deriving effort from budget_tokens when present).
  • Ensuring is_thinking_enabled treats thinking.type="adaptive" as reasoning-enabled.
  • Skipping the effort beta header for Opus 4.6 (effort treated as GA) while keeping Opus 4.5 behavior unchanged.
  • Extending Bedrock transformations to recognize Opus 4.6 for extended/adaptive thinking.

New tests exercise the mapping logic, model detection, beta header behavior, and Bedrock Converse handling for Opus 4.6.

Confidence Score: 4/5

  • This PR looks safe to merge with low functional risk given the targeted parameter mapping changes and added test coverage.
  • Changes are mostly additive and gated on Opus 4.6 model detection; existing Opus 4.5 and non-Opus paths appear preserved. I couldn’t execute the test suite in this environment (no python/pytest available), so confidence is not 5/5.
  • tests/test_litellm/llms/anthropic/chat/test_anthropic_opus_4_6_adaptive_thinking.py (test runner assumptions); litellm/llms/anthropic/chat/transformation.py (Opus 4.6 detection + mapping logic)

Important Files Changed

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
Loading

Copy link
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, no comments

Edit Code Review Agent Settings | Greptile

12458 added 2 commits February 5, 2026 12:43
…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.
@krrishdholakia
Copy link
Member

@Sameerlite do your PR's already address this?

@Sameerlite
Copy link
Collaborator

Covered all this here: #20551
Closing this

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.

[Feature]: Migrate Claude Opus 4.6 to use adaptive thinking

5 participants