Skip to content

fix: tool call text no longer leaks into chat output when provider chunks split a call marker - #169172

Merged
steipete merged 10 commits into
openclaw:mainfrom
JasonBuildAI:fix/plain-text-tool-call-stream-leak-k3f9
Oct 14, 2026
Merged

steipete merged 10 commits into
openclaw:mainfrom
JasonBuildAI:fix/plain-text-tool-call-stream-leak-k3f9

Conversation

@JasonBuildAI

@JasonBuildAI JasonBuildAI commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #169161

What Problem This Solves

Fixes: serialized tool-call syntax appears briefly in replies when a provider splits a stream inside a function or Harmony marker.

User Impact

The covered marker splits now produce the same visible text as one-chunk delivery. Literal text, reasoning order, content indexes, terminal snapshots, and the existing request-scoped tool allowlist remain intact. No configuration or prompt changes are required.

Pre-existing limitation: arbitrary malformed false-prefix/cumulative-snapshot replay and the disclosed two-space indentation case are not claimed to be universally chunk invariant. No live Telegram send/receive proof is claimed. ClawSweeper accepts the macOS SSE/Gateway evidence for this unchanged transport path.

Why This Change Was Made

Keep unfinished candidate tails buffered until the existing grammar can decide them. The contributor's replay accounting preserves each content block's offset and interleaves retained reasoning when a decided prefix is replayed. The existing oversized-payload suppression state machine is extracted into a sibling module so the coordinator does not grow past the current line-cap ratchet; its byte bound and behavior are unchanged.

Thanks @JasonBuildAI for the original repair and regression cases. All contributor commits are preserved, followed by a merge from current main and the focused extraction/test follow-up.

Evidence

macOS arm64, isolated state/config/workspace, loopback fixture and Gateway only; shared Ollama models were left loaded.

  • Current-main baseline 976cc974fab1912c696d1101bd17a1abf05eb77e: real OpenAI-compatible SSE transport through the production agent wrapper emits no visible text for an unsplit call sequence, but leaks the second call for splits inside <function=, <|channel|>, and <|channel|>comm. Terminal messages agree on two parsed read calls. Through a real isolated Gateway, the split function appears in an assistant event before a later replacement clears it; the durable transcript retains the two parsed calls. The empty second call is rejected for missing arguments, rather than executing another action.
  • Baseline regressions: 12 failed / 53 passed on main using the contributor test file (61.48 s command wall time). After merging main, 67 focused tests pass: 58 normalizer cases plus 9 production-wrapper buffering/adjacency cases (170.21 s command wall; 5.34 s normalizer file, 137.31 s wrapper files dominated by cold transformation; individual wrapper tests 3–6 ms). Added coverage checks every split inside both opening markers and explicit expected visible text for cumulative snapshots.
  • Exhaustive opening-marker split probe: baseline leaks at 9/14 function positions and 17/20 Harmony positions; this head leaks at 0/14 and 0/20.
  • Independent Codex review of 6caf20c659cac6efa86f143912f2b5ae44167913: scoped-clean, no actionable P0–P2 findings.
  • A real Ollama qwen3:4b turn through the Gateway returned a complete sentence without tools in 46.19 s on the baseline. This is inference control; scripted SSE establishes the malformed-byte regression.

