Skip to content

fix: long streamed replies that quote tool-call transcripts no longer stall the Gateway - #186605

Closed
JasonBuildAI wants to merge 17 commits into
openclaw:mainfrom
JasonBuildAI:fix/tool-call-transcript-stream-reparse-d8f1
Closed

JasonBuildAI wants to merge 17 commits into
openclaw:mainfrom
JasonBuildAI:fix/tool-call-transcript-stream-reparse-d8f1

Conversation

@JasonBuildAI

@JasonBuildAI JasonBuildAI commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #186601

Not ready to land: a Control UI bundle-budget decision is required. The streaming checks pass, but this revision exceeds the differential UI budgets below. No budget baseline has been changed.

What Problem This Solves

Long streamed answers quoting legacy [TOOL_CALL], downgraded [Tool Call: ...], or historical transcript markers repeatedly parse the whole reply and can stall the Gateway.

User Impact

Quoted examples stay visible and stream promptly. Unquoted scaffolding is removed, including after a fenced block leaves a list or blockquote. No configuration or migration is needed.

Why This Change Was Made

Each canonical removal pass uses the existing container-aware Markdown checkpoint owner because removing one marker can expose a fence for the next pass. Incomplete candidates remain pending; settled text stops participating in subsequent scans. The separate resolver was removed, preserving existing trim and correction semantics.

The refresh also fixes a previously missed checkpoint case: an unquoted legacy header split across blank lines must stay pending before its closing bracket arrives. Quoted incomplete headers use canonical code protection and continue settling incrementally. The same protected-region rule is applied independently in each downgraded removal pass. The existing regression suites cover all marker families without adding test lines.

Thanks @JasonBuildAI for the report, original implementation, and reproduction workloads. All contributor commits and credit are preserved through merges; no rebase or force-push.

Evidence

Current head: 67618a3d03406cb5e0da894cd3d008c433765777. Main merge base: bca996c12f5568a125d2159fc87186213f1a705c.

  • Current-main reproduction through createAssistantVisibleStreamText("final_answer"), four-character deltas, still parses 16,785,006 legacy / 33,568,848 downgraded characters at 8 KiB. Both committed work regressions fail on main for their scan budget, with correct output.
  • Refreshed 8/16/32 KiB runs parse 348 legacy / 1,239 downgraded characters at every size, with exact canonical output and reconstructed deltas.
  • The blank-line header regression fails before the correction and passes after it. The quoted incomplete-header work regression also fails before the refinement and passes after it; a 5,657-character literal probe falls from 1,464,945 to 30,794 parsed characters with identical output.
  • All 524 focused and consumer tests pass (48.63 s command wall time). Scoped type-aware lint, formatting, and core types pass. Fresh Codex review is scoped-clean through P2; all ten baseline ratchets pass without raising a baseline.
  • Qualified UI comparison against the same base and Vite/Pako toolchain fails: new-session JS is 799,817 B gzip versus base 799,089 B (+728 B; only 192 B variance allowed). Chat boot is 1,286,619 B versus the 1,286,062 B ceiling. These are new differential failures, distinct from the known runner/device-copy failure in the earlier refresh CI.

Prior isolated built-Gateway evidence is retained: nine synthetic WebSocket responses had exact streaming/final text, and a real shared Ollama qwen2.5:7b turn completed in 3.24 s with 566 canonical final characters. That is historical proof, not a new live run of this corrective head. Further live qualification stops at the new budget decision; the checkpoint correction is covered at its owning projection boundary.

Production +206/-64 (net +142); tests +71/-72 (net -1). Remaining source growth carries checkpoint/candidate state and canonical pass composition. There is one Markdown ownership implementation. Validation is local macOS. #186667 remains the second step and must follow this PR.

Final remote verification

Exact-head CI 41974491724 completed with only control-ui-performance failing, which made openclaw/ci-gate fail. The failure table classifies it as new; its comparison found +290 B new-session and +518 B chat gzip growth. ClawSweeper reviewed this exact head with no code findings; its remaining requests are the declared fresh-Gateway proof and bundle-budget decision.

@clawsweeper

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

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. labels Oct 28, 2026
@JasonBuildAI
JasonBuildAI force-pushed the fix/tool-call-transcript-stream-reparse-d8f1 branch from ab37afd to 4f89bd2 Compare October 28, 2026 07:24
@JasonBuildAI
JasonBuildAI force-pushed the fix/tool-call-transcript-stream-reparse-d8f1 branch from 4f89bd2 to 7ca09e5 Compare October 28, 2026 07:41
…delta

A final answer that quotes a legacy [TOOL_CALL] block or a downgraded [Tool Call: ...] transcript inside code kept re-running the canonical sanitizer, including its full Markdown ownership parse, on every delta. Both stages now project incrementally: they scan when a marker bracket arrives or a candidate is open, reuse code ranges across appends, and append the rest of the tail verbatim.

Fixes openclaw#186601
@JasonBuildAI
JasonBuildAI force-pushed the fix/tool-call-transcript-stream-reparse-d8f1 branch from 7ca09e5 to 3a26eb4 Compare October 28, 2026 07:54
@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. 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 clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Oct 28, 2026
@clawsweeper

clawsweeper Bot commented Oct 28, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs real behavior proof before merge.

What this changes

This PR incrementally filters legacy and downgraded tool transcripts while preserving quoted code and streaming corrections.

Example: An 8 KiB answer quotes a fenced [TOOL_CALL] transcript and arrives in four-character deltas.

  • Before: The reported current-main reproduction parses 16,785,006 Markdown characters.
  • After: The refreshed projection measurement parses 348 characters with exact canonical output and reconstructed deltas.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The previous defect is repaired and no new concrete code finding remains, but current corrective behavior has only boundary proof and the measured UI performance tradeoff is unresolved.
Proof confidence 🦪 silver shellfish (2/6) Real behavior proof is necessary before merge. See Before merge.
Patch quality 🦐 gold shrimp (3/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Long replies quoting tool-call transcripts can make the Gateway unresponsive during streaming.
Reason: The failure has a concrete current-main mechanism, and feature-history owner involvement supports the checkpoint repair direction.

Merge readiness

⛔ Blocked before merge - 2 items remain

This PR addresses a current-main Gateway stall and fixes the previous split-header finding; the explicitly paused UI bundle-budget decision remains unresolved.

Priority: P1
Reviewed head: 67618a3d03406cb5e0da894cd3d008c433765777
Owner decision: Required. See Decision needed.

Decision needed

  • Question: Should this PR reduce the measured Control UI bundle growth or receive an explicit owner-approved budget exception?
  • Recommendation: Reduce bundle growth: Keep the streaming repair while bringing new-session and Chat boot payloads within the existing differential budgets.
  • Why: The PR expressly pauses landing, records differential budget failures, and contains no acceptance of this tradeoff; approval of earlier checkpoint work does not cover this increase.

Before merge

  • Add real behavior proof - Historical macOS built-Gateway WebSocket responses and a real Ollama turn exercise the original transcript repair, but the body explicitly excludes the current scanner corrections from that run; provide redacted Gateway terminal output or logs showing split legacy headers are removed and quoted incomplete headers remain visible without growing rescans, with streaming and final text matching canonical output. After adding proof, update the PR body, then request a new review with @clawsweeper re-review. The PR author or someone with repository write access can request it.
  • Resolve maintainer decision - Resolve the maintainer decision shown above before merge.

Findings

None.

Tests

  • Missing end-to-end proof: The corrective head lacks shipped-Gateway evidence for whitespace-split legacy headers and quoted incomplete legacy/downgraded headers; the body reports red/green boundary regressions.
Agent review details

How this fits together

Assistant text deltas enter shared sanitizer projections, which remove internal scaffolding and emit visible text with append or replacement updates for Gateway and channel delivery.

flowchart LR
A[Assistant text deltas] --> B[Visible text projection]
B --> C[Ordered transcript filters]
C --> D[Canonical Markdown checkpoints]
D --> E[Visible text and correction deltas]
E --> F[Gateway and channel delivery]
Loading

Technical review

Best possible solution:

Retain the canonical checkpoint repair and reduce its UI bundle cost unless the performance owner explicitly accepts the measured increase.

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

Current-main source confirms accumulated-input sanitization after marker activation, and the linked report supplies concrete four-character-delta workloads and parser measurements; this read-only review executed no target code.

Is this the best way to solve the issue?

Reusing the existing Markdown checkpoint owner is a focused root-cause repair, preserves ordered removal semantics, and removes the superseded resolver without introducing a competing parser.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 0bad3b4 adds src/shared/text/text-projection.ts:102 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 0bad3b4ba389; files: src/shared/text/text-projection.ts)
  • Jason Cat: Raw commit 17e09c7 adds src/shared/text/code-regions.ts:77 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 17e09c778e6b; files: src/shared/text/code-regions.ts)
  • sunlit-deng: Raw commit 49265a7 adds src/shared/text/code-regions.ts:100 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 49265a7b583a; files: src/shared/text/code-regions.ts)

