From 677b66af805d93f7a26e9cf96b7b243eb1beaee1 Mon Sep 17 00:00:00 2001 From: Xinyuan Tong <115166877+JustinTong0323@users.noreply.github.com> Date: Sat, 21 Feb 2026 09:13:08 -0500 Subject: [PATCH] fix KimiK2Detector regex patterns with re.DOTALL (#19120) Signed-off-by: Xinyuan Tong --- python/sglang/srt/function_call/kimik2_detector.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/python/sglang/srt/function_call/kimik2_detector.py b/python/sglang/srt/function_call/kimik2_detector.py index 37d039c39..2480fe80a 100644 --- a/python/sglang/srt/function_call/kimik2_detector.py +++ b/python/sglang/srt/function_call/kimik2_detector.py @@ -40,11 +40,13 @@ class KimiK2Detector(BaseFormatDetector): self.tool_call_end_token: str = "<|tool_call_end|>" self.tool_call_regex = re.compile( - r"<\|tool_call_begin\|>\s*(?P[\w\.]+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P\{.*?\})\s*<\|tool_call_end\|>" + r"<\|tool_call_begin\|>\s*(?P[\w\.]+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P\{.*?\})\s*<\|tool_call_end\|>", + re.DOTALL, ) self.stream_tool_call_portion_regex = re.compile( - r"<\|tool_call_begin\|>\s*(?P[\w\.]+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P\{.*)" + r"<\|tool_call_begin\|>\s*(?P[\w\.]+:\d+)\s*<\|tool_call_argument_begin\|>\s*(?P\{.*)", + re.DOTALL, ) self._last_arguments = "" @@ -87,7 +89,7 @@ class KimiK2Detector(BaseFormatDetector): function_name = m.group("name") function_idx = int(m.group("index")) - logger.info(f"function_name {function_name}") + logger.debug(f"function_name {function_name}") tool_calls.append( ToolCallItem(