diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index c03e689ff2..eb4d1e742e 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -5008,7 +5008,8 @@ async def streaming_chat_response_handler(response, ctx): if current_response_tool_call is None: # Add the new tool call delta_tool_call.setdefault('function', {}) - delta_tool_call['function'].setdefault('name', '') + if delta_tool_call['function'].get('name') is None: + delta_tool_call['function']['name'] = '' delta_tool_call['id'] = delta_tool_call.get('id') or output_id('fc') delta_arguments = delta_tool_call['function'].get('arguments') if not isinstance(delta_arguments, str):