Skip to content

refactor(agents): share preferred block chunk boundaries - #148391

Merged
vincentkoc merged 1 commit into
mainfrom
refactor/block-chunker-preferred-boundaries-20260914
Sep 15, 2026
Merged

vincentkoc merged 1 commit into
mainfrom
refactor/block-chunker-preferred-boundaries-20260914

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

This maintainer-requested refactor is part of the approved duplication and complexity reduction deliverable. The block chunker repeats paragraph, newline and sentence preference selection in its capped-window and forced-tail paths. Keeping those branches synchronized requires editing two copies of the same precedence rules.

User Impact

No intended boundary or source-text change. Forced tails still choose the first paragraph or newline boundary, capped windows choose the last, and sentence selection remains last in both paths. Newline preference still avoids sentence fallback.

Why This Change Was Made

Both paths call one private preferred-boundary selector with their existing direction, minimum length, absolute offset and open-fence context. Capped whitespace and hard-limit fallbacks, UTF-16 progress, fence reopening, source cursors and emission order remain with their existing owners.

Production: -25 lines. Tests: +64 lines. This mechanical refactor needs no changelog entry.

Evidence

  • Complete chunker/tests, fence and UTF-16 helpers, stream-rendering and subscription/BTW callers, and source-accounting/fence history were inspected. Independent current-source review preserved both direction choices, source cursors, emitted ordering and reset behavior.
  • The original chunker job passed all 54 chunker cases, including all three additions. These exercise ordinary draining and a forced tail after a capped prefix, checking ordered chunk/sourceText pairs, buffered text, source lengths and repeated final drain. Existing fence, replacement, UTF-16 and scan-count coverage remains.
  • Normal CI, attempt 2 passed: 118 successful jobs and 17 planned skips, with the selected-lane aggregate passing. The unchanged head is 932e1f79d664901359919e3f23df042451d5e41c; actual tested merge 4a14a243e65db54e37a5d23102f43e75b464d891 contains the reviewed two-file change.
  • The original selected lint, production/test types, guards, dependencies and build jobs passed. Workflow Sanity passed. The original formatter job checked the same actual merge with oxfmt --check: all 38,224 matched files used the correct format. These passing executions were carried forward into attempt 2.
  • The original speech job failed a transport-timeout assertion. That original failure remains unexplained. After source/history review and a separate instrumented diagnostic, one unchanged-source exact-job rerun was authorized. The rerun passed all 19 speech cases, including all four timeout cases and both drainage cases. The other passing jobs were retained, not rerun. Different worker/runtime details prevent an equivalent-environment or causal claim.
  • One exact-head P2 review had no actionable finding. That isolated review used the diff and supplied owner; separate source review covered surrounding contracts. The latest ClawSweeper review has no actionable finding, Before merge item or Rank-up move; its static-only scope is separate from the hosted proof above.

No live-channel behavior, performance improvement or bundle reduction is claimed.

@vincentkoc vincentkoc self-assigned this Sep 14, 2026
@clawsweeper

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

@vincentkoc
vincentkoc marked this pull request as ready for review September 14, 2026 16:47
@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 3:59 AM ET / 07:59 UTC (Revision 2).

ClawSweeper review

What this changes

Shares streamed-reply boundary selection between normal draining and forced tails, with tests preserving chunk order and original-text accounting.

Merge readiness

✅ Ready for maintainer review

The cleanup remains useful on current main, and this review found no actionable defect. The member-authored PR preserves existing behavior and has passing hosted validation.

Priority: P3
Reviewed head: 932e1f79d664901359919e3f23df042451d5e41c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, behavior-preserving cleanup with meaningful coverage, passing hosted validation, and no actionable findings.
Proof confidence 🌊 off-meta tidepool Not applicable: The member-authored internal refactor is exempt from contributor live proof; hosted chunker tests cover both drain paths and source accounting, with no live-channel or performance claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The member-authored internal refactor is exempt from contributor live proof; hosted chunker tests cover both drain paths and source accounting, with no live-channel or performance claim.
Evidence reviewed 7 items Verified introduced refactor: The pinned introduction delta preserves first-boundary selection for forced tails, last-boundary selection for capped windows, sentence precedence, offsets, and open-fence context. Public interfaces and hard-limit fallbacks are unchanged.
Behavioral coverage: Read the complete chunker and test module. Added cases check paragraph, newline, and sentence output, original source slices, pending tails, consumed lengths, and repeated final drains without exposing private implementation.
Still necessary on current main: Both affected files are unchanged between the pinned merge base and fetched main; main therefore retains the duplicated preferred-boundary selectors.
Findings None None.
Security None None.

