mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-06 10:58:17 -05:00
[GH-ISSUE #23917] feat: Open WebUI -- Bug Reports & Feature Requests with attached Patches #58772
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @pvyswiss on GitHub (Apr 21, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/23917
Check Existing Issues
Verify Feature Scope
Problem Description
I tought a PR is not the right way, since its address several findings. Also made the SDK Caching into from Anthropic, saves you a lot of Tokens.
Open WebUI -- Bug Reports & Feature Requests
Bug 1: Stale
Content-EncodingHeader Forwarded from Upstream APIsFile:
backend/open_webui/routers/openai.pySeverity: Critical
Affects: All models routed through OpenAI-compatible upstream APIs (Anthropic, OpenAI, etc.)
Symptom
Desktop clients (OpenCode Desktop, OnlyOffice plugin) receive
Decompression error: ZlibErrorwhen streaming SSE from Claude/OpenAI models. The Web UI works fine.Root Cause
aiohttp(Open WebUI's HTTP client) sendsAccept-Encoding: gzipto upstream APIs. When the upstream responds withContent-Encoding: gzip, aiohttp auto-decompresses the response body but keeps theContent-Encoding: gzipheader in the response headers (known behavior, see aiohttp#4462).Open WebUI's
openai.pyforwards all upstream headers verbatim to the client:The client receives:
Content-Encoding: gzip(tells client "this is compressed")The client tries to gunzip plain text →
ZlibError.Fix
Strip hop-by-hop / encoding headers that become stale after aiohttp auto-decompression:
Impact
Content-Encodingheaders are fixedBug 2: Premature
finish_reason: "stop"on First SSE Chunk (Ollama Models)File:
backend/open_webui/utils/misc.pySeverity: Critical
Affects: All Ollama models with thinking/reasoning (DeepSeek R1, Gemma 4) when accessed via API
Symptom
API clients (OpenCode Desktop) see the first SSE chunk, then the stream appears to end. The model seems to hang after "let me think." The Web UI works fine.
Root Cause
openai_chat_chunk_message_template()inmisc.pyuses truthy checks to determine when to setfinish_reason: "stop":When Ollama sends the first chunk for a reasoning model, both
contentandthinkingare empty strings (""). Empty strings are falsy in Python, so the condition is True, andfinish_reason: "stop"is set on the very first chunk.API clients that comply with the OpenAI spec (like
@ai-sdk/openai-compatible) seefinish_reason: "stop"and close the stream immediately -- before any reasoning or content tokens arrive.The Web UI is unaffected because its browser path never checks
finish_reasonfor stream termination; it reads untildata: [DONE].Fix
Only set
finish_reason: "stop"whenusageis present (which only happens on the final chunk when Ollama sendsdone: true):Impact
finish_reason)Bug 3: Missing
roleand Non-Unique Chunk IDs in Ollama SSE ConversionFile:
backend/open_webui/utils/response.pySeverity: Major
Affects: All Ollama models when accessed via API
Symptom
API clients fail to correlate SSE chunks or initialize the response correctly. Some SDKs silently drop chunks or fail to render content.
Root Cause (Two Issues)
3a: Missing
delta.role: "assistant"on first chunkThe OpenAI SSE spec requires the first chunk to contain
delta.role: "assistant". The Ollama-to-OpenAI conversion inconvert_streaming_response_ollama_to_openai()never emitsrole. OpenAI-compatible SDKs expect this field to initialize the message.3b: Unique UUID per SSE chunk
openai_chat_message_template()generates a newuuid4()for every chunk:The OpenAI spec requires all chunks in a single completion to share the same
id. SDKs use this ID to correlate chunks into one response. With unique IDs per chunk, SDK chunk correlation breaks.For comparison:
msg_xxxxxID across all chunks ✓Fix
Generate one
chatcmpl-prefixed ID per stream and addrole: "assistant"to the first chunk:@Classic298 commented on GitHub (Apr 21, 2026):
This is impossible to track properly please open standalone issues.
And include version numbers what version this is affected in and other information like setup information.
There is a bug report form for a reason and you skipped it.
@pvyswiss commented on GitHub (Apr 21, 2026):
It is possible to track, Each Issue and Fix is described. Files attached. Your PR Guidelines says only PR for Issues. I made this way, since certain things you steer over the Ollama Local API Ports. So my idea was, let you guys cherry pick. But I can if you want to open an issue for each and propose it individual. BTW I also fixed the PDF Render Engine. Black PDFs in Dark Theme is ugly. Gonna look into the opening issue for each after my working hours.
@Classic298 commented on GitHub (Apr 21, 2026):
Where does it say only PR for issues?
@pvyswiss commented on GitHub (Apr 21, 2026):
Ok, here we go, backward compatible to branch stream 0.9
Issue URL
1 Stale Content-Encoding header (ZlibError) #23920
2 Premature finish_reason "stop" #23921
3 Missing delta.role + non-unique chunk IDs #23922
4 Expose reasoning as tags #23923
5 Client tools crash non-native models #23924
6 No API analytics without chat_id #23926
7 Inject stream_options for Anthropic #23927
and for each I created a PR
<head></head> # | Issue | PR | Branch -- | -- | -- | -- 1 | #23920 | #23928 | fix/strip-stale-content-encoding 2 | #23921 | #23929 | fix/premature-finish-reason-stop 3 | #23922 | #23930 | fix/ollama-sse-role-and-chunk-id 4 | #23923 | #23931 | feat/ollama-reasoning-as-think-tags 5 | #23924 | #23932 | fix/strip-tools-non-native-models 6 | #23926 | No PR (design issue, code suggestion in issue) | -- 7 | #23927 | #23933 | fix/inject-stream-options-anthropic# Issue PR Branch
1 #23920 #23928 fix/strip-stale-content-encoding
2 #23921 #23929 fix/premature-finish-reason-stop
3 #23922 #23930 fix/ollama-sse-role-and-chunk-id
4 #23923 #23931 feat/ollama-reasoning-as-think-tags
5 #23924 #23932 fix/strip-tools-non-native-models
6 #23926 No PR (design issue, code suggestion in issue) --
7 #23927 #23933 fix/inject-stream-options-anthropic
If you can look at this, and take a benefit out of it, its awesome.
All PRs:
Reference #23917 (original combined issue)
Are minimal, self-contained patches against current main (v0.9.0)
Have one branch per fix for easy cherry-picking
Are from pvyswiss/open-webui fork
@Classic298 commented on GitHub (Apr 21, 2026):
thank you
@pvyswiss commented on GitHub (Apr 21, 2026):
Thank you too, its a cool project