PR surface

Source +142, Tests -1. Total +141 across 9 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 206 64 +142
Tests 4 71 72 -1
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 9 277 136 +141

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Review metrics

Metric Value Why it matters
Production versus test delta Production +206/-64; tests +71/-72. Growth carries candidate settlement and ordered canonical passes; the former resolver is removed, and distinct parity and work-budget coverage is consolidated.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #186601
Summary: This PR addresses the canonical quoted-transcript sanitizer report; the snapshot and repeated-inline-code repairs affect separate owners.

Members:

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

Labels

Label changes:

  • add merge-risk: 🚨 other: The reported Control UI route payload increase exceeds existing differential performance budgets and has no recorded owner acceptance.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • add status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.
  • remove proof: sufficient: Current real behavior proof status is insufficient, not sufficient.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🦪 silver shellfish, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 📣 needs proof.

Label justifications:

  • P1: A long quoted transcript can occupy the shared Gateway event loop and stall other sessions.
  • merge-risk: 🚨 other: The reported Control UI route payload increase exceeds existing differential performance budgets and has no recorded owner acceptance.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦐 gold shrimp.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Resolve the measured Control UI payload increase through reduction or explicit performance-owner acceptance.
  • Supply shipped-Gateway evidence for the corrective scanner scenarios.

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 (3 earlier review cycles)
  • reviewed 2026-10-28T08:12:20.787Z sha 3a26eb4 :: needs real behavior proof before merge. :: [P2] Reparse nested fences when their Markdown container ends
  • reviewed 2026-10-28T09:25:50.278Z sha 542aa94 :: needs maintainer review before merge. :: none
  • reviewed 2026-11-05T05:00:35.831Z sha e25f3e6 :: needs changes before merge. :: [P2] Retain incomplete legacy headers before the quick rejection

Reviewed November 5, 2026, 12:35 AM ET / 05:35 UTC (Revision 4).

steipete and others added 3 commits October 28, 2026 01:35
…delta

A final answer that quotes a legacy [TOOL_CALL] block or a downgraded [Tool Call: ...] transcript inside code kept re-running the canonical sanitizer, including its full Markdown ownership parse, on every delta. Both stages now project incrementally: they scan when a marker bracket arrives or a candidate is open, reuse code ranges across appends, and append the rest of the tail verbatim.

Fixes openclaw#186601
@JasonBuildAI
JasonBuildAI force-pushed the fix/tool-call-transcript-stream-reparse-d8f1 branch from 3a26eb4 to 60f3220 Compare October 28, 2026 08:42
steipete and others added 3 commits October 28, 2026 01:47
…delta