Runtime proof (6caf20c659cac6efa86f143912f2b5ae44167913; unchanged at final head b593f059b977ecb0aeb3b97f7edc40555734406d):

  • The real compatible transport emits no marker text for all three split shapes. With reasoning enabled, the wire replay preserves [read] → thinking checking → newline in arrival order, with the same terminal content.

  • A built, isolated Gateway emits only Fixture complete. for unsplit (8.990 s), split function (4.719 s), split channel (0.473 s), and split commentary (0.637 s); all retain two parsed read calls in history. The replay control retains [read] without leaking the incomplete function (0.402 s). A real Ollama qwen3:4b turn completes through that Gateway in 22.295 s with no tools. These timings include RPC/history work and are not performance comparisons.

  • OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm build passed in 8m24.6s, including bundled-plugin, CLI import, and runtime postbuild checks. The full declaration-bundle attempt was intentionally stopped during its slow shared-package phase; standalone pnpm tsgo:core and a scoped test typecheck both pass.

  • Scoped type-aware lint and formatting pass. Max-lines, line-cap, assertion-safety, timeout-race, mock-export, config-docs, and plugin-inventory ratchets pass without baseline changes.

  • Initial exact-head CI 38504961005 found the new suppression helper missing from the archived PR-wrapper inventory. The follow-up registers that file. The contributor independently added the identical inventory fix in b593f059b977ecb0aeb3b97f7edc40555734406d, which is retained. Its Git tree matches the locally tested correction exactly. Both failing eager-import-closure tests pass (2/2 selected; 46.95 s command wall, 37.08 s Vitest duration). This follow-up changes only inventory metadata, so the runtime proof above is reused. ClawSweeper’s review of 6caf20c accepts the Mac SSE/Gateway proof and identifies only this inventory omission; that finding is repaired by the retained contributor commit. Corrected-head CI 38507202210 passes, including openclaw/ci-gate. ClawSweeper reviewed exact head b593f059b977ecb0aeb3b97f7edc40555734406d: ready for maintainer review, zero findings, no before-merge items. No earlier-head green result is reused.

  • Independent Codex review of final head b593f059b977ecb0aeb3b97f7edc40555734406d: scoped-clean, no actionable P0–P2 findings.

Production: +674 / -369 lines (net +305); tests: +168 / -0; wrapper inventory: +1 / -0. The added replay accounting is retained because removing it reintroduces observed loss of reasoning, block indexes, or cumulative-snapshot text. The extraction satisfies the per-file ratchet without weakening it; no unrelated code was deleted to disguise the net growth. No dependency, public API, prompt, config, or stored-transcript format changes.

…l marker

A buffered tail that is still an unfinished call marker ("<funct", "<|channel|>")
was replayed as a false-positive prefix when a complete call preceded it, so the
rest of the call arrived mid-buffer and was emitted as visible text. Hold the
buffer while the tail can still complete into a call, replay only decided
false-positive prefixes, and route trim bookkeeping through one helper so the
done/error/EOF paths share the same chunk-independent decision.

Regression tests cover a replayed false prefix, a stacked function call, and a
stacked Harmony call split across chunks.

Refs openclaw#169161
@clawsweeper

clawsweeper Bot commented Oct 11, 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.

JasonBuildAI added a commit to JasonBuildAI/openclaw that referenced this pull request Oct 11, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: telegram-e2e This PR needs Telegram Test Server proof with the repository E2E skill. 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 Oct 11, 2026
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR buffers split tool-call markers and preserves visible text, reasoning order, and content-block offsets during replay.

Example: A provider sends [tool:read]\n{"path":"a"}&lt;funct followed by ion=read>&lt;/function>.

  • Before: The second call appears as &lt;function=read>&lt;/function> in streamed chat text.
  • After: Both serialized calls remain hidden from streamed chat text.

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Focused, useful repair with shipped-entry-point evidence, exact-head green gates, and no outstanding findings.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): Supplied isolated macOS SSE and built-Gateway runs exercise the changed normalizer through the production wrapper, show no marker text for the three split shapes, and preserve parsed calls and reasoning order; the final inventory-only commit permits reuse of that runtime proof.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Users briefly see serialized tool-call syntax when provider chunks divide a call marker.
Reason: The patch restores the existing hidden-call contract for the reported marker splits, with owner involvement and production-path evidence.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a concrete current-main output defect, the supplied production-path proof covers the repair, and all prior findings are addressed.

Priority: P2
Reviewed head: b593f059b977ecb0aeb3b97f7edc40555734406d

Before merge

None.

Findings

None.

Agent review details

How this fits together

The shared tool-call repair package receives provider text and lifecycle events, applies the existing request-scoped grammar, and emits sanitized stream events and normalized terminal messages.

flowchart TD
  A[Provider SSE chunks] --> B[Provider stream wrapper]
  B --> C[Shared stream normalizer]
  C --> D[Canonical call grammar]
  C --> E[Bounded suppression]
  C --> F[Visible text and reasoning]
  C --> G[Normalized terminal message]
Loading

Technical review

Best possible solution:

Land the focused shared-normalizer repair while retaining the existing grammar, request tool allowlist, and bounded suppression contract.

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

Yes: current-main classification exposes the unfinished suffix for the reported two-chunk input, and supplied SSE/Gateway baseline results independently demonstrate that path; this review ran no target code.

