openclaw - 💡(How to fix) Fix [Bug]: WebChat leaks Gemini reasoning tags (<think>/<final>) during streaming — sibling of #87712 [1 pull requests]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…

Following the Telegram reasoning lane fix in #6328 and the pending WhatsApp issue in #87712, Google Gemini models (specifically gemini-3.5-flash) still leak raw <think>...</think> and <final>...</final> tags directly into the WebChat UI during active streaming sessions on OpenClaw v2026.5.28.

Under earlier models like gemini-3.1-pro-preview the issue was less pronounced, but with the verbose and extensive reasoning output of gemini-3.5-flash, the bug is highly disruptive.

Root Cause

While Telegram has a dedicated splitTelegramReasoningText() coordinator to separate the reasoning and answer streams at the channel boundary, the WebChat delivery pipeline relies on generic text sanitization via sanitizeAssistantVisibleTextWithProfile and stripReasoningTagsFromText.

During streaming, when the <think> tag is opened but not yet closed by the model, the fallback inside stripReasoningTagsFromText (at src/shared/text/reasoning-tags.ts:121) returns the unclosed thinking content itself to prevent empty UI updates. This causes the internal reasoning and raw tags to remain permanently visible in the WebChat bubble.

Fix Action

Fixed

RAW_BUFFERClick to expand / collapse

Description

Following the Telegram reasoning lane fix in #6328 and the pending WhatsApp issue in #87712, Google Gemini models (specifically gemini-3.5-flash) still leak raw <think>...</think> and <final>...</final> tags directly into the WebChat UI during active streaming sessions on OpenClaw v2026.5.28.

Under earlier models like gemini-3.1-pro-preview the issue was less pronounced, but with the verbose and extensive reasoning output of gemini-3.5-flash, the bug is highly disruptive.

Severe UX & Truncation Fallout (Message Loss)

Because gemini-3.5-flash produces exceptionally long and detailed thought processes, streaming the entire raw <think> block directly into the WebChat window frequently causes the reply to hit length or char bounds (e.g. chatHistoryMaxChars limits or UI rendering caps) before the model even reaches the <final> block.

As a result, the visible reply is severely truncated, and the user gets a wall of raw reasoning text with no actual answer at the end.

Root Cause

While Telegram has a dedicated splitTelegramReasoningText() coordinator to separate the reasoning and answer streams at the channel boundary, the WebChat delivery pipeline relies on generic text sanitization via sanitizeAssistantVisibleTextWithProfile and stripReasoningTagsFromText.

During streaming, when the <think> tag is opened but not yet closed by the model, the fallback inside stripReasoningTagsFromText (at src/shared/text/reasoning-tags.ts:121) returns the unclosed thinking content itself to prevent empty UI updates. This causes the internal reasoning and raw tags to remain permanently visible in the WebChat bubble.

Steps to Reproduce

  1. Run OpenClaw v2026.5.28 with google/gemini-3.5-flash as the active WebChat model.
  2. Ensure /reasoning or thinking mode is active.
  3. Send an analytical request in the WebChat Control UI.
  4. Observe the raw <think> and </think><final> tags appearing directly inside the visible message bubble, followed by potential truncation of the actual answer due to token/character budget exhaustion from the leaked reasoning text.

Suggested Fix

Implement a dedicated WebChat / Control-UI stream coordinator or reasoning-lane splitter (similar to Telegram's #6328 coordinator) to completely suppress streaming payloads before the <final> block is reached, rather than relying on the generic post-processing tag stripper.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

openclaw - 💡(How to fix) Fix [Bug]: WebChat leaks Gemini reasoning tags (<think>/<final>) during streaming — sibling of #87712 [1 pull requests]