Fix Inkling tool-call parsing recovery, content handling, and streaming (#32861)

This commit is contained in:
Ke Bao
2026-07-30 14:11:09 +08:00
committed by GitHub
parent f4e0ac382e
commit 07a087bf45
4 changed files with 329 additions and 285 deletions
+5 -4
View File
@@ -15,6 +15,7 @@ from sglang.srt.function_call.hunyuan_detector import resolve_hunyuan_tokens
from sglang.srt.parser.harmony_parser import HarmonyParser
from sglang.srt.parser.inkling_tokenizer import (
CONTENT_INVOKE_TOOL_JSON,
CONTENT_INVOKE_TOOL_TEXT,
CONTENT_MODEL_END_SAMPLING,
CONTENT_TEXT,
CONTENT_THINKING,
@@ -862,12 +863,12 @@ class InklingDetector(BaseReasoningFormatDetector):
# a real header can only follow an end token. Preserve it
# instead of rerouting the rest of the block into a header.
emit(token)
elif token == CONTENT_INVOKE_TOOL_JSON:
elif token in (CONTENT_INVOKE_TOOL_JSON, CONTENT_INVOKE_TOOL_TEXT):
# Preserve the tool-invocation framing (json and headerless raw
# text) in content so the tool-call detector receives it.
flush_reasoning()
if self._kind == "header":
content.extend(
(MESSAGE_MODEL, self._pending_header, CONTENT_INVOKE_TOOL_JSON)
)
content.extend((MESSAGE_MODEL, self._pending_header, token))
self._pending_header = ""
else:
content.append(token)