From 9a55eb67cfe503ca96a7a69a30eabfc228f83b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Yavuz=20Alp=20Sencer=20=C3=96ZT=C3=9CRK?= <28690608+alpsencer@users.noreply.github.com> Date: Tue, 17 Mar 2026 19:44:59 +0300 Subject: [PATCH] fix(openai): handle tool calls with empty/null arguments When an LLM returns a tool call with no arguments (arguments=null in the streaming chunks), the tool call is silently dropped because: 1. `tool_call.function.arguments` is None, so nothing is accumulated and `arguments` stays as "" (empty string) 2. `if function_name and arguments:` treats "" as falsy, skipping the entire tool call execution OpenAI always sends arguments="{}" even for parameterless tools, masking this bug. But vLLM, Ollama, and other OpenAI-compatible providers may omit arguments entirely when the tool schema has no required parameters, causing tool calls to be silently ignored. Fix: check only `function_name` (not `arguments`) and default empty arguments to "{}" so `json.loads` produces an empty dict. Apply the same fallback for intermediate tool calls in multi-tool responses. --- src/pipecat/services/openai/base_llm.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/pipecat/services/openai/base_llm.py b/src/pipecat/services/openai/base_llm.py index eb8ce3cc6..6fceed0e5 100644 --- a/src/pipecat/services/openai/base_llm.py +++ b/src/pipecat/services/openai/base_llm.py @@ -532,7 +532,7 @@ class BaseOpenAILLMService(LLMService): tool_call = chunk.choices[0].delta.tool_calls[0] if tool_call.index != func_idx: functions_list.append(function_name) - arguments_list.append(arguments) + arguments_list.append(arguments or "{}") tool_id_list.append(tool_call_id) function_name = "" arguments = "" @@ -558,10 +558,10 @@ class BaseOpenAILLMService(LLMService): # a registered handler. If so, run the registered callback, save the result to # the context, and re-prompt to get a chat answer. If we don't have a registered # handler, raise an exception. - if function_name and arguments: + if function_name: # added to the list as last function name and arguments not added to the list functions_list.append(function_name) - arguments_list.append(arguments) + arguments_list.append(arguments or "{}") tool_id_list.append(tool_call_id) function_calls = []