Skip to content

improve: speed up streaming text with inline brackets - #154398

Merged
steipete merged 1 commit into
mainfrom
codex/perf-bracket-line-scan
Sep 21, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/perf-bracket-line-scan

Conversation

@steipete

Copy link
Copy Markdown
Contributor

Related: #145679

What Problem This Solves

Streaming assistant text containing ordinary inline brackets repeatedly triggers tool-call scanning and Markdown code-region discovery.

User Impact

Bracket-heavy prose takes less processing time while preserving visible text and the handling of actual tool-call blocks. No configuration or migration is required.

Why This Change Was Made

Require the same line start and indentation that the existing full-line tool-call scanner already requires before doing the deeper scan. Parser grammar, protected code regions, adjacent calls, and Harmony/XML alternatives remain with their existing owners.

Evidence

  • Registered streaming-handler workload on Node 26.8.2/Linux, four separate ABBA processes, one warmup and three samples per case. Both arms use the pinned 7d14778 dependency installation and include the landed lazy snapshots; only this predicate differs. The candidate owner and caller bytes match the new branch; current-head CI covers integration.
  • Bracket-heavy 8/32/128 KiB workloads took 59–75% less time in both process pairs. At 128 KiB, medians were 417.765/464.086 ms baseline versus 109.356/114.699 ms candidate.
  • All 535 output traces and 325 split cases matched in every arm. All 21 workload cases retained identical output hashes. Five related test files passed 321 tests.
  • Controls were mixed: angle-heavy 8 KiB cases were 3–6% slower and 32 KiB cases 2–3% slower. Whole-process peak RSS was 1.8% and 8.2% higher in the two pairs. These are suite peaks, not retained-heap measurements; no general latency or memory improvement is claimed. This workload is not sustained live Gateway load.
  • Five table cases protect inline text and Unicode indentation with LF/CR/CRLF, JSON/XML, and adjacent calls. These correctness guards also pass the original implementation.
  • pnpm test packages/tool-call-repair/src/payload.test.ts --maxWorkers=1: 30/30 passed, 1.962 seconds wall time on the isolated Node 26 Linux install (default and JSON reporters). Independent review passed with no P0-P2 findings; CI seconds remain pending.

Formatting passed. The changed-check plan selects core production and core tests; full lint/type/guard execution is delegated to the published-head CI. The final formatter change only reflows an it.each call and adds an optional trailing comma.

@clawsweeper

clawsweeper Bot commented Sep 21, 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.

@steipete
steipete marked this pull request as ready for review September 21, 2026 04:03
@openclaw-barnacle openclaw-barnacle Bot added size: XS maintainer Maintainer-authored PR labels Sep 21, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Sep 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 21, 2026, 12:21 AM ET / 04:21 UTC.

ClawSweeper review

What this changes

Avoid unnecessary tool-call scanning for ordinary inline brackets while preserving standalone tool-call removal, with tests for prose, Unicode indentation, and line endings.

Merge readiness

✅ Ready for maintainer review

Keep open: this remains a useful, focused optimization absent from the inspected main and release revisions. No actionable correctness or security findings were identified.

Priority: P2
Reviewed head: 414b8f69079fdadbb72765eee28e9bef6d928c14

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused optimization with relevant workload evidence, useful parity guards, and no identified blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The external-contributor gate does not apply to this maintainer-authored PR. Its supplied Node/Linux registered-handler comparison exercises the changed stripping path and reports output parity with reduced bracket-heavy processing time; it does not establish sustained Gateway performance.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The external-contributor gate does not apply to this maintainer-authored PR. Its supplied Node/Linux registered-handler comparison exercises the changed stripping path and reports output parity with reduced bracket-heavy processing time; it does not establish sustained Gateway performance.
Evidence reviewed 8 items Introduced optimization preserves the scanner boundary: The introduced delta changes only the bracket prefilter and adds correctness cases. The new line-start condition matches the scan loop at lines 688–693; its indentation class matches skipLineIndentation. Adjacent calls still pass through the unchanged scanner after an initial recognized call.
Existing parser and protection remain authoritative: Read the complete payload implementation and its tests. The early return skips protected-range discovery only when no supported full-line opener exists; JSON/XML parsing, Harmony alternatives, payload limits, and protected-range checks remain unchanged.
Production caller connection: plainToolCallTextFilter invokes the changed owner with findCodeRegions and activates on brackets; the agent's userFacingTextFilters includes this filter for streaming. This establishes the repeated-work path without relying on a Codex dependency contract.
Findings None None.
Security None None.

How this fits together

OpenClaw filters assistant text before streaming and delivery to remove serialized tool-call blocks. This change lets ordinary bracket-containing prose bypass deeper parsing and Markdown code-region discovery.

flowchart TD
  A[Assistant text] --> B[Visible text filters]
  B --> C{Possible standalone tool call?}
  C -->|No| F[Preserved visible text]
  C -->|Yes| D[Find protected code regions]
  D --> E[Scan and remove tool-call blocks]
  E --> F
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source 0, Tests +26. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 1 0
Tests 1 26 0 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 27 1 +26

Review metrics

