Skip to content

fix(text): hide encoded MiniMax tool envelopes - #126307

Merged
obviyus merged 7 commits into
openclaw:mainfrom
zhucegep:agent/fix-minimax-encoded-tool-call-leak
Sep 11, 2026
Merged

obviyus merged 7 commits into
openclaw:mainfrom
zhucegep:agent/fix-minimax-encoded-tool-call-leak

Conversation

@zhucegep

@zhucegep zhucegep commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

MiniMax can emit internal tool XML as assistant text with interleaved ]<]minimax[>[ transport markers. Those markers prevent the existing XML filter from recognizing the payload, which exposes internal text in channel replies and public shared-session history.

Recognize complete encoded envelopes at the shared visible-text boundary, then apply the existing XML cleanup. Ignore opening and closing markers inside code examples. Stop the closing-marker search once it reaches the end of incomplete input. The integration preserves current main's streaming projection and existing tests.

Evidence

  • Real Telegram Test Server: reproduced marker and internal-payload leakage on pinned main; the candidate removes complete envelopes and preserves surrounding text.
  • The same 11-case flow preserves inline/fenced examples, standalone markers, incomplete input, ordinary MiniMax cleanup, and unrelated prose.
  • Public shared-session HTML shows the same corrected results; all temporary shares return 404 after revocation.
  • A structured read call returns its actual result, and generic XML cleanup works after switching to another provider fixture.
  • Focused sanitizer, projection, extraction, and renderer coverage passes (239 cases), with formatting and static checks. The final 12-case scanner suite also passes type-aware lint.
  • Restoring the former incomplete-scan branch fails at 256 closing searches; the repaired branch passes with one search.

Channel proof uses synthetic HTTP provider responses and real Telegram transport. Full type checks and suites run in hosted CI. Test messages, temporary shares, Gateway processes, and credential leases were cleaned up.

AI-assisted.

@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. labels Aug 19, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 11, 2026, 7:01 AM ET / 11:01 UTC (Revision 13).

ClawSweeper review

What this changes

The PR removes complete encoded MiniMax tool-call envelopes from assistant replies and shared history while preserving code examples and surrounding prose.

Merge readiness

✅ Ready for maintainer review

This remains a useful fix absent from current main and v2026.9.4. The previous code concerns and PR-body follow-up are addressed; no blocking introduced defect was found.

Priority: P2
Reviewed head: cbe73a9c7a547fdcfd75dda1e0568694be72324e

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused repair with relevant runtime observations and regression coverage; prior actionable feedback is resolved.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The supplied Telegram Test Server observations exercise the shared sanitizer through real channel transport and report removal of complete encoded payloads with surrounding text preserved; public-share HTML observations cover the history consumer. Synthetic provider responses make this boundary proof, not a live MiniMax service test.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied Telegram Test Server observations exercise the shared sanitizer through real channel transport and report removal of complete encoded payloads with surrounding text preserved; public-share HTML observations cover the history consumer. Synthetic provider responses make this boundary proof, not a live MiniMax service test.
Evidence reviewed 8 items Verified patch scope: The complete host-provided merge-base-to-head patch changes the shared sanitizer and two regression-test files. Local comparison confirms the production delta is the encoded-envelope handling; unrelated endpoint drift was excluded.
Current main and release still need the fix: Current main retains the minimax:tool_call-only early check, and v2026.9.4 has the same limitation. Interleaved transport markers prevent the subsequent generic XML filter from recognizing the nested payload.
Existing sanitizer owner and downstream consumers: The MiniMax transform runs before generic tool XML cleanup. The public renderer uses the history profile, while Telegram's outbound adapter and assistant stream projection consume the same shared sanitizer. No Codex dependency contract is involved in the introduced change.
Findings None None.
Security None None.

How this fits together

OpenClaw’s shared text sanitizer turns model-generated assistant text into visible replies and history. Telegram delivery and public shared-session rendering consume this sanitized text.

flowchart TD
  A[Assistant text] --> B[Shared text sanitizer]
  B --> C{Complete encoded envelope outside code?}
  C -->|Yes| D[Normalize envelope and remove tool XML]
  C -->|No| E[Preserve existing text handling]
  D --> F[Visible assistant text]
  E --> F
  F --> G[Channel replies]
  F --> H[Public shared history]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +38, Tests +142. Total +180 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 1 43 5 +38
Tests 2 142 0 +142
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 185 5 +180

Review metrics

None.

Technical review

Best possible solution:

Keep encoded-envelope recognition in the existing shared sanitizer, preserving literal examples, incomplete-input behavior, and structured tool dispatch.

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

Yes: current source shows why interleaved MiniMax markers bypass tool-payload recognition, and the supplied Telegram observations report the same failure. This read-only review did not execute target code.

Is this the best way to solve the issue?

Yes: extending the existing MiniMax sanitizer before generic XML cleanup repairs both delivery and history without adding a competing parser owner or configuration surface.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 227e7ae26af4.

Labels

Label justifications:

  • P2: This repairs a bounded model-output formatting defect affecting replies and shared history.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied Telegram Test Server observations exercise the shared sanitizer through real channel transport and report removal of complete encoded payloads with surrounding text preserved; public-share HTML observations cover the history consumer. Synthetic provider responses make this boundary proof, not a live MiniMax service test.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied Telegram Test Server observations exercise the shared sanitizer through real channel transport and report removal of complete encoded payloads with surrounding text preserved; public-share HTML observations cover the history consumer. Synthetic provider responses make this boundary proof, not a live MiniMax service test.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. The sanitizer changes visible Telegram replies; the supplied Test Server observations cover that behavior.

Evidence

What I checked:

  • Verified patch scope: The complete host-provided merge-base-to-head patch changes the shared sanitizer and two regression-test files. Local comparison confirms the production delta is the encoded-envelope handling; unrelated endpoint drift was excluded. (src/shared/text/assistant-visible-text.ts:514, cbe73a9c7a54)
  • Current main and release still need the fix: Current main retains the minimax:tool_call-only early check, and v2026.9.4 has the same limitation. Interleaved transport markers prevent the subsequent generic XML filter from recognizing the nested payload. (src/shared/text/assistant-visible-text.ts:514, 3a9d69db306c)
  • Existing sanitizer owner and downstream consumers: The MiniMax transform runs before generic tool XML cleanup. The public renderer uses the history profile, while Telegram's outbound adapter and assistant stream projection consume the same shared sanitizer. No Codex dependency contract is involved in the introduced change. (src/shared/text/assistant-visible-text.ts:807, cbe73a9c7a54)
  • Prior findings resolved: Opening and closing markers inside code regions are ignored, complete envelopes containing protected examples are removed as a unit, and an exhausted closing search breaks immediately. Regression coverage includes these cases, three visible-text profiles, streaming replacement, and public HTML suppression. (src/shared/text/assistant-visible-text.minimax.test.ts:49, cbe73a9c7a54)
  • Supplied real behavior observations: The captured PR body reports an 11-case Telegram Test Server run using synthetic HTTP provider responses and real Telegram transport: main leaked encoded payloads, while the candidate removed complete envelopes and preserved prose and examples. It also reports corrected public-share HTML, revoked shares returning 404, and a working structured read call. These are supplied runtime observations, not executions performed during this review. Source revision: ed8d00c20acefcd9854be844037e131f89ec1effb059af9b4e5e86f874efa759.
  • Re-review continuity: The previous completed review covered the same head and requested the What Problem This Solves and Evidence headings. Both are present in the captured body, so that follow-up is resolved. (cbe73a9c7a54)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • obviyus: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

  • 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.

History

Review history (12 earlier review cycles; latest 8 shown)
  • reviewed 2026-08-23T05:33:23.567Z sha 818f62f1e4774fa36e9661fb20392e051df376b2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-23T05:52:04.016Z sha 818f62f1e4774fa36e9661fb20392e051df376b2 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-24T01:14:14.603Z sha 6d2d335c7e2001b2e194bd2ac1e662ae52239844 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-25T01:15:46.301Z sha edb914cf0522fe3f2aa2b0005b81865f15d201ca :: needs changes before merge. :: [P2] Keep encoded envelope matching out of code regions
  • reviewed 2026-08-26T01:13:23.722Z sha b6da27e2cd0f946317e25c42a694666725e213dd :: needs maintainer review before merge. :: none
  • reviewed 2026-09-03T08:00:51.554Z sha 57dca21 :: blocked before merge. :: [P2] Stop rescanning incomplete encoded envelopes
  • reviewed 2026-09-06T01:13:15.851Z sha 40bf18a :: blocked before merge. :: none
  • reviewed 2026-09-11T10:50:59.660Z sha cbe73a9 :: needs changes before merge. :: none

@zhucegep
zhucegep force-pushed the agent/fix-minimax-encoded-tool-call-leak branch from c9c6481 to 818f62f Compare August 20, 2026 07:57
@openclaw-barnacle openclaw-barnacle Bot removed the agents Agent runtime and tooling label Aug 20, 2026
@zhucegep
zhucegep marked this pull request as ready for review August 20, 2026 07:58
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 20, 2026
@zhucegep

Copy link
Copy Markdown
Contributor Author

Rebased onto current main, ported the fix to the shared code-region-aware sanitizer, added redacted terminal behavior proof to the PR body, and verified 127/127 targeted tests plus clean autoreview. @clawsweeper re-review

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 20, 2026
@zhucegep

Copy link
Copy Markdown
Contributor Author

Exact-head CI for 818f62f1e4774fa36e9661fb20392e051df376b2 is now complete and green, including openclaw/ci-gate. ClawSweeper has also marked the proof sufficient and the PR ready for maintainer review.

@clawsweeper clawsweeper Bot added mantis: telegram-visible-proof Mantis should capture Telegram visible proof. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Aug 23, 2026
@zhucegep

Copy link
Copy Markdown
Contributor Author

Addressed the latest ClawSweeper compatibility concern in 6d2d335c: encoded MiniMax delimiters are now normalized only inside a complete encoded <tool_call> envelope, while standalone literal delimiters are preserved. Verified with node scripts/run-vitest.mjs src/shared/text/assistant-visible-text.test.ts (129 passed) and the required autoreview (clean). The local changed-file gate reached an unrelated assertion-SAFETY baseline drift outside this PR; conflict-marker and max-lines checks passed. @clawsweeper re-review

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Aug 24, 2026
@zhucegep

Copy link
Copy Markdown
Contributor Author

Fixed the current-head max-lines CI failure in check-lint-core-1.

The stripToolCallXmlTags cases now live in assistant-visible-text.tool-calls.test.ts, keeping the original focused sanitizer test file at 985 lines without changing production behavior or coverage.

Validation:

  • node scripts/run-vitest.mjs src/shared/text/assistant-visible-text.test.ts src/shared/text/assistant-visible-text.tool-calls.test.ts (129 passing)
  • git diff --check
  • check-changed reached the known unrelated assertion-SAFETY baseline drift; the max-lines ratchet passed.

The prior current-head core-test failure remains an unrelated timing miss in src/audit/audit-event-writer.test.ts (266.9ms vs 250ms). New CI is now running on edb914cf.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 25, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. label Sep 6, 2026
@obviyus obviyus self-assigned this Sep 11, 2026
Normalize complete encoded envelopes at the shared visible-text boundary while
preserving code examples, incomplete input, and structured tool dispatch.
Retain current streaming projection and history behavior when integrating the
contributor fix.
@obviyus
obviyus requested review from a team and steipete as code owners September 11, 2026 10:15
@obviyus obviyus changed the title fix: strip encoded Minimax tool-call XML fix(text): hide encoded MiniMax tool envelopes Sep 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. triage: refactor-only Candidate: refactor/cleanup-only PR without maintainer context. labels Sep 11, 2026
@github-actions

github-actions Bot commented Sep 11, 2026 •

Copy link
Copy Markdown
Contributor

Security-sensitive guard cleared

This PR no longer has blocked security-sensitive file changes. A future security-sensitive change requires a fresh /allow-security-sensitive-change comment after the guard blocks that new head SHA.

  • Current SHA: cbe73a9c7a547fdcfd75dda1e0568694be72324e

@github-actions github-actions Bot added dependencies-changed PR changes dependency-related files and removed security-sensitive-changed labels Sep 11, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S and removed size: XL labels Sep 11, 2026
@github-actions github-actions Bot removed the dependencies-changed PR changes dependency-related files label Sep 11, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Sep 11, 2026
@obviyus
obviyus merged commit fe286b4 into openclaw:main Sep 11, 2026
225 of 227 checks passed
@obviyus

obviyus commented Sep 11, 2026

Copy link
Copy Markdown
Collaborator

Thanks @zhucegep!

Proof: Real Telegram Test Server messages and public shared-session history show the encoded payload leak before the fix and clean replies after it. Synthetic HTTP provider responses exercise the same 11-case flow, including code examples, incomplete input, and an actual structured read result.

  • Bug: Interleaved MiniMax transport markers prevented the shared XML filter from recognizing internal tool text.
  • Fix: Recognize complete envelopes outside code, retain the existing shared cleanup pipeline, and stop after an exhausted closing-marker search.
  • Validation: 239-case focused coverage, the revised 12-case scanner suite and type-aware lint, fresh independent behavior acceptance, clean exact-head ClawSweeper review, and green hosted CI.
  • Cleanup: Temporary public shares were revoked; all test messages were deleted or verified absent; proof consumers and credential leases closed.
Before After
Internal encoded tool text appears in Telegram and public history. Only the intended surrounding prose remains.
Literal inline/fenced examples and structured tools work. Those controls continue to work.

Final hosted CI passed on cbe73a9c7a547fdcfd75dda1e0568694be72324e.

vincentkoc added a commit that referenced this pull request Sep 11, 2026
Preserve the reviewed harness while incorporating the landed benchmark prerequisite.

Punchcard-Session: coral-orchard-orchard-d4

* commit '4407ed19ac63b1c1c84a0cfe6eb4bbeca9c2322c': (1196 commits)
  fix(perf): isolate benchmark subprocess transport (#144159)
  refactor(auth): await Copilot cache persistence (#144810)
  refactor(web-fetch): exercise URL normalization through the public tool (#144887)
  fix(ollama): preserve hosted subdomain model context (#144891)
  fix(doctor): explain Codex plugin health failures (#144813)
  fix(channels): honor pinned accounts in Mattermost model menus (#144880)
  fix(update): failed-update records hide the triggering error behind the excerpt tail (#144729)
  fix(logging): preserve OpenClaw package references in diagnostics (#144808)
  fix: retain plugin detail tab selections while inspection loads (#144647)
  fix: keep discovered models when sign-in tokens renew (#144861)
  fix(update): preserve local package overrides (#89985)
  fix(update): resolve compatibility bridges within the runtime graph (#144831)
  chore(i18n): refresh native locales (#144856)
  fix: preserve child signal termination during CLI respawn (#144838)
  fix(text): hide encoded MiniMax tool envelopes (#126307)
  fix(subagents): deliver child replies that match the empty placeholder (#130647)
  fix(cli): reject blank message channel selectors (#144802)
  fix(telegram): preserve mixed text order and pending stop (#144839)
  fix(memory): restore FTS fallback for same-name view collisions (#144783)
  chore(release): close out 2026.9.4 on main (#144708)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 12, 2026
Remove complete encoded MiniMax internal tool envelopes from delivered replies and public shared-session history while preserving code examples and incomplete input. Keep the repair at the shared visible-text owner and preserve current streaming projection behavior.

Validated with real Telegram Test Server baseline/candidate flows, shared-history captures and revocations, a structured read control, 239 focused tests, and static checks.

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

Labels

gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. triage: dirty-candidate Candidate: broad unrelated surfaces; may need splitting or cleanup. triage: refactor-only Candidate: refactor/cleanup-only PR without maintainer context.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants