From b68722512335712004a7ef0e59857c81bdf0b10a Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 8 Oct 2026 19:00:49 +0200 Subject: [PATCH] fix: reply never finishes when streaming is off and the model calls a tool (#32083) With Stream Chat Response turned off, a reply where the model called a tool was never saved or marked as finished, so the chat kept showing it as still generating until the page was reloaded. The reply is now saved and finished like any other non-streamed reply. Tools themselves still only run with streaming on, as the docs describe. --- backend/open_webui/utils/middleware.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 537688ba72..896f0ac5e6 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -4179,12 +4179,14 @@ async def non_streaming_chat_response_handler(response, ctx): choices = response_data.get('choices', []) response_output = response_data.get('output') - content = choices[0].get('message', {}).get('content') if choices else '' + content = (choices[0].get('message', {}).get('content') or '') if choices else '' + # Native tools only run on the streaming path; still finish the turn. + tool_calls = choices[0].get('message', {}).get('tool_calls') if choices else None if (continuing and 'error' not in response_data) or ( - not continuing and choices and (content or response_output) + not continuing and choices and (content or response_output or tool_calls) ): - if content or response_output or continuing: + if content or response_output or tool_calls or continuing: if not continuing: await event_emitter( {