Is this the best way to solve the issue?

Yes: the repair changes the shared classification owner and preserves replayed text and reasoning rather than filtering leaked output downstream.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Shared serialized-call normalization keeps the original intent (3ea9115: Consolidate provider and embedded repair into one internal package while preserving argument bytes and the SDK facade.)
  • Bounded suppression and ordered projection keeps the original intent (05ebaf4: Keep incomplete and oversized known calls hidden while preserving literal text, native blocks, and stable content indexes.)
  • Wrapper source inventory keeps the original intent (unknown: Current wrapper documentation requires the inventory to remain closed over runtime imports; the new entry satisfies that contract.)

Testing

Proof path: shipped entry point.

Security

None.

Evidence

What I checked:

  • Current-main defect remains: Current main strips a leading complete call and immediately exposes the remaining suffix without checking whether that suffix is an unfinished marker. (packages/tool-call-repair/src/stream-normalizer.ts:847, 229125877639)
  • Introduced repair: The pinned introduction diff adds unfinished-tail buffering, block-local replay accounting, auxiliary-event ordering, and a mechanical extraction of the existing suppression state machine. (packages/tool-call-repair/src/stream-normalizer.ts:798, b593f059b977)
  • Production boundary: The provider wrapper passes the request's tool-name matcher and CommonMark protection resolver to the shared normalizer; promotion and terminal authorization conditions remain unchanged. (src/plugin-sdk/provider-stream-shared.ts:140, b593f059b977)
  • Runtime evidence: The full PR body records isolated macOS arm64 runs through the real compatible SSE transport and built Gateway: function, channel, and commentary splits emit only Fixture complete., preserve two parsed read calls, and retain reasoning replay order. Runtime proof at 6caf20c is reusable because the final commit changes only inventory metadata. (b593f059b977)
  • Prior inventory finding repaired: The final commit registers the extracted suppression module in the wrapper inventory, closing the introduced runtime import dependency. (scripts/pr-lib/wrapper-components.txt:2199, b593f059b977)
  • Exact-head CI: GitHub reports successful dependency-review, security-sensitive-review, and ci-gate statuses for the reviewed head; the cited corrected-head CI run also completed successfully. (b593f059b977)

PR surface

Source +305, Tests +168, Other +1. Total +474 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 674 369 +305
Tests 1 168 0 +168
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 0 +1
Total 4 843 369 +474

Review metrics

Metric Value Why it matters
Production versus regression coverage Production +674/-369; tests +168/-0 The net production growth supports observed replay-order and block-offset failures; suppression extraction preserves existing behavior, and added tests use independent visible-output expectations.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.
  • remove merge-risk: 🚨 automation: Current PR review selected no merge-risk labels.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: Deterministic provider chunk splits expose serialized tool syntax in replies without making the core runtime unavailable.
  • 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.
  • proof: sufficient: Contributor real behavior proof is sufficient.
  • proof: telegram-e2e: This PR needs Telegram Test Server proof with the repository E2E skill. Suppressing leaked marker text changes replies that Telegram's Test Server can observe; supplied proof covers the shared Gateway path and claims no Telegram run.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (6 earlier review cycles)
  • reviewed 2026-10-11T15:05:23.339Z sha 37ff20e :: needs real behavior proof before merge. :: [P2] Drain auxiliary events before terminal trimming clears them | [P2] Replay each prefix segment at its original content index | [P2] Preserve text and reasoning order during prefix replay
  • reviewed 2026-10-11T16:28:01.628Z sha b325652 :: needs real behavior proof before merge. :: [P2] Drain auxiliary events before terminal trimming clears them | [P2] Replay each prefix segment at its original content index | [P2] Preserve text and reasoning order during prefix replay
  • reviewed 2026-10-11T18:11:14.739Z sha f865603 :: needs real behavior proof before merge. :: [P2] Keep the trimmed snapshot offset local to the retained block
  • reviewed 2026-10-11T18:30:55.749Z sha 9d7d80a :: needs real behavior proof before merge. :: none
  • reviewed 2026-10-14T03:20:08.780Z sha 6caf20c :: needs changes before merge. :: [P2] [P2] Include the suppression module in the PR wrapper inventory
  • reviewed 2026-10-14T03:44:46.436Z sha b593f05 :: needs maintainer review before merge. :: none

Reviewed October 14, 2026, 12:09 AM ET / 04:09 UTC (Revision 7).

The split-marker buffering added in the previous commit diverged from the
unsplit stream when an authoritative text_end extended the same content block
("hello\n[read]\n{}\nX\n  " lost the call placeholder). Classify
delta-path buffers with the same finalize context as snapshots, keep the block
offset when a text_end extends a buffered snapshot, and track per-content-index
consumed input length so non-authoritative replays slice from the right origin.

Adds three regression tests (plain text and Harmony, delta and text_end split
shapes); stream-normalizer suite 58/58 and packages/tool-call-repair +
normalization-core 445/445 pass, fuzz seed=1 20k iters failures 71 -> 56 and
leakToSplit 18 -> 10 versus the previous commit.

Refs openclaw#169161
The previous uploads kept a CRLF final newline captured from the local
working copy; the repository stores these files as LF, so the PR diff
picked up a spurious trailing-line change on both files. No code changes.

Refs openclaw#169161
check-lint failed on the previous commit because the three added it.each
rows exceeded the formatter width; run oxfmt's default formatting on the
test file (source file already clean). No behavior change.

Refs openclaw#169161
Replays each false-positive prefix segment with its own content block template and unit accounting instead of the latest template, and interleaves the replayed text with queued reasoning in arrival order. Every trim path (delta, done, error, queue overflow, EOF) now drains buffered auxiliary events before clearing the candidate queue. Adds regression tests for the three review repros.
@JasonBuildAI

Copy link
Copy Markdown
Contributor Author

Updated after the review at b325652. Pushed 08518c6 on this branch, fixing all three P2 findings:

1. Terminal trims drain buffered auxiliary events. applyCandidateTrim now streams queued entries (projected exactly like forceProjectPendingAux) interleaved with the replayed prefix before the candidate queue is cleared, on every trim path: delta, done, error, queue overflow, and EOF. Regression test mirrors the review repro — [read] + 300 spaces, nope\n<function=read>, thinking_delta "checking", EOF — and asserts the reasoning event is retained with unchanged visible text.

2. Prefix replay keeps each segment on its original content block. Replay segments are built from the candidate parts, each using its own block's event template and per-block emitted-unit accounting instead of the latest template. The review repro ([read] at index 0, then x\n<function=read> at index 1) now replays [read] at index 0 and x\n at index 1 rather than reassigning block 0 text to block 1.

3. Replay preserves text/reasoning arrival order. Queued entries now record the buffer offset they were queued at, and the decided prefix is split at those offsets so text and reasoning replay in the order they arrived. The review repro ([read], thinking_delta "checking", \n<function=read>) replays as [read] -> checking -> \n.

Verification on the changed sources (same mirror harness the PR body describes): packages/tool-call-repair 112/112 tests passing (109 before, 3 new regressions), oxfmt --check clean, oxlint with the repository config exits 0, and strict tsc with noUncheckedIndexedAccess clean.

On the remaining proof item: this environment cannot run the Telegram Test Server E2E — no test-server credentials, and the Gateway cannot be provisioned from this Windows checkout. The PR body now says so explicitly. If the E2E recording is a hard gate, please point me at who can run the repository E2E skill, or the setup you expect, and I will prepare the script.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@JasonBuildAI

Copy link
Copy Markdown
Contributor Author

Small follow-up commit f865603: added regression coverage for the terminal paths the review called out. The done and error trim guards fail on the pre-fix source, and the queue-cap guard covers the auxiliary-queue overflow path; the EOF case is in the previous commit. packages/tool-call-repair is now 115/115 in the same harness, with oxfmt --check / oxlint / strict tsc still clean.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

…lock

A trim can drop earlier content blocks whole, so the retained suffix can
start inside a later block. Advancing snapshotOffset by the concatenated
buffer's removed length made authoritative text_end reconciliation slice
at the wrong origin: the f865603 review repro ('[read]' then
'x\n<function=read>' plus text_end) leaked 'ion=read></function>' as
visible text.

Derive the new origin from the original part that contains the retained
suffix so replay slicing and cumulative snapshots agree, and add the
cross-block cumulative-snapshot case to the block-index regression.
@JasonBuildAI

Copy link
Copy Markdown
Contributor Author

Fixed the remaining P2 from the latest review in 9d7d80a.

Trimmed snapshot origins stay local to the retained block. The repro you gave (text_delta("[read]", 0), text_delta("x\n<function=read>", 1), text_end("x\n<function=read></function>", 1)) trimmed 8 characters off the concatenated buffer and advanced snapshotOffset to 8, while the retained call begins at offset 2 inside block 1. Authoritative text_end reconciliation then sliced at 8, and classification replayed ion=read></function> as visible text plus a raw text_end. applyCandidateTrim now walks the original parts to the one containing the retained suffix and derives the new origin from that block (max(0, blockLocal + trimmedOffset - part.start)), so replay slicing and cumulative snapshots share one origin.

The cumulative-snapshot repro is now part of the block-index regression (trim replay ordering); it fails on f865603 (extra [1, "ion=read></function>"] delta) and passes after the fix.

Verification in the same mirror harness as the previous revisions: packages/tool-call-repair 116/116 tests passing, oxfmt --check clean, oxlint with the repository config exits 0, and strict tsc (with noUncheckedIndexedAccess) is clean.

On the proof item: this environment still cannot run the Telegram Test Server E2E (no test-server credentials; the Gateway cannot be provisioned from this Windows checkout), as noted in the body. If that recording is a hard gate, please point me at who can run the repository E2E skill or what setup you expect, and I will prepare the script.

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@JasonBuildAI

Copy link
Copy Markdown
Contributor Author

Read the revision-4 verdict. Confirming my understanding: no code findings remain, and the only open item is the proof: telegram-e2e gate.

Before asking again, I re-checked both proof paths available from this side:

  • The requested-proof workflow can't run for this head. mantis-telegram-bot-e2e-proof.yml requires the PR head repo to be openclaw/openclaw (pull.head.repo?.id !== context.payload.repository.id fails otherwise), and this PR's head is JasonBuildAI/openclaw, so a maintainer cannot dispatch it against 9d7d80a as-is.
  • A local userbot run can't lease credentials here. The lease needs broker-member access or the OPENCLAW_QA_CONVEX_* pair; this host has neither (no ~/.convex, no convex CLI, no broker env), and the skill says not to install or log in on the credential owner's behalf, with pool creation owner-only.

So the Test Server recording can only come from a credential owner or maintainer running .agents/skills/telegram-e2e-userbot against 9d7d80a. I'm happy to prepare the exact scenario for them (it needs provider-shape control - alternate E2E_MOCK_SERVER_PATH or qa-mock fixtures - to stream a split marker); just say where to put it.

If neither path is available, the reasonable alternatives are a same-repo replacement PR (source PR credited) so the requested-proof lane becomes admissible, or maintainer judgment on the current head. Nothing is left to change on the code side; the head stays 9d7d80a and checks are green.

Keep the stream coordinator below its inherited line budget by moving the existing oversized-payload state machine into a sibling module. Preserve the shared grammar and request tool allowlist, and strengthen marker-split regressions with independent visible-text expectations.
@clawsweeper clawsweeper Bot added merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. proof: sufficient ClawSweeper judged the real behavior proof convincing. labels Oct 14, 2026
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. 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 Oct 14, 2026
… inventory

6caf20c moved the bounded stream suppression state machine into packages/tool-call-repair/src/stream-normalizer-suppression.ts, but scripts/pr only extracts scripts/pr, scripts/pr-lib, and the paths listed in wrapper-components.txt. Without the entry the extracted anchor cannot resolve ./stream-normalizer-suppression.js, so eager-import-closure fails on the PR wrapper inventory and on the extracted dependency context.
@openclaw-barnacle openclaw-barnacle Bot added the scripts Repository scripts label Oct 14, 2026
@JasonBuildAI

Copy link
Copy Markdown
Contributor Author

Fixed the remaining P2 in b593f05.

