fix(anthropic): align translate_thinking_for_model with default summary injection + docs#22909
Merged
Chesars merged 1 commit intoBerriAI:litellm_oss_staging_03_05_2026from Mar 5, 2026
Conversation
…ry injection + add docs - Update translate_thinking_for_model (3rd code path) to inject summary="detailed" by default, consistent with the other two paths - Add disable_default_reasoning_summary flag check via shared helper - Add tests for flag enabled/disabled and user-provided summary - Document disable_default_reasoning_summary in reasoning_content.md
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile SummaryThis PR aligns
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py | Adds summary="detailed" default injection to translate_thinking_for_model when no user-provided summary is present and disable_default_reasoning_summary is not set. Logically correct and consistent with the other two code paths, but changes the existing default return shape from a plain string to an object. This is a backwards-incompatible change, opt-out rather than opt-in, which could silently affect downstream consumers that expected reasoning_effort to be a plain string. |
| tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py | Two new unit tests added (test_translate_thinking_for_model_no_summary_when_disabled and test_non_claude_model_converts_thinking_to_reasoning_effort) properly verify the disabled-flag path and the default injection behavior. Both are mock-only tests that correctly restore global state via try/finally. Existing test assertions properly updated to reflect the new default behavior of including summary="detailed". |
| docs/my-website/docs/reasoning_content.md | New "Default Summary Injection for /v1/messages Adapter" section clearly documents the opt-out flag with SDK, env var, and proxy config examples. Documentation explains how to disable the default injection and includes a note that user-provided summaries are always preserved regardless of the flag. Clear and accurate. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[translate_thinking_for_model] --> B{is_anthropic_claude_model?}
B -- Yes --> C[Return thinking param as-is]
B -- No --> D[translate_anthropic_thinking_to_reasoning_effort]
D --> E{reasoning_effort resolved?}
E -- No --> F[Return empty dict]
E -- Yes --> G{User provided summary<br/>in thinking dict?}
G -- Yes --> H["Return {effort, summary: user_value}"]
G -- No --> I{is_default_reasoning_summary_disabled?<br/>litellm flag OR env var}
I -- True --> J["Return {reasoning_effort: string}"]
I -- False --> K["Return {effort, summary: 'detailed'}"]
Last reviewed commit: 5b904f6
litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py
Show resolved
Hide resolved
5c418d8
into
BerriAI:litellm_oss_staging_03_05_2026
4 of 5 checks passed
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
Follow-up to #22904.
Pre-Submission checklist
tests/test_litellm/directory, Adding at least 1 test is a hard requirement - see detailsmake test-unitType
🐛 Bug Fix
📖 Documentation
Changes
translate_thinking_for_modelto useis_default_reasoning_summary_disabled()and injectsummary="detailed"by default (matching the other two code paths)./v1/messagesAdapter" inreasoning_content.mdcovering SDK, env var, and proxy config usage.