From 587a55f33bfa09e5e154041e34bf5c03bb113db2 Mon Sep 17 00:00:00 2001 From: maco Date: Sun, 9 Aug 2026 20:13:40 +0200 Subject: [PATCH] fix: pair each round's tool results with that round's tool calls Closes #28305 --- backend/open_webui/utils/middleware.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 1daccff6ad..2cd098941a 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -4918,6 +4918,13 @@ async def streaming_chat_response_handler(response, ctx): response_tool_calls = tool_calls.pop(0) + answered_call_ids = { + item.get('call_id') for item in output if item.get('type') == 'function_call_output' + } + for tc in response_tool_calls: + if tc.get('id') and tc['id'] in answered_call_ids: + tc['id'] = output_id('call') + # Append function_call items for each tool call # (Responses API already has them from streaming, so skip duplicates) existing_call_ids = {item.get('call_id') for item in output if item.get('type') == 'function_call'}