This commit is contained in:
Koudo 2026-09-23 14:52:30 +00:00 • committed by GitHub
commit aa323d7d05
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 21 additions and 1 deletions

View file

@ -324,6 +324,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:
completion_kwargs: _CompletionKwargs,
*,
thinking: Mapping[str, object] | None,
use_chat_completions_url: bool = False,
) -> None:
"""
When users call `litellm.anthropic.messages.*` with a non-Anthropic model and
@ -346,7 +347,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:
except Exception:
custom_llm_provider = None
if custom_llm_provider != "openai":
if custom_llm_provider != "openai" or use_chat_completions_url:
return
if not isinstance(thinking, dict) or thinking.get("type") != "enabled":
@ -589,6 +590,7 @@ class LiteLLMMessagesToCompletionTransformationHandler:
LiteLLMMessagesToCompletionTransformationHandler._route_openai_thinking_to_responses_api_if_needed(
completion_kwargs,
thinking=thinking,
use_chat_completions_url=litellm.use_chat_completions_url_for_anthropic_messages,
)
plain_effort: Final = LiteLLMMessagesToCompletionTransformationHandler._plain_effort_for_chat_target(

View file

@ -421,6 +421,24 @@ class TestThinkingParameterTransformation:
class TestThinkingSummaryPreservation:
"""Tests for thinking.summary preservation and reasoning_auto_summary flag."""
def test_thinking_respects_chat_completions_url_override(self):
from litellm.llms.anthropic.experimental_pass_through.adapters.handler import (
LiteLLMMessagesToCompletionTransformationHandler,
)
completion_kwargs = {
"model": "openai/gpt-5.6",
"custom_llm_provider": "openai",
"reasoning_effort": "medium",
}
LiteLLMMessagesToCompletionTransformationHandler._route_openai_thinking_to_responses_api_if_needed(
completion_kwargs,
thinking={"type": "enabled", "budget_tokens": 5000},
use_chat_completions_url=True,
)
assert completion_kwargs["model"] == "openai/gpt-5.6"
def test_thinking_summary_concise_preserved_for_openai(self):
"""User-provided summary='concise' should not be replaced with 'detailed'."""
from litellm.llms.anthropic.experimental_pass_through.adapters.handler import (