Metric Value Why it matters
Reported bracket workload improvement 59–75% less processing time across 8/32/128 KiB cases The registered-handler comparison supports the targeted optimization; mixed controls prevent a broader latency or memory claim.

Technical review

Best possible solution:

Keep the optimization in the existing scanner owner and retain the established parsing and literal-text contracts.

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

Yes, source establishes the repeated-work path: ordinary inline brackets pass the existing prefilter and trigger deeper scanning despite lacking a valid line-start opener. Runtime timings were supplied by the author and were not rerun.

Is this the best way to solve the issue?

Yes. Aligning the cheap prefilter with the existing scanner grammar removes unnecessary work without introducing another parser, changing public APIs, or migrating user state.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This is a bounded streaming-performance improvement with measured benefit and no demonstrated urgent user-facing failure.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The external-contributor gate does not apply to this maintainer-authored PR. Its supplied Node/Linux registered-handler comparison exercises the changed stripping path and reports output parity with reduced bracket-heavy processing time; it does not establish sustained Gateway performance.

Label justifications:

  • P2: This is a bounded streaming-performance improvement with measured benefit and no demonstrated urgent user-facing failure.
  • 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. Not applicable: The external-contributor gate does not apply to this maintainer-authored PR. Its supplied Node/Linux registered-handler comparison exercises the changed stripping path and reports output parity with reduced bracket-heavy processing time; it does not establish sustained Gateway performance.

Evidence

What I checked:

  • Introduced optimization preserves the scanner boundary: The introduced delta changes only the bracket prefilter and adds correctness cases. The new line-start condition matches the scan loop at lines 688–693; its indentation class matches skipLineIndentation. Adjacent calls still pass through the unchanged scanner after an initial recognized call. (packages/tool-call-repair/src/payload.ts:675, 414b8f69079f)
  • Existing parser and protection remain authoritative: Read the complete payload implementation and its tests. The early return skips protected-range discovery only when no supported full-line opener exists; JSON/XML parsing, Harmony alternatives, payload limits, and protected-range checks remain unchanged. (packages/tool-call-repair/src/payload.ts:683, 414b8f69079f)
  • Production caller connection: plainToolCallTextFilter invokes the changed owner with findCodeRegions and activates on brackets; the agent's userFacingTextFilters includes this filter for streaming. This establishes the repeated-work path without relying on a Codex dependency contract. (src/shared/text/assistant-visible-text.ts:747, 414b8f69079f)
  • Main and release still contain the broad prefilter: Inspected payload.ts at fetched main 8c198a5 and v2026.9.5; both retain the unanchored bracket test. The merge-base-to-main comparison shows no change to this file, so the branch still contributes the optimization. (packages/tool-call-repair/src/payload.ts:675, 8c198a55ceb7)
  • Scoped workload evidence: The captured PR body reports four Node 26.8.2/Linux ABBA processes exercising the registered streaming handler, with candidate owner/caller bytes matching the branch: bracket-heavy cases took 59–75% less time, all 535 output traces and 325 split cases matched, and all 21 workload output hashes matched. It explicitly discloses slower angle-heavy controls, higher whole-process peak RSS, and no sustained Gateway-load claim. These are supplied observations, not reviewer-executed measurements. (414b8f69079f)
  • Behavior guards and validation scope: The five added table cases check unchanged visible output and Unicode-indented JSON/XML calls across LF, CR, and CRLF, including adjacent calls. They are parity guards, not a performance regression measurement. The body reports 30 passing owner tests in 1.962 seconds and 321 related tests; this read-only review did not execute tests. Diff whitespace validation passed and the checkout remained clean. (packages/tool-call-repair/src/payload.test.ts:149, 414b8f69079f)

Likely related people:

  • Peter Steinberger: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vincent Koc: 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.

