Skip to content

Litellm day 0 opus 4.7 support#25867

Merged
ishaan-berri merged 7 commits intolitellm_internal_stagingfrom
litellm_day_0_opus_4.7_support
Apr 16, 2026
Merged

Litellm day 0 opus 4.7 support#25867
ishaan-berri merged 7 commits intolitellm_internal_stagingfrom
litellm_day_0_opus_4.7_support

Conversation

@Sameerlite
Copy link
Copy Markdown
Collaborator

@Sameerlite Sameerlite commented Apr 16, 2026

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/test_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
  • I have requested a Greptile review by commenting @greptileai and received a Confidence Score of at least 4/5 before requesting a maintainer review

Delays in PR merge?

If you're seeing a delay in your PR being merged, ping the LiteLLM Team on Slack (#pr-review).

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:

Screenshots / Proof of Fix

Type

🆕 New Feature

Changes

  • Added support for Opus 4.7 across all providers
  • Tool search is not supported from bedrock
image

…on Messages API

Bedrock rejects clear_thinking_20251015 unless thinking is enabled or adaptive.
Inject minimal extended thinking and interleaved-thinking beta when Claude Code
sends context_management without thinking. Adds unit tests.

Made-with: Cursor
@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 16, 2026

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

Project Deployment Actions Updated (UTC)
litellm Ready Ready Preview, Comment Apr 16, 2026 4:29pm

Request Review

@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps Bot commented Apr 16, 2026

Greptile Summary

