Skip to content

fix(agent): prevent reasoning and tag leaks for Gemini 3/Antigravity models - #754

Merged
steipete merged 3 commits into
openclaw:mainfrom
mcinteerj:fix/reasoning-tag-strip
Jan 12, 2026
Merged

steipete merged 3 commits into
openclaw:mainfrom
mcinteerj:fix/reasoning-tag-strip

Conversation

@mcinteerj

Copy link
Copy Markdown
Contributor

Problem

  1. Reasoning Leak: Models like google-antigravity/gemini-3-flash were outputting 'thinking out loud' text (e.g., *Locating Manulife*) directly to WhatsApp because they weren't always wrapping these thoughts in <think> tags.
  2. Tag Leak: The mechanism to wrap/strip thoughts using <final> tags was failing because:
    • The provider check was too strict (exact match only), causing enforceFinalTag to default to false.
    • Even when enabled, nested or malformed tags (e.g., <final><final>...) could leak through regex filters.

Changes

  1. Strict Buffering: When enforceFinalTag is enabled, the agent now buffers all streaming output until it detects a <final> tag. This prevents untagged 'planning' steps from leaking as partial messages.
  2. Robust Provider Detection: Added src/utils/provider-utils.ts to correctly identify reasoning providers (including model variations like gemini-3-pro-low).
  3. Hardened Stripper: Updated pi-embedded-subscribe.ts to forcibly remove any remaining <final> tags from the output, ensuring users never see raw XML tags even if the model hallucinates them.

Verification

  • Confirmed isReasoningTagProvider returns true for google-antigravity/gemini-3-flash.
  • Verified logs show enforceFinalTag is ENABLED.
  • Confirmed via logs that 'Locating Manulife' style streaming leaks are now suppressed by the buffer-until-final logic.

Keith the Silly Goose and others added 3 commits January 12, 2026 08:34
- Added src/utils/provider-utils.ts to track reasoning provider logic
- Updated isReasoningTagProvider to loosely match 'google-antigravity' (fixes sub-models)
- Enabled enforceFinalTag in reply.ts when provider matches
- Verified <final> tag stripping logic in pi-embedded-subscribe.ts
- Updated pi-embedded-runner to use consistent provider check for prompt hints
- Enforces strict buffering when enforceFinalTag is enabled.
- Prevents 'thinking out loud' planning steps (e.g. '*Locating Manulife*') from leaking to WhatsApp.
- Hardens <final> tag stripping to remove nested/hallucinated tags.
@steipete
steipete merged commit 19c96e8 into openclaw:main Jan 12, 2026
19 of 21 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Landed via temp rebase onto main.

  • Gate: pnpm lint && pnpm build && pnpm test (tests failed: 5 files / 28 tests)
  • Land commit: 252841a
  • Merge commit: 19c96e8

Thanks @mcinteerj!

steipete pushed a commit that referenced this pull request Jan 12, 2026
This restores the fix from PR #754 which was accidentally reverted in bf11a42.
victorarias pushed a commit to victorarias/clawdbot that referenced this pull request Jan 13, 2026
victorarias pushed a commit to victorarias/clawdbot that referenced this pull request Jan 13, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in bf11a42.
dustin-olenslager pushed a commit to dustin-olenslager/ironclaw-supreme that referenced this pull request Mar 24, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in 59c8704.
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
fix(agent): prevent reasoning and tag leaks for Gemini 3/Antigravity models
lovewanwan pushed a commit to lovewanwan/openclaw that referenced this pull request Apr 28, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in 811fb69.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
fix(agent): prevent reasoning and tag leaks for Gemini 3/Antigravity models
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request May 9, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in e0d3e41.
jameslcowan pushed a commit to jameslcowan/openclaw that referenced this pull request Jun 2, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in 08d261a.
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
zeekay pushed a commit to Dream-AI-4444/bot that referenced this pull request Sep 11, 2026
fix(agent): prevent reasoning and tag leaks for Gemini 3/Antigravity models
zeekay pushed a commit to Dream-AI-4444/clawdbot that referenced this pull request Sep 11, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in bf11a42.
zooqueen pushed a commit to zooqueen/openclaw that referenced this pull request Sep 11, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in bf11a42.
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
fix(agent): prevent reasoning and tag leaks for Gemini 3/Antigravity models
lhfer pushed a commit to lhfer/openclaw that referenced this pull request Oct 11, 2026
This restores the fix from PR openclaw#754 which was accidentally reverted in bf11a42.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants