The fastest, litest AI Gateway. Rust core with Python SDK. Call 100+ LLM APIs in OpenAI (or native) format with cost tracking, guardrails, load balancing, and logging [Bedrock, Azure, OpenAI, Anthropic, OpenAI, VertexAI, vLLM, Nvidia NIM]
Python ai-gatewayanthropicazure-openaibedrockgatewaylangchainlitellmllmllm-gatewayllmopsmcp-gatewayopenaiopenai-proxyrustrust-aivertex-ai
fix(anthropic-adapter): keep disabled-thinking reasoning_effort a plain string
Tin Chi Lo9da21f38a92d
diff --git a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.pyindex edcb474b01f..3d4233e719a 100644--- a/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py+++ b/litellm/llms/anthropic/experimental_pass_through/adapters/transformation.py@@ -989,12 +989,18 @@ class LiteLLMAnthropicMessagesAdapter:if not reasoning_effort:return+ thinking_type = thinking.get("type") if isinstance(thinking, dict) else None+# For adaptive thinking, override with output_config.effort if available- if isinstance(thinking, dict) and thinking.get("type") == "adaptive":+ if thinking_type == "adaptive":output_config = anthropic_message_request.get("output_config")if isinstance(output_config, dict) and output_config.get("effort"):reasoning_effort = output_config["effort"]+ if thinking_type == "disabled":+ new_kwargs["reasoning_effort"] = reasoning_effort+ return+summary = thinking.get("summary") if isinstance(thinking, dict) else Noneauto_summary = is_reasoning_auto_summary_enabled()if summary:diff --git a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.pyindex f8984e6f4e6..326c8858551 100644--- a/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py+++ b/tests/test_litellm/llms/anthropic/experimental_pass_through/adapters/test_anthropic_experimental_pass_through_adapters_transformation.py@@ -1593,6 +1593,23 @@ def test_thinking_disabled_translated_to_reasoning_effort_none_for_non_claude_moassert new_kwargs["reasoning_effort"] == "none"+def test_thinking_disabled_stays_plain_string_when_auto_summary_enabled():+ import litellm++ adapter = LiteLLMAnthropicMessagesAdapter()+ thinking = {"type": "disabled"}++ original = litellm.reasoning_auto_summary+ try:+ litellm.reasoning_auto_summary = True+ new_kwargs = {"model": CACHE_CONTROL_NON_ANTHROPIC_MODEL}+ adapter._translate_thinking_to_openai(cast(Any, {"thinking": thinking}), cast(Any, new_kwargs))+ finally:+ litellm.reasoning_auto_summary = original++ assert new_kwargs["reasoning_effort"] == "none"++def test_stop_sequences_translated_to_stop_for_non_claude_model():from litellm.types.llms.anthropic import AnthropicMessagesRequest