From f59552effff1c27caf3075d7fb006f5cbd7fc890 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Thu, 5 Nov 2026 14:30:39 +0100 Subject: [PATCH] perf: stop resending the whole reply on every reasoning chunk with OpenRouter-style providers (#33698) Providers such as OpenRouter attach reasoning details to every reasoning chunk, and each of those chunks made Open WebUI send the entire reply so far to the browser and, with Redis, rewrite the copy kept for page reloads. The browser never shows these details, so a long reasoning reply moved tens of megabytes for a few kilobytes of text. Those chunks now stream like any other reasoning text, and the details are still saved with the reply and still sent back to the provider on the next request. Measured against a simulated OpenRouter-style provider streaming 1,500 reasoning chunks: | | before | after | |---|---|---| | Data sent to the browser | 73.6 MB | 0.73 MB | | Redis writes for the reload copy | 1,504 | 19 | --- backend/open_webui/utils/middleware.py | 5 ----- 1 file changed, 5 deletions(-) diff --git a/backend/open_webui/utils/middleware.py b/backend/open_webui/utils/middleware.py index 3135310d3a..27d65ac26f 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -5299,11 +5299,6 @@ async def streaming_chat_response_handler(response, ctx): reasoning_item.setdefault('reasoning_details', []), reasoning_detail_items, ) - await flush_pending_delta_data() - await event_emitter( - {'type': 'chat:completion', 'data': {'output': full_output()}} - ) - stream_size = 0 data = None if value: