From d0b05b16df3d1ef7cc3e762d8f807394f10a5cbf Mon Sep 17 00:00:00 2001 From: Yiyang Liu <37043548+ianliuy@users.noreply.github.com> Date: Thu, 16 Apr 2026 14:14:21 -0700 Subject: [PATCH] fix: guard against None thinking param for reasoning_effort=none (fixes #25792) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: Yiyang Liu <37043548+ianliuy@users.noreply.github.com> --- litellm/llms/anthropic/chat/transformation.py | 4 +++- litellm/llms/bedrock/chat/converse_transformation.py | 4 +++- litellm/llms/databricks/chat/transformation.py | 4 +++- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/litellm/llms/anthropic/chat/transformation.py b/litellm/llms/anthropic/chat/transformation.py index 6e6078728eb..77bddee9a36 100644 --- a/litellm/llms/anthropic/chat/transformation.py +++ b/litellm/llms/anthropic/chat/transformation.py @@ -1088,9 +1088,11 @@ class AnthropicConfig(AnthropicModelInfo, BaseConfig): elif param == "thinking": optional_params["thinking"] = value elif param == "reasoning_effort" and isinstance(value, str): - optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( + thinking = AnthropicConfig._map_reasoning_effort( reasoning_effort=value, model=model ) + if thinking is not None: + optional_params["thinking"] = thinking # For Claude 4.6+ models, effort is controlled via output_config, # not thinking budget_tokens. Map reasoning_effort to output_config. if AnthropicConfig._is_claude_4_6_model( diff --git a/litellm/llms/bedrock/chat/converse_transformation.py b/litellm/llms/bedrock/chat/converse_transformation.py index 5d98e1538bd..76a85309fe8 100644 --- a/litellm/llms/bedrock/chat/converse_transformation.py +++ b/litellm/llms/bedrock/chat/converse_transformation.py @@ -449,9 +449,11 @@ class AmazonConverseConfig(BaseConfig): optional_params.update(reasoning_config) else: # Anthropic and other models: convert to thinking parameter - optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( + thinking = AnthropicConfig._map_reasoning_effort( reasoning_effort=reasoning_effort, model=model ) + if thinking is not None: + optional_params["thinking"] = thinking @staticmethod def _clamp_thinking_budget_tokens(optional_params: dict) -> None: diff --git a/litellm/llms/databricks/chat/transformation.py b/litellm/llms/databricks/chat/transformation.py index 91d6129c3fe..772efe46527 100644 --- a/litellm/llms/databricks/chat/transformation.py +++ b/litellm/llms/databricks/chat/transformation.py @@ -330,9 +330,11 @@ class DatabricksConfig(DatabricksBase, OpenAILikeChatConfig, AnthropicConfig): ) # unsupported for claude models - if json_schema -> convert to tool call if "reasoning_effort" in non_default_params and "claude" in model: - optional_params["thinking"] = AnthropicConfig._map_reasoning_effort( + thinking = AnthropicConfig._map_reasoning_effort( reasoning_effort=non_default_params.get("reasoning_effort"), model=model ) + if thinking is not None: + optional_params["thinking"] = thinking optional_params.pop("reasoning_effort", None) ## handle thinking tokens self.update_optional_params_with_thinking_tokens(