From e9a711c2a1c08fbdca5ed6f9208ad683725cc547 Mon Sep 17 00:00:00 2001 From: Classic298 <27028174+Classic298@users.noreply.github.com> Date: Tue, 3 Nov 2026 19:28:23 +0100 Subject: [PATCH] perf: stop resending the whole reply on every reasoning chunk with OpenRouter-style providers 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 e2284b1118..d2be65aa20 100644 --- a/backend/open_webui/utils/middleware.py +++ b/backend/open_webui/utils/middleware.py @@ -5292,11 +5292,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: