Repository navigation
fix: serialized tool-call XML leaks into chat replies - #138204
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs real behavior proof before merge. What this changesThis PR hides serialized GLM and invocation tool-call XML from streamed and final replies while preserving prose, code examples, and native calls. Example: The assistant emits Visible followed by <tool_call>exec<arg_key>command</arg_key><arg_value>echo hidden</arg_value></tool_call> and Done.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Blocked before merge - 1 item remains Keep this PR open: current main still misses the reported XML dialects, the patch contains useful unique work, and an assigned reviewer is involved; no actionable code defect was found. Priority: P2 Before merge
FindingsNone. Tests
Agent review detailsHow this fits togetherProvider text enters the shared assistant-visible sanitizer, which supplies stream events, block snapshots, and final delivery payloads consumed by chat clients and channel plugins. flowchart LR
A[Provider content] --> B[Shared text sanitizer]
B --> C[Stream projection]
B --> D[Final payload assembly]
C --> E[Gateway chat events]
C --> F[Channel delivery]
D --> F
Technical reviewBest possible solution: Land the shared sanitizer repair after the scoped proof requirement is resolved and the native workflow handles inherited CI failures. Do we have a high-confidence way to reproduce the issue? Current-main source deterministically leaves the reported GLM toolname/arg_key shape unclassified; the linked report and supplied baseline replay corroborate that path, but this review executed no target code. Is this the best way to solve the issue? Extending the existing shared sanitizer addresses the missing grammar at its owner and covers stream and final consumers without executing text as tools or adding a competing reply-token policy. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 9a165c492058. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +186, Tests +319, Docs +1. Total +506 across 16 files. Added test files: 3. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (36 earlier review cycles; latest 8 shown)
Reviewed October 10, 2026, 8:37 PM ET / October 11, 2026, 00:37 UTC (Revision 37). |
sylvesterkaczmarek
left a comment
There was a problem hiding this comment.
The streaming boundary looks correct. Holding an incomplete <tool_call>exec prefix until it can be classified prevents partial leakage, while requiring the wrapped GLM shape avoids stripping literal exec<arg_key> explanations.
|
Addressed the Rank-up moves on 92329ee101a9:
Evidence: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review P1s on
No Telegram Test Server this cycle. Gateway loopback remains the channel-visible substitute; not claimed as Telegram. |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
@clawsweeper re-review Previous exact-review run completed without replacing the durable review. Head is still P1s from that verdict are already in |
|
🦞🧹 I asked ClawSweeper to review this item again. Re-review progress:
|
|
This assigned pull request has been automatically marked as stale after being open for 27 days. |
Keep GLM shadow text and standalone invocation XML in the shared visible-text sanitizer. Hold incomplete stream prefixes, restore finished literal examples, and retain payload context across adjacent native text parts. Preserve prose, code, and native tool execution. Incorporates the distinct invocation cases from openclaw#153635 alongside the GLM repair from openclaw#138204. Thanks @ericcaiwx-star and @ruiling-smartbear. Co-authored-by: Ruilin Gao <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Keep XML context within consecutive text parts, including empty text, and stop it at native tool or thinking blocks in final extraction and block snapshots. Retain the terminal retry and warning assertions with the sanitized payload expectation. Align the QA private-completion projection with the compatible Responses user-role carrier contract merged in openclaw#168546. Keep separate ordered messages and all private nonce, media, and channel-delivery assertions.
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Closes #138198
Related: #153594, #153635
What Problem This Solves
Fixes raw GLM and invocation XML appearing in streamed and final chat replies when a model writes a tool request or a shadow copy as ordinary text.
User Impact
Replies retain visible prose while hiding internal tool XML, including partial streaming prefixes. Completed literal explanations and inline, fenced, or indented code examples remain visible. Native calls continue to execute exactly once. No configuration or migration is required.
Known limitation: artifact-only replies without a native call or visible answer reach the existing empty-reply format failure (
chatstateaborted, no message). The baseline's already-supported JSON envelope reproduces that terminal behavior. Original transcript bytes remain intact.Why This Change Was Made
The existing
assistant-visible-text.tssanitizer owns GLMarg_keypayloads and bare,antml, andmminvocation forms. Stream fallback, block snapshots, and completed payloads consume that owner. It holds ambiguous opening fragments during streaming, restores terminal literals, and carries XML context only across consecutive same-phase text parts, ending it at native tool/thinking blocks.This preserves @ericcaiwx-star's contributor commits and incorporates @ruiling-smartbear's distinct invocation cases with Ruilin Gao's co-author credit. The competing reply-token scanner was not carried forward.
Main
6b8e69e470765791cd8ac91d721b497f9b58948bwas merged without rebasing. The sole conflict uses main's current subagent QA expectation, removing this branch's superseded assertion correction. One additional unused local binding inherited from main was removed to fix core typecheck error TS6133; environment-consuming callers are unchanged. The separately filed Memory QA issue is outside this repair.Evidence
Validation head:
84b0dfe52fbad2bd5c53aa513adf59ec59819d32.The replay uses the built Gateway's real WebSocket
chat.sendentry point and a local OpenAI-compatible SSE fixture provider. It covers GLM shadow text; bare, antml, mm, and plain function_calls wrappers; native exec plus a shadow copy; artifact-only GLM/invoke/legacy JSON; and literal/code controls. Baseline main leaked XML. Candidate reply deltas, snapshots, finals, assistant events, and preambles contain no leaked markup; the native control executes once and returnsXML_PROOF_OK; literal/code examples preserve exact bytes.The campaign lead explicitly accepts this isolated Gateway replay as the required boundary proof and overrides proof-only live-Telegram holds. Live Telegram receipt and live GLM generation are not claimed. ClawSweeper reviewed this exact head on October 11 at 00:07 UTC after the single re-review request: no actionable findings. Its proof-only Telegram hold is lead-overridden. Its remaining request for CI attribution is addressed below.
Inherited Memory QA failure
The lead accepted READY-WITH-INHERITED-QA if the remaining CI failure is
memory-dreaming-sweep, and filed that issue separately. Actual same-environment attribution used the unmodified scenario/planner/model-selection/profile configuration, fresh isolated state, macOS arm64, Node v26.11.1, pnpm12.9.0, and thesmoke-cimock-openai/Crabline Telegram defaults:5eff359970282911ca2d4bf60093423fddd86b5f0e6b2c23c8d55292b67c6835c22c85dec6d0a575Each checkout was built with
OPENCLAW_BUILD_PRIVATE_QA=1 pnpm build qaRuntime, then ranpnpm openclaw --profile <isolated-profile> qa run --repo-root . --qa-profile smoke-ci --concurrency 10 --output-dir <isolated-output> --scenario memory-dreaming-sweep. Matching private-QA flags, a 180000ms transport-readiness setting, separate parent state/config paths, and task TMPDIR were supplied. No model pin, manual retry, or scenario timeout change was used. These local runs establish source attribution; hosted CI uses Linux/Node24.Current exact-head CI run 38096487544 completed with 47 successful jobs and four inherited failed jobs, so the aggregate gate remains red. No rerun was requested. It tested merge
28e7d321bc7595dab322999ac32ca6bcd7351a50against main6cc0e8460192d6dae2f1f3622665755d09b908b7.In addition to the accepted Memory QA failure, the exact executed main independently reproduces all additional failures:
checks-node-compact-small-5: SDK surface budgets fail at exports3672>3656, callables2133>2122, deprecated158>154, and deprecated entrypoint counts1>0/3>0. Main commiteacb83742946(feat(plugin-sdk): add worker-owned conversation binding APIs #168483) added conversation-binding exports without updating the budgets. The same SDK test fails on main in9.27s (two failing assertions; the Linux-only lifetime case is skipped on macOS); its registeredpnpm plugin-sdk:surface:checkcommand separately fails with all five identical messages in4.29s.check-lint-core-2: main'splugin-state-observation-cache.ts:42shadowscacheKey, and line71 has an unnecessary Number conversion.check-lint-core-4: main'ssqlite-worker-plugin-comparison.test.ts:95captures an unbound Worker method. Both lint files came from main01e189266093(perf(plugin-state): reuse committed observations during turns #168635); all three diagnostics reproduce together on exact main in11.99s.The lint reproduction used
node scripts/run-oxlint.mjs --tsconfig config/tsconfig/oxlint.core.json src/plugin-state/plugin-state-observation-cache.ts src/infra/sqlite-worker-plugin-comparison.test.ts. SDK reproduction usednode scripts/run-vitest.mjs test/scripts/plugin-sdk-surface-report.test.ts --maxWorkers=1and the registered command above. All ran with the task TMPDIR on an unmodified checkout of the exact CI main base, after restoring its pinned dependencies. These failed files are outside the PR diff. No budget expansion, lint suppression, or unrelated repair was added. The inherited-only CI exception remains the lead's landing decision; this is not a green-gate claim.Captured final-head Gateway audit excerpt:
{"id": "glm", "state": "final", "finalText": "Visible\n\nDone.", "leakedSurfaces": {}, "toolStarts": 0} {"id": "native", "state": "final", "finalText": "Done.", "leakedSurfaces": {}, "toolStarts": 1} {"id": "glmonly", "state": "aborted", "finalText": "", "leakedSurfaces": {}, "toolStarts": 0}