openclaw - ✅(Solved) Fix [Bug]: Gemini <final> tags leak into delivered messages [1 pull requests, 1 comments, 2 participants]

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…
GitHub stats
openclaw/openclaw#65867Fetched 2026-04-14 05:39:49
View on GitHub
Comments
1
Participants
2
Timeline
5
Reactions
0
Author
Participants
Timeline (top)
labeled ×2commented ×1cross-referenced ×1referenced ×1

Sorry i am new to the this is a resurfaced issue like #48587 as far as i could gather. everything was fine did newest update now i see the <final> tags in answer of chatbot in webui no tags in whatsapp

Root Cause

Sorry i am new to the this is a resurfaced issue like #48587 as far as i could gather. everything was fine did newest update now i see the <final> tags in answer of chatbot in webui no tags in whatsapp

Fix Action

Fixed

PR fix notes

PR #66225: fix(agents): align final tag regexes to handle self-closing <final/> variant

Description (problem / solution / changelog)

Summary

  • Aligns FINAL_TAG_SCAN_RE (streaming subscriber) and FINAL_TAG_RE (user-facing text sanitizer) with the broader pattern already used by reasoning-tags.ts
  • The narrower regex /<\s*\/?\s*final\s*>/gi matched <final> and </final> but not <final/> (self-closing), which some Gemini models emit
  • The shared reasoning-tags.ts already used /<\s*\/?\s*final\b[^<>]*>/gi which handles all variants — this change aligns the other two callsites

Root Cause

Three separate FINAL_TAG_RE regexes existed in the codebase with different patterns:

  1. reasoning-tags.ts: \b[^<>]* after final — handles <final/>
  2. sanitize-user-facing-text.ts: \s* after final — misses <final/>
  3. pi-embedded-subscribe.ts: \s* after final — misses <final/>

The webui streaming path uses #3, so <final/> tags leaked into the display.

Test Plan

  • Added regression test for sanitizeUserFacingText stripping <final/> self-closing tags
  • Added regression test for streaming subscriber stripping <final/> tags when enforcement is off
  • All 82 sanitizer tests pass, all 6 subscriber tests pass, all 45 reasoning-tags tests pass

Closes #65867

Changed files

  • src/agents/pi-embedded-helpers.sanitizeuserfacingtext.test.ts (modified, +6/-0)
  • src/agents/pi-embedded-helpers/sanitize-user-facing-text.ts (modified, +1/-1)
  • src/agents/pi-embedded-subscribe.subscribe-embedded-pi-session.filters-final-suppresses-output-without-start-tag.test.ts (modified, +35/-0)
  • src/agents/pi-embedded-subscribe.ts (modified, +11/-3)
RAW_BUFFERClick to expand / collapse

Bug type

Regression (worked before, now fails)

Beta release blocker

No

Summary

Sorry i am new to the this is a resurfaced issue like #48587 as far as i could gather. everything was fine did newest update now i see the <final> tags in answer of chatbot in webui no tags in whatsapp

Steps to reproduce

Start openclaw, chat with assistant in webui

Expected behavior

no <final> <final/> visible on answer in webui

Actual behavior

<final> <final/> visible in answer at start and end of the answer.

OpenClaw version

2026.4.11

Operating system

windows 11

Install method

npm global

Model

gemini 3.1 pro preview

Provider / routing chain

openclaw > google ai > gemini 3.1 pro

Additional provider/model setup details

No response

Logs, screenshots, and evidence

Impact and severity

No response

Additional information

no problem with 2026.4.10 problem with 2026.4.11 updated to 2026.4.12 tags still visible.

extent analysis

TL;DR

Downgrade to OpenClaw version 2026.4.10 to potentially resolve the issue with <final> tags visible in chatbot answers on the webui.

Guidance

  • The issue seems to be related to the update from OpenClaw version 2026.4.10 to 2026.4.11, as the problem started after the update.
  • Try downgrading to version 2026.4.10 to see if the issue is resolved, as the user mentioned that there was no problem with this version.
  • If downgrading is not feasible, check if there are any configuration options or settings in OpenClaw that may be causing the <final> tags to be displayed.
  • Verify that the issue is not related to the model or provider by testing with a different model or provider, if possible.

Example

No code snippet is provided as there is no clear indication of what code changes could resolve the issue.

Notes

The issue may be specific to the Gemini 3.1 Pro Preview model or the Google AI provider, and further investigation may be needed to determine the root cause.

Recommendation

Apply workaround: Downgrade to OpenClaw version 2026.4.10, as this version was reported to not have the issue, and the problem started after updating to version 2026.4.11.

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…

FAQ

Expected behavior

no <final> <final/> visible on answer in webui

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 - ✅(Solved) Fix [Bug]: Gemini <final> tags leak into delivered messages [1 pull requests, 1 comments, 2 participants]