From a32783bb35c6120df88d57609c8e454f9131f0a1 Mon Sep 17 00:00:00 2001 From: Chauncey Date: Wed, 25 Mar 2026 12:06:21 +0800 Subject: [PATCH] [Bugfix] Fix IndexError when accessing prev_tool_call_arr in OpenAIToolParser (#37958) Signed-off-by: chaunceyjiang --- vllm/entrypoints/openai/chat_completion/serving.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/vllm/entrypoints/openai/chat_completion/serving.py b/vllm/entrypoints/openai/chat_completion/serving.py index 62a0192e7..6b39bc5ec 100644 --- a/vllm/entrypoints/openai/chat_completion/serving.py +++ b/vllm/entrypoints/openai/chat_completion/serving.py @@ -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(