mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-17 08:21:12 -05:00
[PR #23087] [CLOSED] fix: handle finish_reason in streaming to prevent infinite loop with tool_calls #65875
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?
📋 Pull Request Information
Original PR: https://github.com/open-webui/open-webui/pull/23087
Author: @yang1002378395-cmyk
Created: 3/26/2026
Status: ❌ Closed
Base:
dev← Head:fix-streaming-tool-calls-loop📝 Commits (1)
45f9ff4fix: handle finish_reason in streaming to prevent infinite loop with tool_calls📊 Changes
1 file changed (+17 additions, -1 deletions)
View changed files
📝
src/lib/apis/streaming/index.ts(+17 -1)📄 Description
Issue
Fixes #23066
Problem
When using streaming responses with tool calls, Open WebUI would get stuck in an infinite loop if the server sent
finish_reason: 'tool_calls'. This is because the streaming parser only checked for[DONE]but ignored OpenAI's standardfinish_reasonfield.Root Cause
In
src/lib/apis/streaming/index.ts, theopenAIStreamToIteratorfunction:delta.contentfor streamingfinish_reasonfromchoices[0].finish_reasonfinish_reasonwas 'tool_calls' or 'stop'Solution
deltaandfinish_reasonfrom parsed datafinish_reasonequals 'tool_calls'finish_reasonequals 'stop'Testing
finish_reason: 'tool_calls', the stream now properly terminatesChecklist
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.