@steipete
steipete merged commit 7c047ae into main Sep 21, 2026
196 checks passed
@steipete
steipete deleted the codex/perf-bracket-line-scan branch September 21, 2026 04:36
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit to jb510/openclaw that referenced this pull request Sep 21, 2026
* commit 'f76d38a4ac5e5f4e6c5a5320436db169e33d5c8a': (49 commits)
  fix(ci): remove duplicate database worker test entry
  fix(voice): keep audio flowing while the Gateway is busy (openclaw#154119)
  docs: reserve Team live updates for Night Watch (openclaw#154425)
  test(meeting-bot): control browser retry fixture clocks (openclaw#149174)
  fix(ui): use remote defaults for manual worktree creation (openclaw#154364)
  fix(proxy): keep WebChat and Codex loopback calls direct (openclaw#154013)
  fix(pr): revalidate head reads and reuse repository locators (openclaw#154212)
  fix(browser): start control when the Gateway has activated the plugin (openclaw#154255)
  improve: publish CI dependencies promptly and warm hosted JavaScript caches (openclaw#154156)
  improve: speed up streaming text with inline brackets (openclaw#154398)
  test: isolate historical Node runner policy from CI
  fix: refresh stale Gateway shutdown budgets during updates and Doctor (openclaw#153636)
  ci: use four Windows workers on the 16 class (openclaw#154261)
  feat: verify GitHub credit from trusted OIDC claims (openclaw#153940)
  feat(sessions): support explicit local placement for child sessions (openclaw#153912)
  fix(ui): prevent stale copies after text changes (openclaw#154259)
  perf(gateway): reuse session list candidates across viewers (openclaw#154003)
  perf(codex): bound progressive local catalog waits (openclaw#154362)
  docs: keep update requests owned through acceptance (openclaw#154111)
  perf(state): reduce main-thread coordinator waits (openclaw#154244)
  ...
vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit 'f76d38a4ac5e5f4e6c5a5320436db169e33d5c8a': (58 commits)
  fix(ci): remove duplicate database worker test entry
  fix(voice): keep audio flowing while the Gateway is busy (#154119)
  docs: reserve Team live updates for Night Watch (#154425)
  test(meeting-bot): control browser retry fixture clocks (#149174)
  fix(ui): use remote defaults for manual worktree creation (#154364)
  fix(proxy): keep WebChat and Codex loopback calls direct (#154013)
  fix(pr): revalidate head reads and reuse repository locators (#154212)
  fix(browser): start control when the Gateway has activated the plugin (#154255)
  improve: publish CI dependencies promptly and warm hosted JavaScript caches (#154156)
  improve: speed up streaming text with inline brackets (#154398)
  test: isolate historical Node runner policy from CI
  fix: refresh stale Gateway shutdown budgets during updates and Doctor (#153636)
  ci: use four Windows workers on the 16 class (#154261)
  feat: verify GitHub credit from trusted OIDC claims (#153940)
  feat(sessions): support explicit local placement for child sessions (#153912)
  fix(ui): prevent stale copies after text changes (#154259)
  perf(gateway): reuse session list candidates across viewers (#154003)
  perf(codex): bound progressive local catalog waits (#154362)
  docs: keep update requests owned through acceptance (#154111)
  perf(state): reduce main-thread coordinator waits (#154244)
  ...
vincentkoc added a commit that referenced this pull request Sep 21, 2026
* commit 'f76d38a4ac5e5f4e6c5a5320436db169e33d5c8a': (58 commits)
  fix(ci): remove duplicate database worker test entry
  fix(voice): keep audio flowing while the Gateway is busy (#154119)
  docs: reserve Team live updates for Night Watch (#154425)
  test(meeting-bot): control browser retry fixture clocks (#149174)
  fix(ui): use remote defaults for manual worktree creation (#154364)
  fix(proxy): keep WebChat and Codex loopback calls direct (#154013)
  fix(pr): revalidate head reads and reuse repository locators (#154212)
  fix(browser): start control when the Gateway has activated the plugin (#154255)
  improve: publish CI dependencies promptly and warm hosted JavaScript caches (#154156)
  improve: speed up streaming text with inline brackets (#154398)
  test: isolate historical Node runner policy from CI
  fix: refresh stale Gateway shutdown budgets during updates and Doctor (#153636)
  ci: use four Windows workers on the 16 class (#154261)
  feat: verify GitHub credit from trusted OIDC claims (#153940)
  feat(sessions): support explicit local placement for child sessions (#153912)
  fix(ui): prevent stale copies after text changes (#154259)
  perf(gateway): reuse session list candidates across viewers (#154003)
  perf(codex): bound progressive local catalog waits (#154362)
  docs: keep update requests owned through acceptance (#154111)
  perf(state): reduce main-thread coordinator waits (#154244)
  ...
vincentkoc added a commit to vyctorbrzezowski/openclaw that referenced this pull request Sep 21, 2026
* commit 'f76d38a4ac5e5f4e6c5a5320436db169e33d5c8a': (44 commits)
  fix(ci): remove duplicate database worker test entry
  fix(voice): keep audio flowing while the Gateway is busy (openclaw#154119)
  docs: reserve Team live updates for Night Watch (openclaw#154425)
  test(meeting-bot): control browser retry fixture clocks (openclaw#149174)
  fix(ui): use remote defaults for manual worktree creation (openclaw#154364)
  fix(proxy): keep WebChat and Codex loopback calls direct (openclaw#154013)
  fix(pr): revalidate head reads and reuse repository locators (openclaw#154212)
  fix(browser): start control when the Gateway has activated the plugin (openclaw#154255)
  improve: publish CI dependencies promptly and warm hosted JavaScript caches (openclaw#154156)
  improve: speed up streaming text with inline brackets (openclaw#154398)
  test: isolate historical Node runner policy from CI
  fix: refresh stale Gateway shutdown budgets during updates and Doctor (openclaw#153636)
  ci: use four Windows workers on the 16 class (openclaw#154261)
  feat: verify GitHub credit from trusted OIDC claims (openclaw#153940)
  feat(sessions): support explicit local placement for child sessions (openclaw#153912)
  fix(ui): prevent stale copies after text changes (openclaw#154259)
  perf(gateway): reuse session list candidates across viewers (openclaw#154003)
  perf(codex): bound progressive local catalog waits (openclaw#154362)
  docs: keep update requests owned through acceptance (openclaw#154111)
  perf(state): reduce main-thread coordinator waits (openclaw#154244)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant