mirror of
https://github.com/open-webui/open-webui.git
synced 2026-07-16 23:21:44 -05:00
[GH-ISSUE #21888] bug: RAG query generation fails with thinking models (<think> tags break JSON extraction) #35132
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 @rockinyp on GitHub (Feb 26, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/21888
GitHub Issue Draft for open-webui/open-webui
Title: RAG query generation fails with thinking models (
<think>tags break JSON extraction)Description
RAG query generation fails when using thinking models (Qwen3, DeepSeek R1, etc.) because these models wrap their responses in
<think>...</think>tags. The current JSON extraction logic doesn't handle this, causing RAG to silently fail with "No sources found."Steps to Reproduce
Expected Behavior
RAG should work regardless of whether the model outputs thinking tags.
Actual Behavior
TypeError: 'NoneType' object is not subscriptableingenerate_embeddingsRoot Cause
In
open_webui/utils/middleware.py(around line 1763), the query generation response is parsed like this:When a thinking model responds, the content looks like:
The JSON extraction either fails or extracts garbage because:
{inside thinking content may be found firstProposed Fix
Strip
<think>...</think>tags before JSON extraction:This is a minimal, non-breaking change that:
<think>tags to strip)re.DOTALLto handle multi-line thinking blocksEnvironment
<think>output formatAdditional Context
Labels to add
bugragenhancement(if treating as feature request for thinking model support)@pr-validator-bot commented on GitHub (Feb 26, 2026):
⚠️ Missing Issue Title Prefix
@rockinyp, your issue title is missing a prefix (e.g.,
bug:,feat:,docs:).Please update your issue title to include one of the following prefixes:
Example:
bug: Login fails when using special characters in password@rockinyp commented on GitHub (Feb 26, 2026):
Should be updated now.
@Classic298 commented on GitHub (Mar 7, 2026):
Generally it is not recommended to use reasoning models as task models but I'll leave this open for now
@tjbck commented on GitHub (Mar 24, 2026):
Addressed in dev.
@Yasand123 commented on GitHub (Apr 15, 2026):
Is this fix included in v0.8.12? since I still have the issue
@rockinyp commented on GitHub (Apr 15, 2026):
My solution was to switch from MLX to Ollama. Ollama adds better support for the thinking tags than MLX.