This PR adds day-0 support for Claude Opus 4.7 across Anthropic, Bedrock (Converse + Invoke/Messages), Vertex AI, and Azure AI providers, including new pricing/capability entries in the model map, adaptive thinking handling, and correctly excluding tool-search on Bedrock Invoke for this model.

  • effort='max' validation is hardcoded in _apply_output_config (self._is_opus_4_6_model(model) instead of self._supports_effort_level(model, \"max\")), directly contradicting the data-driven xhigh check right below it. The JSON schema already declares supports_max_reasoning_effort as a valid boolean field — adding it to the Opus 4.6 entries and using _supports_effort_level(model, \"max\") would make future model support a pure data change, consistent with the project's own rule.

Confidence Score: 4/5

Safe to merge after addressing the max effort validation inconsistency — no correctness bugs in the Opus 4.7 routing itself.

One P1 finding: effort='max' uses a hardcoded _is_opus_4_6_model() check while effort='xhigh' directly below uses the data-driven _supports_effort_level() pattern. The JSON schema already declares supports_max_reasoning_effort as a valid field, making the fix straightforward. All other changes (pricing entries, adaptive thinking routing, Bedrock tool-search exclusion, tests) look correct.

litellm/llms/anthropic/chat/transformation.py — _apply_output_config max effort guard

Important Files Changed

Filename Overview
litellm/llms/anthropic/chat/transformation.py Adds _is_opus_4_7_model() and _is_claude_4_7_model() helpers and wires them into reasoning-effort mapping and output_config routing; effort='max' guard remains hardcoded against Opus 4.6 instead of using the data-driven _supports_effort_level pattern already used for xhigh.
litellm/llms/anthropic/common_utils.py Adds _is_claude_4_7_model() and _is_adaptive_thinking_model() string-match helpers; wires Opus 4.7 into beta-header logic. Hardcoded pattern is consistent with the existing 4.6 approach; correctness looks sound.
litellm/llms/bedrock/messages/invoke_transformations/anthropic_claude3_transformation.py Correctly excludes Opus 4.7 from _supports_tool_search_on_bedrock with an explanatory comment; strips output_config for all Bedrock Invoke calls; extends extended-thinking model list to include Opus 4.7.
litellm/llms/bedrock/chat/converse_transformation.py Silently drops tool_search_tool_* tools for all Converse models; adds Opus 4.7 to the computer-use-2025-11-24 beta-header list. Changes look correct.
model_prices_and_context_window.json Adds Opus 4.7 entries for anthropic, bedrock (cross-region prefixes), vertex_ai, and azure_ai with correct pricing and capability flags; supports_xhigh_reasoning_effort: true is set. Missing supports_max_reasoning_effort (intentional — max is Opus 4.6-only).
tests/test_litellm/llms/bedrock/messages/invoke_transformations/test_anthropic_claude3_transformation.py Adds mock-only tests for output_config stripping, SSE usage promotion, and clear_thinking injection; all tests are unit-level with no real network calls. No new Opus 4.7-specific test for tool-search exclusion.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[User sends request with reasoning_effort or thinking] --> B{Model is Opus 4.7?}
    B -- Yes --> C[_map_reasoning_effort → type=adaptive]
    B -- No --> D[_map_reasoning_effort → type=enabled + budget_tokens]
    C --> E[Set output_config.effort via effort_map]
    E --> F{effort == max?}
    F -- Yes --> G[❌ ValueError: max is Opus 4.6 only]
    F -- No --> H{effort == xhigh?}
    H -- Yes --> I{_supports_effort_level via JSON?}
    I -- No --> J[❌ ValueError: xhigh not supported]
    I -- Yes --> K[Apply output_config to request]
    H -- No --> K
    K --> L{Provider?}
    L -- Anthropic Direct --> M[Send with output_config]
    L -- Bedrock Invoke --> N[Strip output_config step 5b]
    L -- Bedrock Converse --> O[Pass through normally]
    P[Tool search tools in request] --> Q{Provider?}
    Q -- Bedrock Converse --> R[Strip tool_search_tool_* for ALL models]
    Q -- Bedrock Invoke Opus 4.7 --> S[_supports_tool_search_on_bedrock → false]
    Q -- Bedrock Invoke Opus 4.5/4.6 --> T[Add tool-search-tool-2025-10-19 beta header]
Loading

Reviews (2): Last reviewed commit: "Remove max support for opus 4.7" | Re-trigger Greptile

Comment thread litellm/llms/anthropic/common_utils.py
Copy link
Copy Markdown
Contributor

@ishaan-berri ishaan-berri left a comment

Choose a reason for hiding this comment

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

LGTM

@ishaan-berri ishaan-berri merged commit 44c9924 into litellm_internal_staging Apr 16, 2026
91 of 98 checks passed
@ishaan-berri ishaan-berri deleted the litellm_day_0_opus_4.7_support branch April 16, 2026 16:42
Comment on lines +1537 to +1546
# ``max`` is Claude Opus 4.6 only (not Sonnet 4.6, not Opus 4.5/4.7).
# Keep this hardcoded so the error message is specific and stable.
if effort == "max" and not self._is_opus_4_6_model(model):
raise ValueError(
f"effort='max' is only supported by Claude Opus 4.6. Got model: {model}"
f"effort='max' is only supported by Claude Opus 4.6. "
f"Got model: {model}"
)
# ``xhigh`` is data-driven via ``supports_xhigh_reasoning_effort`` so
# enabling it for a new model is a pure model-map change.
if effort == "xhigh" and not self._supports_effort_level(model, "xhigh"):
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.

P1 max effort check is hardcoded while xhigh is data-driven

effort='max' is validated with a hardcoded _is_opus_4_6_model() string match, while effort='xhigh' directly below uses _supports_effort_level(model, "xhigh") — exactly the pattern the project rule requires. The JSON schema already declares supports_max_reasoning_effort as a valid boolean field (see test_utils.py line 774). Any future model that supports max will require a code change here rather than a simple model-map addition.

The fix is a two-line change:

  1. Add "supports_max_reasoning_effort": true to the claude-opus-4-6 (and its regional/versioned) JSON entries.
  2. Replace the hardcoded gate:
Suggested change
# ``max`` is Claude Opus 4.6 only (not Sonnet 4.6, not Opus 4.5/4.7).
# Keep this hardcoded so the error message is specific and stable.
if effort == "max" and not self._is_opus_4_6_model(model):
raise ValueError(
f"effort='max' is only supported by Claude Opus 4.6. Got model: {model}"
f"effort='max' is only supported by Claude Opus 4.6. "
f"Got model: {model}"
)
# ``xhigh`` is data-driven via ``supports_xhigh_reasoning_effort`` so
# enabling it for a new model is a pure model-map change.
if effort == "xhigh" and not self._supports_effort_level(model, "xhigh"):
if effort == "max" and not self._supports_effort_level(model, "max"):
raise ValueError(
f"effort='max' is not supported by this model. Got model: {model}"
)

Rule Used: What: Do not hardcode model-specific flags in the ... (source)

Sameerlite pushed a commit that referenced this pull request Apr 16, 2026
Sameerlite pushed a commit that referenced this pull request Apr 16, 2026
shang309073819 added a commit to shang309073819/litellm that referenced this pull request Apr 17, 2026
Anthropic's Messages API accepts `output_config.effort="max"` on
`claude-opus-4-7-*` models, but `_apply_output_config` hardcoded the
gate to `_is_opus_4_6_model`, so any request hitting LiteLLM with
Opus 4.7 + effort=max was rejected with a 400 before reaching Anthropic.

This was preserved on purpose in BerriAI#25867 (day-0 4.7 PR) under the old
assumption that `max` was Opus-4.6-only. The Anthropic API has since
extended `max` support to Opus 4.7.

Allow the effort=max guard to also accept Opus 4.7. Update the two
existing rejection tests to match the new error message and add a new
regression test for Opus 4.7.

Fixes BerriAI#25957
shang309073819 added a commit to shang309073819/litellm that referenced this pull request Apr 18, 2026
Anthropic's Messages API accepts `output_config.effort="max"` on
`claude-opus-4-7-*` models, but `_apply_output_config` hardcoded the
gate to `_is_opus_4_6_model`, so any request hitting LiteLLM with
Opus 4.7 + effort=max was rejected with a 400 before reaching Anthropic.

This was preserved on purpose in BerriAI#25867 (day-0 4.7 PR) under the old
assumption that `max` was Opus-4.6-only. The Anthropic API has since
extended `max` support to Opus 4.7.

Allow the effort=max guard to also accept Opus 4.7. Update the two
existing rejection tests to match the new error message and add a new
regression test for Opus 4.7.

Fixes BerriAI#25957
shang309073819 added a commit to shang309073819/litellm that referenced this pull request Apr 19, 2026
Anthropic's Messages API accepts `output_config.effort="max"` on
`claude-opus-4-7-*` models, but `_apply_output_config` hardcoded the
gate to `_is_opus_4_6_model`, so any request hitting LiteLLM with
Opus 4.7 + effort=max was rejected with a 400 before reaching Anthropic.

This was preserved on purpose in BerriAI#25867 (day-0 4.7 PR) under the old
assumption that `max` was Opus-4.6-only. The Anthropic API has since
extended `max` support to Opus 4.7.

Allow the effort=max guard to also accept Opus 4.7. Update the two
existing rejection tests to match the new error message and add a new
regression test for Opus 4.7.

Fixes BerriAI#25957
Sameerlite pushed a commit that referenced this pull request Apr 20, 2026
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.

2 participants