[PR #23929] [CLOSED] fix: only set finish_reason 'stop' on final SSE chunk when usage is present #50489

Closed
opened 2026-04-30 03:12:50 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23929
Author: @pvyswiss
Created: 4/21/2026
Status: Closed

Base: mainHead: fix/premature-finish-reason-stop


📝 Commits (1)

  • 4595d01 fix: only set finish_reason 'stop' on final SSE chunk (when usage present)

📊 Changes

1 file changed (+1 additions, -1 deletions)

View changed files

📝 backend/open_webui/utils/misc.py (+1 -1)

📄 Description

Summary

Fixes #23921 (Ref: #23917 Bug 2)

  • One-line fix in misc.py: add usage and to the finish_reason condition
  • Empty content/thinking strings from Ollama's first chunk are falsy in Python
  • This caused finish_reason: "stop" on the very first SSE chunk
  • API clients close the stream immediately, missing all reasoning and content

🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/23929 **Author:** [@pvyswiss](https://github.com/pvyswiss) **Created:** 4/21/2026 **Status:** ❌ Closed **Base:** `main` ← **Head:** `fix/premature-finish-reason-stop` --- ### 📝 Commits (1) - [`4595d01`](https://github.com/open-webui/open-webui/commit/4595d011baae6079f0988fa9ba372299af1c4aa7) fix: only set finish_reason 'stop' on final SSE chunk (when usage present) ### 📊 Changes **1 file changed** (+1 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/misc.py` (+1 -1) </details> ### 📄 Description ## Summary Fixes #23921 (Ref: #23917 Bug 2) - One-line fix in `misc.py`: add `usage and` to the `finish_reason` condition - Empty `content`/`thinking` strings from Ollama's first chunk are falsy in Python - This caused `finish_reason: "stop"` on the very first SSE chunk - API clients close the stream immediately, missing all reasoning and content --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 03:12:50 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#50489