How this fits together

The block chunker turns incoming assistant text into Markdown-safe reply blocks. Streaming callers send those blocks onward while tracking how much original text has been consumed.

flowchart TD
  A[Assistant text] --> B[Pending reply buffer]
  B --> C{Normal drain or forced tail}
  C --> D[Shared preferred boundary selection]
  D --> E[Fence-safe and length fallbacks]
  E --> F[Reply blocks and source accounting]
  F --> G[Streaming delivery]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source -25, Tests +64. Total +39 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 17 42 -25
Tests 1 64 0 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 81 42 +39

Review metrics

None.

Technical review

Best possible solution:

Keep one private owner for boundary precedence while preserving the existing drain directions, fence handling, and source-accounting contract.

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

Not applicable: this PR addresses duplicated implementation rather than a reported runtime failure; source inspection confirms the duplication remains on main.

Is this the best way to solve the issue?

Yes. Sharing the existing private selector removes duplicate precedence rules while preserving caller-specific direction and fallback behavior.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is a bounded internal cleanup with no intended user-visible behavior change.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool 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 member-authored internal refactor is exempt from contributor live proof; hosted chunker tests cover both drain paths and source accounting, with no live-channel or performance claim.

Evidence

What I checked:

  • Verified introduced refactor: The pinned introduction delta preserves first-boundary selection for forced tails, last-boundary selection for capped windows, sentence precedence, offsets, and open-fence context. Public interfaces and hard-limit fallbacks are unchanged. (src/agents/embedded-agent-block-chunker.ts:410, 932e1f79d664)
  • Behavioral coverage: Read the complete chunker and test module. Added cases check paragraph, newline, and sentence output, original source slices, pending tails, consumed lengths, and repeated final drains without exposing private implementation. (src/agents/embedded-agent-block-chunker.test.ts:56, 932e1f79d664)
  • Still necessary on current main: Both affected files are unchanged between the pinned merge base and fetched main; main therefore retains the duplicated preferred-boundary selectors. (src/agents/embedded-agent-block-chunker.ts:408, e83fa1461db6)
  • Release comparison: The supplied latest release also contains separate soft-break and capped-window preference selection; the proposed consolidation is not already present there. (src/agents/embedded-agent-block-chunker.ts:408, 3a9d69db306c)
  • Hosted validation: GitHub confirms CI attempt 2 completed successfully for the reviewed head. The linked chunker job also reports success. These are hosted test results, not live-channel proof; no target code was executed during this review. (932e1f79d664)
  • Review continuity and protected ownership: The supplied previous review covers the same head and retains no findings or required next step. The complete supplied body explains the requested cleanup and the prior speech timeout plus successful rerun without claiming a causal diagnosis. Live REST metadata confirms the PR remains open, member-authored, and assigned to vincentkoc. (932e1f79d664)

Likely related people:

  • unknown: The claimed source-line change could not be verified from bounded local history. (role: source history unknown; confidence: low)
  • steipete: 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 (1 earlier review cycle)
  • reviewed 2026-09-14T17:34:22.598Z sha 932e1f7 :: needs maintainer review before merge. :: none

@vincentkoc
vincentkoc merged commit 26316eb into main Sep 15, 2026
397 of 399 checks passed
@vincentkoc
vincentkoc deleted the refactor/block-chunker-preferred-boundaries-20260914 branch September 15, 2026 08:18
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 15, 2026
* commit '0cd944c01416c4f9c1f6dc9d1dea9670c5b99cab':
  improve: speed up session search for restricted operators (#148826)
  fix(update): avoid retry guidance for historical abandoned runs (#146982)
  fix(android): reduce queued-message send overhead (#148899)
  refactor(slack): count table cells only for native output (#148872)
  fix: correct update status and apply saved model keys (#148830)
  refactor(nostr): share doctor state migration flow (#148647)
  refactor(gateway): centralize device token denial responses (#148644)
  test: make kitchen sink assertions runtime portable (#148891)
  refactor(agents): share preferred block chunk boundaries (#148391)
  fix(ui): use the selected timezone for Usage date shortcuts (#148277)
  test: probe active Node in release preflight (#148892)
  fix(test): restore services typecheck shard headroom (#148889)
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 16, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant