mirror of
https://github.com/open-webui/open-webui.git
synced 2026-05-07 11:28:35 -05:00
[PR #20933] [CLOSED] fix: set finish_reason to "tool_calls" when tool calls are present in API responses #64696
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/20933
Author: @Classic298
Created: 1/25/2026
Status: ❌ Closed
Base:
dev← Head:tool-call-early-stop📝 Commits (1)
dea3e4efix: set finish_reason to "tool_calls" when tool calls are present in API responses📊 Changes
1 file changed (+4 additions, -2 deletions)
View changed files
📝
backend/open_webui/utils/misc.py(+4 -2)📄 Description
fix: set finish_reason to "tool_calls" when tool calls are present in API responses
When Open WebUI converts Ollama responses to OpenAI format, finish_reason was always set to "stop" even when tool_calls were present. This caused external API clients (like OpenCode) to stop after receiving tool calls instead of continuing the conversation.
Per the OpenAI API specification, finish_reason should be "tool_calls" when the model returns tool calls, signaling to clients that they should execute the tools and continue. This fix updates both streaming and non-streaming response templates to set the correct finish_reason based on whether tool_calls are present.
Contributor License Agreement
By submitting this pull request, I confirm that I have read and fully agree to the Contributor License Agreement (CLA), and I am providing my contributions under its terms.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.