fix: tool parse in large streaming chunk beginning with normal content (#10397)

Co-authored-by: gemini-code-assist[bot] <176961590+gemini-code-assist[bot]@users.noreply.github.com>
This commit is contained in:
Xinyuan Tong
2025-09-12 22:29:35 -07:00
committed by GitHub
parent c9ec4cae5b
commit 6f4676ef85

View File

@@ -162,12 +162,9 @@ class BaseFormatDetector(ABC):
try:
try:
if current_text.startswith(self.bot_token):
start_idx = len(self.bot_token)
elif self.current_tool_id > 0 and current_text.startswith(
self.tool_call_separator + self.bot_token
):
start_idx = len(self.tool_call_separator + self.bot_token)
tool_call_pos = current_text.find(self.bot_token)
if tool_call_pos != -1:
start_idx = tool_call_pos + len(self.bot_token)
elif self.current_tool_id > 0 and current_text.startswith(
self.tool_call_separator
):