Skip to content

fix(control-ui): strip <think>/<final> tags from rendered assistant text - #78026

Closed
Beandon13 wants to merge 1 commit into
openclaw:mainfrom
Beandon13:fix/openclaw-77879-strip-streaming-tags
Closed

Beandon13 wants to merge 1 commit into
openclaw:mainfrom
Beandon13:fix/openclaw-77879-strip-streaming-tags

Conversation

@Beandon13

Copy link
Copy Markdown
Contributor

Summary

  • renderGroupedMessage reads message.content[].text directly via normalizeMessage, so the streaming bubble and any non-streaming history message can render raw <think> / <final> scaffolding the model emitted as text.
  • Run the assembled assistant text through stripThinkingTags (internal-scaffolding profile, already used elsewhere in the chat extractor) before it becomes markdown. User and tool roles are unchanged.
  • Adds two regression tests covering both renderStreamingGroup and the non-streaming renderMessageGroup path.

Closes #77879

Testing

  • pnpm vitest run ui/src/ui/chat/grouped-render.test.ts (37/37, includes 2 new)
  • pnpm vitest run ui/src/ui/chat (205/205)
  • pnpm vitest run ui/src/ui/views/chat.test.ts (28/28)

Real behavior proof

  • Behavior or issue addressed: Issue [Bug]: <think> and <final> tags appear in openclaw-control-ui even when thinkingDefault is "off". #77879 reports literal <think> and <final> tags appearing in openclaw-control-ui chat bubbles even when thinkingDefault is "off". The two new tests fail on origin/main (text content includes the tag bodies) and pass after this patch.
  • Real environment tested: Local OpenClaw checkout from this PR branch on macOS (Darwin 25.5.0) at HEAD f25a2824ec81a022727559a6ad1a8e8633ccd77e. Vitest runs from the branch worktree against the changed UI module.
  • Exact steps or command run after this patch:
    pnpm vitest run ui/src/ui/chat/grouped-render.test.ts
    pnpm vitest run ui/src/ui/chat
    
  • Evidence after fix:
     Test Files  1 passed (1)
          Tests  37 passed (37)
       Start at  15:06:14
       Duration  1.11s
    
     Test Files  17 passed (17)
          Tests  205 passed (205)
    
  • Observed result after fix: Streaming and non-streaming assistant bubbles render "Visible answer" / "Done." without the surrounding tags or the in-tag content; tool and user message rendering paths are untouched.
  • What was not tested: A live multi-turn streaming session against google/gemini-flash-3 was not run; this is a UI-side render fix, and the hosted control-ui smoke is covered by CI.

@openclaw-barnacle openclaw-barnacle Bot added app: web-ui App: web-ui size: XS triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI. labels May 5, 2026
@clawsweeper

clawsweeper Bot commented May 5, 2026 •

Copy link
Copy Markdown
Contributor

Thanks for the context here. I swept through the related work, and this is now duplicate or superseded.

Keep open: this targets a real Control UI grouped-render leak, but the branch is conflicting, the proof is still test-only, and the patch should be refreshed to use the shared message extractor instead of adding a partial sanitizer path.

Root-cause cluster
Relationship: fixed_by_candidate
Canonical: #77879
Summary: This PR is a focused candidate fix for the original Control UI think/final tag report; broader gateway history truncation work overlaps in visible scaffolding symptoms but does not replace the grouped-render UI path.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Canonical path: Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

So I’m closing this here because the remaining work is already tracked in the canonical issue.

Review details

Best possible solution:

Close this stale PR. The latest review rated it F, the branch still lacks merge-ready proof, and there has been no human follow-up after the durable review.

Do we have a high-confidence way to reproduce the issue?

Yes, at source level: current main sends streaming and grouped assistant text through renderGroupedMessage, which currently renders normalized text blocks without the shared assistant sanitizer. I did not run a live browser/provider reproduction in this read-only review.

Is this the best way to solve the issue?

No, not as currently shaped. The maintainable fix should use the existing shared message extractor/sanitizer contract so grouped rendering does not create a second assistant-visible-text path.

Security review:

Security review cleared: The diff only changes Control UI text rendering and unit tests; it adds no dependency, workflow, secret, permission, package, or code-execution surface.

AGENTS.md: found and applied where relevant.

What I checked:

  • stale F-rated PR: PR was opened 2026-05-05T19:10:19Z, is older than 60 days, and the latest review rated it F.
  • proof blocker: real behavior proof is mock_only and proof tier is F, so this branch is not merge-ready without contributor follow-up.
  • no human follow-up: live comments and timeline hydrated by apply contain no non-automation activity after the ClawSweeper review.

