fix(reasoning): let --enable-strict-thinking works for DeepSeek-V4 (#32400)

Co-authored-by: Claude Fable 5 <noreply@anthropic.com>
Co-authored-by: Xinyuan Tong <xinyuantong.cs@gmail.com>
This commit is contained in:
Shangming Cai
2026-07-27 18:15:47 +08:00
committed by GitHub
co-authored by Claude Fable 5 Xinyuan Tong
parent 08af5aea57
commit 1d350aaad3
2 changed files with 48 additions and 1 deletions
@@ -6,6 +6,7 @@ from sglang.srt.parser.reasoning_parser import (
Apertus2509Detector,
BaseReasoningFormatDetector,
DeepSeekR1Detector,
DeepSeekV4Detector,
Gemma4Detector,
Glm45Detector,
HunyuanDetector,
@@ -167,6 +168,21 @@ class TestQwen3Detector(CustomTestCase):
self.assertEqual(result.reasoning_text, "")
class TestDeepSeekV4Detector(CustomTestCase):
def test_strict_thinking_excludes_deepseek_control_tokens(self):
detector = ReasoningParser(model_type="deepseek-v4").detector
self.assertIsInstance(detector, DeepSeekV4Detector)
self.assertEqual(
detector.think_excluded_tokens,
["<|end▁of▁sentence|>", "|DSML|"],
)
def test_thinking_stays_explicit_opt_in(self):
detector = ReasoningParser(model_type="deepseek-v4").detector
self.assertEqual(detector.reasoning_default, "explicit_thinking")
self.assertTrue(detector.thinks_internally)
class TestInklingDetector(CustomTestCase):
def test_streaming_routes_blocks_across_all_string_boundaries(self):
detector = InklingDetector()