Skip to content
Python

fix(llm): treat deepseek-flash as a thinking model (#1389)

olivergptecd3404213ac
diff --git a/tests/test_capabilities.py b/tests/test_capabilities.py
index 2ab28dc2d..1cd396eaa 100644
--- a/tests/test_capabilities.py
+++ b/tests/test_capabilities.py
@@ -25,6 +25,17 @@ class TestExactIdMatches:
assert caps.supports_tool_choice is False
assert caps.requires_reasoning_content_roundtrip is True
+ def test_deepseek_flash_alias_rejects_tool_choice(self):
+ """``deepseek-flash`` is what the model picker offers for V4.1 Flash.
+
+ It was falling through to _DEFAULT (tool_choice on), so every
+ structured-output call 400'd with "Thinking mode does not support
+ this tool_choice" and burned a retry as free text.
+ """
+ caps = get_capabilities("deepseek-flash")
+ assert caps.supports_tool_choice is False
+ assert caps.requires_reasoning_content_roundtrip is True
+
def test_deepseek_v4_pro_rejects_tool_choice(self):
caps = get_capabilities("deepseek-v4-pro")
assert caps.supports_tool_choice is False
@@ -48,6 +59,10 @@ class TestPatternMatches:
caps = get_capabilities("deepseek-reasoner-pro")
assert caps.supports_tool_choice is False
+ def test_future_flash_variant_inherits_thinking_quirks(self):
+ caps = get_capabilities("deepseek-flash-lite")
+ assert caps.supports_tool_choice is False
+
def test_minimax_m3_inherits_thinking_quirks(self):
caps = get_capabilities("MiniMax-M3")
assert caps.supports_tool_choice is False
@@ -128,6 +143,9 @@ class TestOpenRouterDeepSeekNamespace:
def test_prefixed_reasoner_suppresses_tool_choice(self):
assert get_capabilities("deepseek/deepseek-reasoner").supports_tool_choice is False
+ def test_prefixed_flash_alias_suppresses_tool_choice(self):
+ assert get_capabilities("deepseek/deepseek-flash").supports_tool_choice is False
+
def test_prefixed_chat_selects_deepseek_chat_not_default(self):
# Must resolve to _DEEPSEEK_CHAT, not _DEFAULT: supports_json_schema=False
# is what distinguishes them (both keep tool_choice).
diff --git a/tradingagents/llm_clients/capabilities.py b/tradingagents/llm_clients/capabilities.py
index a2df7100a..e693bb5df 100644
--- a/tradingagents/llm_clients/capabilities.py
+++ b/tradingagents/llm_clients/capabilities.py
@@ -94,6 +94,7 @@ _DEFAULT = ModelCapabilities(
_BY_ID: dict[str, ModelCapabilities] = {
"deepseek-chat": _DEEPSEEK_CHAT,
"deepseek-reasoner": _DEEPSEEK_THINKING,
+ "deepseek-flash": _DEEPSEEK_THINKING,
"deepseek-v4-flash": _DEEPSEEK_THINKING,
"deepseek-v4-pro": _DEEPSEEK_THINKING,
# MiniMax — full official model lineup per
@@ -108,10 +109,14 @@ _BY_ID: dict[str, ModelCapabilities] = {
}
# Forward-compat patterns. New ``deepseek-v5-*`` / ``deepseek-reasoner-*``
-# or ``MiniMax-M3*`` variants inherit the thinking-mode quirks automatically.
+# / ``deepseek-flash-*`` or ``MiniMax-M3*`` variants inherit the thinking-mode
+# quirks automatically. ``deepseek-flash`` is the unversioned alias the model
+# picker offers for V4.1 Flash; it serves thinking mode and so rejects
+# ``tool_choice`` exactly like the versioned ``deepseek-v4-flash`` ID does.
_BY_PATTERN: list[tuple[re.Pattern[str], ModelCapabilities]] = [
(re.compile(r"^deepseek-v\d"), _DEEPSEEK_THINKING),
(re.compile(r"^deepseek-reasoner"), _DEEPSEEK_THINKING),
+ (re.compile(r"^deepseek-flash"), _DEEPSEEK_THINKING),
(re.compile(r"^MiniMax-M\d"), _MINIMAX_THINKING),
]