From 56177f34fdd9dff2917af198190adc8a8b326284 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 27 Aug 2026 09:14:54 +0000 Subject: [PATCH] fix: stream reasoning deltas when the provider also sends reasoning_details Providers such as OpenRouter emit reasoning_details alongside the reasoning text on the same delta. Merging those details cleared the pending event unconditionally, discarding the response.reasoning_text.delta that had just been built, so the client received no reasoning until the response completed and the thinking block only appeared after generation finished. The event is now only dropped when the details were all there was to report. Details persistence is unchanged. Co-Authored-By: Claude Opus 5 Claude-Session: https://claude.ai/code/session_014uuEg4AXPs9zE3vVUfN1Fj --- backend/open_webui/utils/middleware.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index cc5f57e0c3..0a750a29d7 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -5222,7 +5222,12 @@ async def streaming_chat_response_handler(response, ctx): reasoning_detail_items, ) await save_current_response_stream() - data = None + # Providers such as OpenRouter send reasoning_details + # alongside the reasoning text: only drop the event when + # the details were all there was to report, otherwise the + # reasoning delta never reaches the client. + if not reasoning_content: + data = None if value: if (