mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[PR #22400] [CLOSED] fix: strip thinking blocks before parsing tool result JSON #113969
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/22400
Author: @Tattooed-Geek
Created: 3/8/2026
Status: ❌ Closed
Base:
dev← Head:fix-21888-rag-thinking-models📝 Commits (1)
52edb0efix: strip thinking blocks before parsing tool result JSON📊 Changes
1 file changed (+23 additions, -1 deletions)
View changed files
📝
backend/open_webui/utils/middleware.py(+23 -1)📄 Description
Pull Request Checklist
devbranch.Changelog Entry
Description
Fixes JSON extraction failures in RAG queries when using "thinking" models (GLM-5, DeepSeek-R1) that output thinking blocks before the actual JSON response.
Fixed
</think>) from model responses before attempting JSON parsing in RAG query processingAdditional Information
Thinking models like GLM-5 and DeepSeek-R1 output their reasoning in thinking blocks before the actual response. The JSON parser was trying to parse these blocks as JSON, causing failures. This fix strips the thinking blocks before parsing.
Fixes #21888
Contributor License Agreement
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.