Likely related people:

  • steipete: CODEOWNERS routes repository ownership to this login, and recent merged commits in the persisted Control UI text-block work touched message extraction and normalization around this display contract. (role: CODEOWNERS-listed owner and feature-history contributor; confidence: high; commits: 6e253792658b, fc9dd3444536, bfe4f67ccf02; files: .github/CODEOWNERS, ui/src/ui/chat/message-extract.ts, ui/src/ui/chat/message-normalizer.ts)
  • mushuiyu886: Authored the merged persisted-history text block fix that changed the same Control UI normalization and extraction boundary used by grouped rendering. (role: recent adjacent contributor; confidence: medium; commits: 1f8dc5939d2b; files: ui/src/ui/chat/message-extract.ts, ui/src/ui/chat/message-normalizer.ts, src/shared/chat-message-content.ts)
  • miyago9267: Authored a closed unmerged PR that proposed routing grouped-render text through the shared extractor for the same scaffolding leak class, including later review feedback about phase handling. (role: prior same-surface PR author; confidence: medium; commits: d45137fdcd8e, e84ec68d6c2f; files: ui/src/ui/chat/grouped-render.ts, ui/src/ui/chat/message-extract.ts)

Codex review notes: model internal, reasoning high; reviewed against 010b61746379.

@Beandon13

Copy link
Copy Markdown
Contributor Author

Heads-up on the failing checks:

  • Real behavior proof (×2): per the policy script, vitest output doesn't count — the bot wants runtime evidence (terminal screenshot, console output, redacted runtime logs) from a real OpenClaw setup. Happy to capture and upload, but will need a maintainer proof: override or environment to record from. Tagging as a body-content gap, not a code regression.
  • checks-node-core-runtime-shared: failures are in src/utils/usage-format.test.ts (pricing/models.json tests — prefers models.json pricing, normalizes open-ended range, resolves tiered pricing). These are unrelated to this PR's ui/src/ui/chat/grouped-render.ts change and look like pre-existing main-branch behavior.
  • check-additional-extension-package-boundary: also unrelated to UI rendering.

The actual fix and its 2 new regression tests pass locally:

pnpm vitest run ui/src/ui/chat/grouped-render.test.ts
Test Files  1 passed (1)
     Tests  37 passed (37)

If a maintainer wants the proof override or a different evidence format, let me know.

renderGroupedMessage reads message.content[].text directly via
normalizeMessage. The streaming bubble feeds raw model output through this
path, and even non-streaming history messages bypass extractText, so any
literal <think>...</think> or <final>...</final> the model emits leaks
into the chat bubble HTML even when thinkingDefault is "off".

This patch runs the assembled assistant text through stripThinkingTags
(internal-scaffolding profile) before it becomes `markdown`. The other
roles (user, tool) keep their existing rendering untouched.

Adds two regression tests against renderGroupedMessage and
renderStreamingGroup confirming both paths now drop those tags.

Closes openclaw#77879
@Beandon13
Beandon13 force-pushed the fix/openclaw-77879-strip-streaming-tags branch from f25a282 to 804dcde Compare May 6, 2026 12:46
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label May 31, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels May 31, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jun 1, 2026
@clawsweeper clawsweeper Bot added rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 1, 2026
@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. and removed rating: 🌊 off-meta tidepool PR readiness rating does not apply to this item. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 14, 2026
@openclaw-barnacle

Copy link
Copy Markdown

This pull request has been automatically marked as stale due to inactivity.
Please add updates or it will be closed.

@openclaw-barnacle openclaw-barnacle Bot added the stale Marked as stale due to inactivity label Jul 20, 2026
@clawsweeper

clawsweeper Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

@Beandon13 thanks for the PR. ClawSweeper is still waiting on real behavior proof before this can move forward.

Useful proof can be a screenshot, short video, terminal output, copied live output, linked artifact, or redacted logs that show the changed behavior after the fix. Please redact private tokens, phone numbers, private endpoints, customer data, and anything else sensitive.

Once proof is added to the PR body or a comment, ClawSweeper or a maintainer can re-check it.

@openclaw-barnacle openclaw-barnacle Bot removed the stale Marked as stale due to inactivity label Jul 21, 2026
@steipete

Copy link
Copy Markdown
Contributor

Closing per ClawSweeper review verdict duplicate_or_superseded (decision packet 2026-07-03T21:06:01.835Z). This item was part of the audited close backlog (openclaw/clawsweeper#920) stranded by an apply-lane defect, drained manually after re-verification. If this is wrong, reopen and ClawSweeper will re-review.

@steipete steipete closed this Jul 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

app: web-ui App: web-ui P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. size: XS status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. triage: mock-only-proof Candidate: PR proof only shows tests, mocks, snapshots, lint, typecheck, or CI.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: <think> and <final> tags appear in openclaw-control-ui even when thinkingDefault is "off".

2 participants