From d4bce29721a02a2794f93a06ab3baddf8ccdd594 Mon Sep 17 00:00:00 2001 From: Lifu Huang Date: Wed, 20 Aug 2025 16:25:36 -0700 Subject: [PATCH] Fix incorrect logic in chat template handling. (#9336) Signed-off-by: Xinyuan Tong Co-authored-by: Xinyuan Tong --- python/sglang/srt/managers/template_manager.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/python/sglang/srt/managers/template_manager.py b/python/sglang/srt/managers/template_manager.py index 2327f942b..b4f8602c1 100644 --- a/python/sglang/srt/managers/template_manager.py +++ b/python/sglang/srt/managers/template_manager.py @@ -89,6 +89,7 @@ class TemplateManager: if template is None: return False + # TODO: remove this hard code the reasoning pattern force_reasoning_pattern = r"<\|im_start\|>assistant\\n\\n" has_reasoning = re.search(force_reasoning_pattern, template) is not None @@ -128,11 +129,12 @@ class TemplateManager: logger.info( f"Using default HuggingFace chat template with detected content format: {self._jinja_template_content_format}" ) - return - - # Default to string content format if no template was found - self._jinja_template_content_format = "string" - logger.info("No chat template found, defaulting to 'string' content format") + else: + # Default to string content format if no template was found + self._jinja_template_content_format = "string" + logger.info( + "No chat template found, defaulting to 'string' content format" + ) # Detect reasoning pattern from chat template if tokenizer_manager.tokenizer: