[Bugfix] Fix IndexError when accessing prev_tool_call_arr in OpenAIToolParser (#37958)

Signed-off-by: chaunceyjiang <chaunceyjiang@gmail.com>
This commit is contained in:
Chauncey
2026-03-25 12:06:21 +08:00
committed by GitHub
parent 9d0351c91d
commit a32783bb35

View File

@@ -1089,6 +1089,7 @@ class OpenAIServingChat(OpenAIServing):
# any tokens that were generated but previously
# matched by partial json parsing
# only happens if we are NOT using structured outputs
index = 0
auto_tools_called = False
if tool_parser:
auto_tools_called = len(tool_parser.prev_tool_call_arr) > 0
@@ -1097,15 +1098,14 @@ class OpenAIServingChat(OpenAIServing):
if auto_tools_called
else 0
)
else:
index = 0
if (
should_check = (
self._should_check_for_unstreamed_tool_arg_tokens(
delta_message, output
)
and tool_parser
):
)
# only check if there are any tool calls
# detected by partial parsing
if should_check and tool_parser and auto_tools_called:
latest_delta_len = 0
if (
isinstance(