diff --git a/python/sglang/srt/parser/template_detection.py b/python/sglang/srt/parser/template_detection.py index 9dda09563..a662492f0 100644 --- a/python/sglang/srt/parser/template_detection.py +++ b/python/sglang/srt/parser/template_detection.py @@ -168,6 +168,13 @@ REASONING_MODE_RULES = ( and not ctx.has_text("thinking") ), ), + DetectionRule( + name="glm53_always_think", + value=ReasoningToggleConfig(special_case="always"), + # GLM-5.3's generation prompt opens , so the output carries no + # opening tag; lambda because _is_glm53 is defined below. + predicate=lambda ctx: _is_glm53(ctx), + ), DetectionRule( name="mistral_reasoning_effort", value=ReasoningToggleConfig(special_case="mistral"), diff --git a/test/registered/unit/parser/test_template_manager.py b/test/registered/unit/parser/test_template_manager.py index 39d844e41..1d1da64fa 100644 --- a/test/registered/unit/parser/test_template_manager.py +++ b/test/registered/unit/parser/test_template_manager.py @@ -116,6 +116,13 @@ class TestTemplateManagerReasoningDetection(unittest.TestCase): "glm47", ) + def test_glm53_effort_template_forces_reasoning(self): + vocab = ["", "", "", "<|user|>", "<|endoftext|>"] + force, config, _ = self._detect(_glm53_template("+"), vocab) + + self.assertTrue(force) + self.assertEqual(config, ReasoningToggleConfig(special_case="always")) + def test_interns1_detects_enable_thinking_default_true(self): template = """ {% set default_thinking_sys %}......{% endset %}