Skip to content

fix: sanitize streamed assistant payload text - #101036

Merged
steipete merged 2 commits into
openclaw:mainfrom
velanir-ai-manager:fix/strip-minimax-thinking-tags-upstream
Jul 6, 2026
Merged

steipete merged 2 commits into
openclaw:mainfrom
velanir-ai-manager:fix/strip-minimax-thinking-tags-upstream

Conversation

@velanir-ai-manager

@velanir-ai-manager velanir-ai-manager commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

DeepInfra MiniMax can emit provider-hidden reasoning markers such as </mm:think> as ordinary assistant text. Streamed assistant text then reaches embedded-run payload construction without the canonical visible-text sanitizer, so cron summaries or channel reply payloads can expose those markers to users.

Why This Change Was Made

OpenClaw already has a canonical assistant visible-text sanitizer that strips reasoning tags, tool scaffolding, and internal markers. This change applies that sanitizer to streamed assistantTexts before they are selected for embedded-run reply payloads, so the payload path matches the existing final-assistant extraction path.

User Impact

Users should no longer see MiniMax-style </mm:think> markers in cron output, Teams/Slack replies, or other embedded-run payload replies when a provider leaks those markers as plain text. Silent replies and empty sanitized text remain suppressed.

Evidence

  • Added regression coverage for streamed assistant text starting with </mm:think>.
  • Verified locally with:
    • node scripts/run-vitest.mjs src/agents/embedded-agent-runner/run/payloads.test.ts
    • Result: 42 passed
  • Redacted Teams verification:
    • Before: leaked provider reasoning close tag rendered in a visible assistant reply.
    • After: visible reply no longer includes the reasoning close tag.

Before: reasoning close tag leaked in Teams

After: clean Teams response

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Jul 6, 2026
@velanir-ai-manager

Copy link
Copy Markdown
Contributor Author

Redacted Teams verification for this sanitizer path:

Before / failing behavior

A provider reasoning close tag rendered inside the visible assistant reply.

Before: reasoning close tag leaked in Teams

After / fixed behavior

The visible Teams reply no longer includes the reasoning close tag.

After: clean Teams response

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Jul 6, 2026
@clawsweeper

clawsweeper Bot commented Jul 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed July 6, 2026, 6:06 PM ET / 22:06 UTC.

Summary
The PR maps streamed embedded-run assistant texts through sanitizeAssistantVisibleStreamText before payload selection and adds regression tests for MiniMax reasoning tags, hidden-only streams, tool-call scaffolding, and media directives.

PR surface: Source +3, Tests +42. Total +45 across 2 files.

Reproducibility: yes. Current main accepts raw streamed assistantTexts at the embedded payload boundary, and the PR proof shows the leaked MiniMax close tag in a real Teams reply before the fix.

Review metrics: none identified.

Merge readiness
Overall: 🦞 diamond lobster
Proof: 🦞 diamond lobster ✨ media proof bonus
Patch quality: 🦞 diamond lobster
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Next step before merge

  • [P2] No repair lane is needed because the active PR already contains the narrow code change, tests, and real behavior proof.

Security
Cleared: The diff only applies an existing sanitizer and adds focused tests; it does not change dependencies, workflows, secrets, package metadata, or code execution surfaces.

Review details

Best possible solution:

Merge the narrow payload-boundary sanitizer fix after normal exact-head gates, keeping the shared assistant visible-text sanitizer as the single cleanup path.

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

Yes. Current main accepts raw streamed assistantTexts at the embedded payload boundary, and the PR proof shows the leaked MiniMax close tag in a real Teams reply before the fix.

Is this the best way to solve the issue?

Yes. Reusing the existing stream-visible sanitizer at the embedded payload boundary is narrower and more maintainable than adding provider- or channel-specific filtering.

AGENTS.md: found and applied where relevant.

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

Label changes

