This commit is contained in:
Lucas Kim 2026-11-05 20:11:45 +00:00 • committed by GitHub
commit 2db95efdbf
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 29 additions and 1 deletions

View file

@ -211,7 +211,7 @@ from litellm.types.llms.openai import (
ToolMessageContentPart,
)
from litellm.types.utils import Choices, LlmProviders, ModelResponse, StreamingChoices, Usage
from litellm.utils import supports_mid_conversation_system
from litellm.utils import is_explicitly_disabled_factory, supports_mid_conversation_system
from .streaming_iterator import AnthropicSSEStream, AnthropicStreamWrapper
@ -1227,6 +1227,10 @@ class LiteLLMAnthropicMessagesAdapter:
)
if not reasoning_effort:
return
if reasoning_effort == "none" and is_explicitly_disabled_factory(
model=model, custom_llm_provider=custom_llm_provider, key="supports_none_reasoning_effort"
):
return
new_kwargs["reasoning_effort"] = (
reasoning_effort

View file

@ -2432,6 +2432,30 @@ def test_thinking_disabled_stays_plain_string_when_auto_summary_enabled():
assert new_kwargs["reasoning_effort"] == "none"
@pytest.mark.parametrize(
("model", "custom_llm_provider", "expected_effort"),
[
pytest.param("us.openai.gpt-6-astra", "bedrock", None, id="bedrock-gpt-6-astra"),
pytest.param("global.openai.gpt-6-astra", "bedrock", None, id="bedrock-gpt-6-astra-global"),
pytest.param("openai.gpt-6-astra", "bedrock_mantle", None, id="mantle-gpt-6-astra"),
pytest.param("us.openai.gpt-6-sol", "bedrock", "none", id="bedrock-gpt-6-sol"),
pytest.param("converse/global.openai.gpt-6-luna", "bedrock", "none", id="bedrock-converse-gpt-6-luna"),
pytest.param("openai.gpt-6-sol", "bedrock_mantle", "none", id="mantle-gpt-6-sol"),
pytest.param("converse/us.openai.gpt-5.6-sol", "bedrock", "none", id="bedrock-gpt-5.6-sol-without-flag"),
],
)
def test_thinking_disabled_sends_effort_none_only_to_targets_that_take_it(
model: str, custom_llm_provider: str, expected_effort: str | None, local_model_cost_map: None
) -> None:
new_kwargs: Final[dict[str, object]] = {"model": model}
LiteLLMAnthropicMessagesAdapter()._translate_thinking_to_openai(
cast(Any, {"thinking": {"type": "disabled"}}), cast(Any, new_kwargs), custom_llm_provider=custom_llm_provider
)
assert "thinking" not in new_kwargs
assert new_kwargs.get("reasoning_effort") == expected_effort
@pytest.mark.parametrize(
"model",
[