From 9dacaf39576d1a7fbcaa0d9040d7a0c697a372bc Mon Sep 17 00:00:00 2001 From: Bao Nguyen Date: Sun, 3 May 2026 23:09:59 -0700 Subject: [PATCH] fix(deepseek): allow thinking parameter to accept "disabled" type --- litellm/llms/deepseek/chat/transformation.py | 14 +++++++------- .../chat/test_deepseek_chat_transformation.py | 14 ++++++++++++++ 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/litellm/llms/deepseek/chat/transformation.py b/litellm/llms/deepseek/chat/transformation.py index 9cadecb196a..03f58659ca7 100644 --- a/litellm/llms/deepseek/chat/transformation.py +++ b/litellm/llms/deepseek/chat/transformation.py @@ -47,14 +47,14 @@ class DeepSeekChatConfig(OpenAIGPTConfig): thinking_value = optional_params.pop("thinking", None) reasoning_effort = optional_params.pop("reasoning_effort", None) - # Handle thinking parameter - only accept {"type": "enabled"} + # Handle thinking parameter - accept {"type": "enabled"} or {"type": "disabled"} if thinking_value is not None: - if ( - isinstance(thinking_value, dict) - and thinking_value.get("type") == "enabled" - ): - # DeepSeek only accepts {"type": "enabled"}, ignore budget_tokens - optional_params["thinking"] = {"type": "enabled"} + if isinstance(thinking_value, dict) and thinking_value.get( + "type" + ) in ("enabled", "disabled"): + optional_params["thinking"] = { + "type": thinking_value["type"] + } # Handle reasoning_effort - map to thinking enabled/disabled elif reasoning_effort is not None: diff --git a/tests/litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py b/tests/litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py index e6f2a9ad023..34aec2982f3 100644 --- a/tests/litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py +++ b/tests/litellm/llms/deepseek/chat/test_deepseek_chat_transformation.py @@ -139,6 +139,20 @@ class TestDeepSeekThinkingParams: # thinking should be set, reasoning_effort should not override assert result["thinking"] == {"type": "enabled"} + def test_map_thinking_disabled(self): + """Test that thinking={"type": "disabled"} is passed through correctly.""" + non_default_params = {"thinking": {"type": "disabled"}} + optional_params = {} + + result = self.config.map_openai_params( + non_default_params=non_default_params, + optional_params=optional_params, + model=self.model, + drop_params=False, + ) + + assert result["thinking"] == {"type": "disabled"} + def test_invalid_thinking_type_ignored(self): """Test that invalid thinking type values are ignored.""" non_default_params = {"thinking": {"type": "invalid"}}