fix(anthropic): route thinking requests through OpenAI responses - #20755
Merged
2 commits merged intoFeb 10, 2026
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
Greptile OverviewGreptile SummaryThis PR fixes an issue where OpenAI "thinking" requests routed via Anthropic adapter hit Chat Completions and only returned token counts instead of actual reasoning content. The fix routes these requests through OpenAI's Responses API by prepending Key Changes:
Confidence Score: 4/5
|
| Filename | Overview |
|---|---|
| litellm/llms/anthropic/experimental_pass_through/adapters/handler.py | Adds _route_openai_thinking_to_responses_api_if_needed method to route OpenAI thinking requests through Responses API and ensure reasoning summary is included |
| tests/test_litellm/llms/anthropic/experimental_pass_through/messages/test_anthropic_experimental_pass_through_messages_handler.py | Updates test assertions to verify the new routing behavior with responses/ prefix and summary: "detailed" in reasoning_effort |
Sequence Diagram
sequenceDiagram
participant User
participant AnthropicAdapter
participant Handler as LiteLLMMessagesToCompletionTransformationHandler
participant RouteLogic as _route_openai_thinking_to_responses_api_if_needed
participant LiteLLM as litellm.completion
participant OpenAI as OpenAI Responses API
User->>AnthropicAdapter: messages.create(model="openai/gpt-5.2", thinking={"type": "enabled"})
AnthropicAdapter->>Handler: anthropic_messages_handler()
Handler->>Handler: _prepare_completion_kwargs()
Note over Handler: Translates Anthropic format to OpenAI format<br/>Converts thinking to reasoning_effort
Handler->>RouteLogic: _route_openai_thinking_to_responses_api_if_needed()
alt is OpenAI model with thinking enabled
RouteLogic->>RouteLogic: Check custom_llm_provider == "openai"
RouteLogic->>RouteLogic: Check thinking.type == "enabled"
RouteLogic->>RouteLogic: Prepend "responses/" to model
Note over RouteLogic: model: "gpt-5.2" → "responses/gpt-5.2"
RouteLogic->>RouteLogic: Add summary: "detailed" to reasoning_effort
Note over RouteLogic: reasoning_effort: "minimal" →<br/>{"effort": "minimal", "summary": "detailed"}
end
Handler->>LiteLLM: completion(model="responses/gpt-5.2", reasoning_effort={...})
LiteLLM->>OpenAI: POST to Responses API
OpenAI-->>LiteLLM: Response with reasoning content block
LiteLLM-->>Handler: ModelResponse
Handler->>Handler: translate_completion_output_params()
Handler-->>AnthropicAdapter: AnthropicMessagesResponse
AnthropicAdapter-->>User: Response with thinking content
Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
ghost
merged commit Feb 10, 2026
d2ee4a7
into
BerriAI:litellm_oss_staging_02_09_2026
4 of 8 checks passed
Sameerlite
reviewed
Feb 10, 2026
| model = completion_kwargs.get("model") | ||
| if isinstance(model, str) and model and not model.startswith("responses/"): | ||
|
|
||
| reasoning_effort = completion_kwargs.get("reasoning_effort") |
Contributor
There was a problem hiding this comment.
THis is an indentation error. Please be careful as this broke the whole pipeline
Contributor
Author
There was a problem hiding this comment.
Sure will double cheak do I need to make changes and commit ?? I see the pr is merged
Sameerlite
pushed a commit
that referenced
this pull request
Feb 10, 2026
) * fix(anthropic): route thinking requests through OpenAI responses * Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
fzowl
pushed a commit
to fzowl/litellm
that referenced
this pull request
Jun 24, 2026
…riAI#20755) * fix(anthropic): route thinking requests through OpenAI responses * Apply suggestion from @greptile-apps[bot] Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> --------- Co-authored-by: Krish Dholakia <krrishdholakia@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com>
This pull request was closed.
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 #20433 (OpenAI “thinking” requests routed via Anthropic adapter previously hit Chat Completions and returned only token counts).
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
🐛 Bug Fix
Changes
1.)LiteLLMMessagesToCompletionTransformationHandler._route_openai_thinking_to_responses_api_if_needed in handler.py it now inspects the completion kwargs (inferring custom_llm_provider from the model when missing), rewrites OpenAI targets to responses/, and ensures reasoning_effort includes summary: "detailed" whenever thinking={"type":"enabled"} so the request heads through the Responses API and returns a reasoning “thinking” block instead of just token counts.
2.) Updated the Anthropic handler tests test_anthropic_experimental_pass_through_messages_handler.py to assert the new routing behavior.