Wrapper inventory now covers the extracted suppression module. scripts/pr-lib/wrapper-components.txt gains packages/tool-call-repair/src/stream-normalizer-suppression.ts, listed with the other packages/tool-call-repair/* entries, so the trusted anchor that scripts/pr materializes can resolve the ./stream-normalizer-suppression.js import added in 6caf20c.

Exact-head CI on b593f05 confirms it (run 38507202210): checks-node-compact-small-1, the shard that failed on 6caf20c, now passes both previously failing cases in test/scripts/eager-import-closure.test.ts:

  • keeps the PR wrapper inventory closed over runtime imports
  • resolves wrapper package exports and workspace aliases from the extracted dependency context

The change is inventory-only: one added line, no edits to the suppression module, the normalizer, the tests, or any other runtime import. If scripts/pr-lib maintenance would rather carry that line in a maintainer follow-up, it is a one-line revert.

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 14, 2026
@steipete
steipete merged commit c0852fb into openclaw:main Oct 14, 2026
128 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 15, 2026
…unks split a call marker (openclaw#169172)

* fix(tool-call-repair): keep call text private when chunks split a call marker

A buffered tail that is still an unfinished call marker ("<funct", "<|channel|>")
was replayed as a false-positive prefix when a complete call preceded it, so the
rest of the call arrived mid-buffer and was emitted as visible text. Hold the
buffer while the tail can still complete into a call, replay only decided
false-positive prefixes, and route trim bookkeeping through one helper so the
done/error/EOF paths share the same chunk-independent decision.

Regression tests cover a replayed false prefix, a stacked function call, and a
stacked Harmony call split across chunks.

Refs openclaw#169161

* fix(tool-call-repair): align split-stream replay with the block origin

The split-marker buffering added in the previous commit diverged from the
unsplit stream when an authoritative text_end extended the same content block
("hello\n[read]\n{}\nX\n  " lost the call placeholder). Classify
delta-path buffers with the same finalize context as snapshots, keep the block
offset when a text_end extends a buffered snapshot, and track per-content-index
consumed input length so non-authoritative replays slice from the right origin.

Adds three regression tests (plain text and Harmony, delta and text_end split
shapes); stream-normalizer suite 58/58 and packages/tool-call-repair +
normalization-core 445/445 pass, fuzz seed=1 20k iters failures 71 -> 56 and
leakToSplit 18 -> 10 versus the previous commit.

Refs openclaw#169161

* chore(tool-call-repair): store the touched files with LF line endings

The previous uploads kept a CRLF final newline captured from the local
working copy; the repository stores these files as LF, so the PR diff
picked up a spurious trailing-line change on both files. No code changes.

Refs openclaw#169161

* style(tool-call-repair): format the new test cases with oxfmt

check-lint failed on the previous commit because the three added it.each
rows exceeded the formatter width; run oxfmt's default formatting on the
test file (source file already clean). No behavior change.

Refs openclaw#169161

* fix(tool-call-repair): keep trim replay order and drain buffered aux

Replays each false-positive prefix segment with its own content block template and unit accounting instead of the latest template, and interleaves the replayed text with queued reasoning in arrival order. Every trim path (delta, done, error, queue overflow, EOF) now drains buffered auxiliary events before clearing the candidate queue. Adds regression tests for the three review repros.

* test(tool-call-repair): cover terminal trim drains for done, error, and queue cap

* fix(tool-call-repair): keep trimmed snapshot offsets local to their block

A trim can drop earlier content blocks whole, so the retained suffix can
start inside a later block. Advancing snapshotOffset by the concatenated
buffer's removed length made authoritative text_end reconciliation slice
at the wrong origin: the f865603 review repro ('[read]' then
'x\n<function=read>' plus text_end) leaked 'ion=read></function>' as
visible text.

Derive the new origin from the original part that contains the retained
suffix so replay slicing and cumulative snapshots agree, and add the
cross-block cumulative-snapshot case to the block-index regression.

* refactor(tool-call-repair): isolate bounded stream suppression

Keep the stream coordinator below its inherited line budget by moving the existing oversized-payload state machine into a sibling module. Preserve the shared grammar and request tool allowlist, and strengthen marker-split regressions with independent visible-text expectations.

* fix(pr-wrapper): list the extracted suppression module in the wrapper inventory

6caf20c moved the bounded stream suppression state machine into packages/tool-call-repair/src/stream-normalizer-suppression.ts, but scripts/pr only extracts scripts/pr, scripts/pr-lib, and the paths listed in wrapper-components.txt. Without the entry the extracted anchor cannot resolve ./stream-normalizer-suppression.js, so eager-import-closure fails on the PR wrapper inventory and on the extracted dependency context.

---------

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

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: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. scripts Repository scripts size: XL 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.

[Bug]: plain-text tool call text leaks into visible output when provider chunks split a call marker

2 participants