[PR #21355] [CLOSED] fix: fix: prevent cascading reasoning item creation from inline think tags #26042

Closed
opened 2026-04-20 06:17:04 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/21355
Author: @Classic298
Created: 2/13/2026
Status: Closed

Base: devHead: reasoning-handling


📝 Commits (2)

  • 2c53d39 fix: fix: prevent cascading reasoning item creation from inline think tags
  • 429f80c fix: reset content accumulator between streaming rounds to prevent think tag leakage

📊 Changes

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

View changed files

📝 backend/open_webui/utils/middleware.py (+48 -11)

📄 Description

Fix reasoning trace rendering regression in v0.8.0 where inline reasoning tags (e.g. think/thinking) caused one collapsible block per token, freezing the browser.

Root cause: tag_output_handler did not strip the start tag from the content accumulator after detection, causing it to be re-detected on every subsequent token. Additionally, tokens arriving during an active reasoning block were routed to new message items instead of being appended to the reasoning item.

Changes:

  • Strip start tag from content accumulator on detection in tag_output_handler to prevent cascading re-detection
  • Route streaming tokens directly to in-progress reasoning items from tag detection instead of creating intermediate message items
  • Guard message text append to skip when already handled by the reasoning branch
  • Add 8 unit tests for tag_output_handler covering single/multiple blocks, tag variants, split tokens, and content deduplication

Only affects providers sending reasoning as inline tags in the content delta (e.g. Google generativelanguage, Minimax, Ollama). Providers using the separate reasoning_content field (OpenAI, LiteLLM/OpenRouter) are unaffected.

Fixes #21348

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.

Note

Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in.


🔄 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/21355 **Author:** [@Classic298](https://github.com/Classic298) **Created:** 2/13/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `reasoning-handling` --- ### 📝 Commits (2) - [`2c53d39`](https://github.com/open-webui/open-webui/commit/2c53d395f62597a648eca079d2de44d2ee4ac387) fix: fix: prevent cascading reasoning item creation from inline think tags - [`429f80c`](https://github.com/open-webui/open-webui/commit/429f80cff0014dac9ad5df583c083efc76b16c30) fix: reset content accumulator between streaming rounds to prevent think tag leakage ### 📊 Changes **1 file changed** (+48 additions, -11 deletions) <details> <summary>View changed files</summary> 📝 `backend/open_webui/utils/middleware.py` (+48 -11) </details> ### 📄 Description Fix reasoning trace rendering regression in v0.8.0 where inline reasoning tags (e.g. think/thinking) caused one collapsible block per token, freezing the browser. Root cause: tag_output_handler did not strip the start tag from the content accumulator after detection, causing it to be re-detected on every subsequent token. Additionally, tokens arriving during an active reasoning block were routed to new message items instead of being appended to the reasoning item. Changes: - Strip start tag from content accumulator on detection in tag_output_handler to prevent cascading re-detection - Route streaming tokens directly to in-progress reasoning items from tag detection instead of creating intermediate message items - Guard message text append to skip when already handled by the reasoning branch - Add 8 unit tests for tag_output_handler covering single/multiple blocks, tag variants, split tokens, and content deduplication Only affects providers sending reasoning as inline tags in the content delta (e.g. Google generativelanguage, Minimax, Ollama). Providers using the separate reasoning_content field (OpenAI, LiteLLM/OpenRouter) are unaffected. Fixes #21348 ### Contributor License Agreement <!-- 🚨 DO NOT DELETE THE TEXT BELOW 🚨 Keep the "Contributor License Agreement" confirmation text intact. Deleting it will trigger the CLA-Bot to INVALIDATE your PR. --> By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. > [!NOTE] > Deleting the CLA section will lead to immediate closure of your PR and it will not be merged in. --- <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-20 06:17:04 -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#26042