From c384d8e514929e8e81044e2f6e60f7e9bf63ba52 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Fri, 6 Nov 2026 00:19:36 +0100 Subject: [PATCH] fix: split tool calls leave an extra unfinished tool call in the chat (#33779) When a model sends several tool calls glued into one (for example GPT-5.4 putting two JSON argument sets in a single call), Open WebUI ran each part but also kept the original call in the message with the broken combined arguments and no result. That showed up as an extra tool call that never gets a result, and it was dropped silently when the chat was sent back to the model. The first part now reuses the original call, so every tool call in the message has exactly one result. Fixes #33778 --- backend/open_webui/utils/middleware.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 2d2c25c4c6..2160a6d5ae 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -444,9 +444,11 @@ def _split_tool_calls( if len(split_arguments) <= 1: expanded.append(tool_call) else: - for argument in split_arguments: + for position, argument in enumerate(split_arguments): cloned = copy.deepcopy(tool_call) - cloned['id'] = f'call_{uuid4().hex[:24]}' + # The first split keeps the original id so it maps to the streamed output item. + if position > 0: + cloned['id'] = f'call_{uuid4().hex[:24]}' cloned['function']['arguments'] = argument expanded.append(cloned)