From 87bed3f0b325f537e3e93ad6076cf2088479d5b1 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 27 Aug 2026 22:56:00 +0200 Subject: [PATCH] fix: stream post-tool-call thinking into the Thoughts section (#29052) After a tool call, the model's thinking was streamed into the chat as if it were the main response, and only jumped into the collapsed Thoughts section once the turn finished. Every further tool call repeated it. Each tool round appended an empty placeholder message item to the output and sent it to the browser, then dropped it again from the copy used to offset the next round's item indices. The browser therefore held one item more than the backend counted, so the first thinking chunk of the next round was written into that leftover message item and rendered as normal text until the finished output replaced it. The placeholder is removed. It was never needed: a message item is already created when actual content arrives, and dropping it also stops an empty assistant message being sent back to the model on the follow-up request. Co-authored-by: Claude --- backend/open_webui/utils/middleware.py | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index d80066e1dd..e11830d4f9 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -5790,17 +5790,6 @@ async def streaming_chat_response_handler(response, ctx): item['arguments'] = tc.get('function', {}).get('arguments', '{}') break - # Append a new empty message item for the next response - output.append( - { - 'type': 'message', - 'id': output_id('msg'), - 'status': 'in_progress', - 'role': 'assistant', - 'content': [{'type': 'output_text', 'text': ''}], - } - ) - # Emit citation sources to the frontend for display if citations_enabled: for source in tool_call_sources: