Skip to content

JiuwenSwarm is an intelligent AI Agent built on openJiuwen. It extends the powerful capabilities of large language models directly to your fingertips through various communication apps you use daily.

Python

fix(thinking): DeepSeek 白名单改为关键字匹配,覆盖 v4 系列

d30029696e330f5b8219b
diff --git a/jiuwenswarm/common/thinking/vendor_map.py b/jiuwenswarm/common/thinking/vendor_map.py
index b0fc9dfa29..290d868bec 100644
--- a/jiuwenswarm/common/thinking/vendor_map.py
+++ b/jiuwenswarm/common/thinking/vendor_map.py
@@ -3,22 +3,24 @@
"""Vendor match table for thinking control (no skill/role knowledge).
Only explicitly allowlisted model families participate in thinking toggle.
-Currently: GLM-5 / GLM-5.1 / GLM-5.2 / DeepSeek-V3.2.
+Currently: GLM-5 / GLM-5.1 / GLM-5.2 / DeepSeek (keyword match, all versions).
"""
from __future__ import annotations
import re
-# Ordered: first match wins. Patterns are intentionally narrow to avoid
-# false positives (e.g. glm-4, glm-50, deepseek-chat, deepseek-v3.1).
+# Ordered: first match wins. GLM pattern is intentionally narrow to avoid
+# false positives (e.g. glm-4, glm-50, glm-5.3); DeepSeek is matched by
+# keyword across versions (v3.x / v4 / chat) — non-thinking variants rely
+# on the executor's bare-retry fallback for rejected thinking params.
_VENDOR_PATTERNS: tuple[tuple[re.Pattern[str], str], ...] = (
(
re.compile(r"(?:^|[^a-z0-9])glm[-_]?5(?:\.(?:1|2))?(?:$|[^0-9.])", re.IGNORECASE),
"extra_body_thinking_type",
),
(
- re.compile(r"(?:^|[^a-z0-9])deepseek[-_]?v?3\.2(?:$|[^0-9])", re.IGNORECASE),
+ re.compile(r"(?:^|[^a-z0-9])deepseek", re.IGNORECASE),
"extra_body_thinking_type",
),
)
diff --git a/tests/unit_tests/common/test_thinking_adapter.py b/tests/unit_tests/common/test_thinking_adapter.py
index 33e5e45453..1d4412826d 100644
--- a/tests/unit_tests/common/test_thinking_adapter.py
+++ b/tests/unit_tests/common/test_thinking_adapter.py
@@ -34,19 +34,23 @@ class TestVendorMap:
assert match_vendor_style("glm-5.2") == "extra_body_thinking_type"
assert match_vendor_style("provider/glm_5.1") == "extra_body_thinking_type"
- def test_match_deepseek_v32(self):
+ def test_match_deepseek_family(self):
assert match_vendor_style("DeepSeek-V3.2") == "extra_body_thinking_type"
assert match_vendor_style("deepseek-v3.2") == "extra_body_thinking_type"
assert match_vendor_style("deepseek_v3.2") == "extra_body_thinking_type"
+ assert match_vendor_style("deepseek-v4-flash-0731") == "extra_body_thinking_type"
+ assert match_vendor_style("deepseek-v4-pro") == "extra_body_thinking_type"
+ assert match_vendor_style("deepseek-chat") == "extra_body_thinking_type"
+ assert match_vendor_style("provider/deepseek-v3.1") == "extra_body_thinking_type"
def test_unsupported(self):
assert match_vendor_style("doubao-pro") is None
assert match_vendor_style("qwen3-max") is None
- assert match_vendor_style("deepseek-chat") is None
- assert match_vendor_style("deepseek-v3.1") is None
assert match_vendor_style("glm-4") is None
assert match_vendor_style("glm-50") is None
assert match_vendor_style("glm-5.3") is None
+ # 词边界:无分隔的前缀拼名不命中
+ assert match_vendor_style("somedeepseek") is None
assert match_vendor_style("") is None
def test_style_kwargs(self):
@@ -75,6 +79,12 @@ class TestAdaptThinking:
assert profile.injected is True
assert profile.llm_call_kwargs["extra_body"]["thinking"]["type"] == "enabled"
+ def test_off_deepseek_v4_flash(self):
+ profile = adapt_thinking("off", model_name="deepseek-v4-flash-0731")
+ assert profile.injected is True
+ assert profile.degraded is False
+ assert profile.llm_call_kwargs["extra_body"]["thinking"]["type"] == "disabled"
+
def test_unsupported_degraded(self):
profile = adapt_thinking("off", model_name="qwen3-plus")
assert profile.injected is False