A final answer that quotes a legacy [TOOL_CALL] block or a downgraded [Tool Call: ...] transcript inside code kept re-running the canonical sanitizer, including its full Markdown ownership parse, on every delta. Both stages now project incrementally: they scan when a marker bracket arrives or a candidate is open, reuse code ranges across appends, and append the rest of the tail verbatim.

Fixes openclaw#186601
@JasonBuildAI
JasonBuildAI force-pushed the fix/tool-call-transcript-stream-reparse-d8f1 branch from 60f3220 to 57624c4 Compare October 28, 2026 08:59
@clawsweeper clawsweeper Bot added clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed 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. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
steipete and others added 3 commits November 4, 2026 21:14
Do not reject an unfinished legacy header before its pending state is recorded.
The canonical wrapper retains the quick guard, while streaming checkpoints can
keep a whitespace-split opening bracket until the header completes. This also
removes duplicate validation from the shared scanner.

Strengthen the existing legacy cases with prefix and reconstruction checks,
including a header split across blank lines, without adding test lines.

Co-authored-by: JasonBuildAI <[email protected]>
Use the existing Markdown code regions when deciding whether an unfinished
legacy header must retain the checkpoint. Literal examples remain eligible
for incremental settlement. Extend the existing work fixture without adding
test lines.

Co-authored-by: JasonBuildAI <[email protected]>
Keep unfinished bracket candidates pending only outside canonical code regions
in each downgraded removal pass. Quoted Tool Call, Tool Result, and historical
headers must not retain the entire reply after their fence closes. Extend the
existing work fixture for these cases without adding test lines.

Co-authored-by: JasonBuildAI <[email protected]>
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. 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. and removed proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
steipete added a commit that referenced this pull request Nov 5, 2026
…6667)

Long streamed replies containing quoted tool-call transcripts or repeated inline-code paragraphs repeatedly parsed accumulated Markdown and stalled Gateway streaming. Reuse canonical Markdown checkpoints and one shared duplicate-paragraph owner while preserving exact inline-code bytes and correction deltas.

Includes the complete transcript-streaming repair from #186605. Thanks @JasonBuildAI for the original reports and investigation.

Closes #186598
Closes #186601

Validation: exact-head CI passed at https://github.com/openclaw/openclaw/actions/runs/41980269737, including Control UI performance with unchanged budgets. Lead-verified focused tests and isolated built-Gateway synthetic/live-model runs preserved complete previews and final output. Local runtime proof was on macOS; complex Markdown retains its documented conservative fallback. Full evidence remains in the PR body.

Co-authored-by: JasonBuildAI <[email protected]>
@steipete

steipete commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

Thanks @JasonBuildAI. This work landed through #186667 (c6a601f) with your co-author credit. Its head contained every commit of this branch, so both streaming fixes could land together, and that combined head is the one that passed the Control UI size budget. Closing this one as superseded, with nothing lost.

@steipete steipete closed this Nov 5, 2026
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…nclaw#186667)

Long streamed replies containing quoted tool-call transcripts or repeated inline-code paragraphs repeatedly parsed accumulated Markdown and stalled Gateway streaming. Reuse canonical Markdown checkpoints and one shared duplicate-paragraph owner while preserving exact inline-code bytes and correction deltas.

Includes the complete transcript-streaming repair from openclaw#186605. Thanks @JasonBuildAI for the original reports and investigation.

Closes openclaw#186598
Closes openclaw#186601

Validation: exact-head CI passed at https://github.com/openclaw/openclaw/actions/runs/41980269737, including Control UI performance with unchanged budgets. Lead-verified focused tests and isolated built-Gateway synthetic/live-model runs preserved complete previews and final output. Local runtime proof was on macOS; complex Markdown retains its documented conservative fallback. Full evidence remains in the PR body.

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

Labels

merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. size: M status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: streamed replies that quote a tool-call transcript in code re-parse the whole reply per delta (70 s at 32 KB)

2 participants