Label justifications:

  • P2: The PR fixes a user-visible assistant text leak in embedded/channel replies, but the patch is narrow and does not indicate a core outage.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (screenshot): The PR includes inspected redacted Teams before/after screenshots showing the leaked reasoning close tag before the change and a clean visible reply after it.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR includes inspected redacted Teams before/after screenshots showing the leaked reasoning close tag before the change and a clean visible reply after it.
  • proof: 📸 screenshot: Contributor real behavior proof includes screenshot evidence. The PR includes inspected redacted Teams before/after screenshots showing the leaked reasoning close tag before the change and a clean visible reply after it.
Evidence reviewed

PR surface:

Source +3, Tests +42. Total +45 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 4 1 +3
Tests 1 42 0 +42
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 46 1 +45

What I checked:

Likely related people:

  • zhangguiping-xydt: Merged PR fix(feishu): avoid mention forwarding when bot open id is unavailable #100891 and current blame carry the present buildEmbeddedRunPayloads module through commit f805bb4e0255b1d16543213f01b47cd0a91ea791. (role: recent area contributor; confidence: medium; commits: f805bb4e0255; files: src/agents/embedded-agent-runner/run/payloads.ts, src/agents/embedded-agent-utils.ts)
  • vincentkoc: Merged and added follow-up coverage for the MiniMax mm: reasoning-tag sanitizer work that this PR reuses. (role: reasoning-tag sanitizer merger; confidence: medium; commits: 5a5fbe17ce6b, d4bf2bad8f82; files: src/shared/text/reasoning-tags.ts)
  • steipete: Merged the current-path carrier PR, is assigned on this PR, and authored the latest regression-test commit on the branch. (role: recent merger and adjacent owner; confidence: medium; commits: f805bb4e0255, 646d4ffc9afe; files: src/agents/embedded-agent-runner/run/payloads.ts, src/agents/embedded-agent-runner/run/payloads.test.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

How this review workflow works
  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.
Review history (1 earlier review cycle)
  • reviewed 2026-07-06T18:01:20.379Z sha fd815023b3d750d28e71229a15df03deec87469b :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. P2 Normal backlog priority with limited blast radius. labels Jul 6, 2026
@steipete steipete self-assigned this Jul 6, 2026
@steipete
steipete force-pushed the fix/strip-minimax-thinking-tags-upstream branch from fd81502 to 646d4ff Compare July 6, 2026 21:44
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Land-ready evidence:

  • Best-fix review: final payload assembly now uses the same stream-owned user-facing sanitizer as the live subscription path. Regression coverage includes orphan reasoning close tags, hidden-only output, every item in a multi-text reply, tool-call scaffolding, and media-directive preservation.
  • Final branch autoreview: clean, no actionable findings.
  • Maintainer commands: .agents/skills/autoreview/scripts/autoreview --mode branch --base origin/main --model gpt-5.5 --thinking high; scripts/pr review-validate-artifacts 101036; OPENCLAW_TESTBOX=1 scripts/pr prepare-run 101036.
  • Exact-head hosted proof: release gate 28827542065 passed all 109 jobs at 646d4ffc9afea196b610eb9783b48ee1e54a9425.
  • Before/after proof: the contributor-provided Teams screenshots in the PR demonstrate that the leaked provider marker is removed while the visible answer remains.
  • Known proof gap: a dedicated sanitized AWS lease remained capacity-queued for ten minutes and was cancelled before any PR code ran. The exact-head hosted release-gate matrix completed successfully.

@steipete
steipete merged commit 8d46971 into openclaw:main Jul 6, 2026
208 checks passed
@steipete

steipete commented Jul 6, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Jul 7, 2026
* fix: sanitize streamed assistant payload text

* test(agents): cover streamed reply sanitization

---------

Co-authored-by: Yash Inani <[email protected]>
Co-authored-by: Peter Steinberger <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling P2 Normal backlog priority with limited blast radius. proof: 📸 screenshot Contributor real behavior proof includes screenshot evidence. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants