From 7cd1ce5f4af9ef7b8073ce8ef1fff8355b193f75 Mon Sep 17 00:00:00 2001 From: Divyansh8321 Date: Sun, 24 May 2026 18:37:23 +0530 Subject: [PATCH] fix(deepseek): use registry-first check in _is_always_on_reasoner with string fallback Addresses Greptile P1: replaces pure string-pattern detection with a registry- first approach. supports_reasoning() is called first (deepseek-reasoner and R1 variants have supports_reasoning: true in the model registry; V4 opt-in models like deepseek-chat do not). String patterns remain as fallback for unregistered or custom-deployment model names. New always-on models can be handled by adding a registry entry, without touching transformation code. --- litellm/llms/deepseek/chat/transformation.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/litellm/llms/deepseek/chat/transformation.py b/litellm/llms/deepseek/chat/transformation.py index 2a0e16aa28d..4a1975118a3 100644 --- a/litellm/llms/deepseek/chat/transformation.py +++ b/litellm/llms/deepseek/chat/transformation.py @@ -143,7 +143,21 @@ class DeepSeekChatConfig(OpenAIGPTConfig): Returns True for models with always-on thinking (deepseek-reasoner, R1 variants). These models reject reasoning_effort, thinking: {"type": "disabled"}, and require reasoning_content on every assistant message unconditionally. + + Uses the litellm model registry (supports_reasoning field) as the primary + signal — deepseek-reasoner and R1 variants have supports_reasoning: true while + V4 opt-in models (deepseek-chat, deepseek-v3, etc.) do not. Falls back to + string-pattern matching for unregistered or custom-deployment model names. """ + # Primary: registry-based check + try: + from litellm.utils import supports_reasoning + + if supports_reasoning(model=model, custom_llm_provider="deepseek"): + return True + except Exception: + pass + # Fallback: string patterns for unregistered variants / custom deployments m = model.lower() return "reasoner" in m or "-r1" in m or "/r1" in m