Skip to content

improve(agents): skip unused assistant delivery parsing - #146858

Merged
steipete merged 1 commit into
mainfrom
codex/v8-assistant-directive-scan
Sep 13, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/v8-assistant-directive-scan

Conversation

@steipete

@steipete steipete commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Closes #146829.

What Problem This Solves

Saving an assistant reply without delivery markers still parses and normalizes its Markdown, then discards that result. Large code blocks make this unused work noticeable in the complete SQLite append path.

User Impact

Code-heavy assistant replies take less time to save. Exact transcript bytes, delivery facts, mixed content, and managed-media recording remain unchanged. No cache, schema, API, or update behavior changes.

Why This Change Was Made

The existing delivery owner now skips parsing text without the literal [[ prefix required by every reply, audio, malformed-prefix, and TTS directive. Marker-bearing text follows the existing path.

The existing persistence test adds ordinary whitespace, CRLF, and Markdown byte-preservation coverage. Its fixture also uses the existing session-state cleanup owner before removing temporary directories: the original Windows run failed all 21 cases during removal with open SQLite handles; the same 21 cases pass after proper cleanup, with original assertions and limits.

Evidence

Three alternating fresh-process pairs on each of Node 24.19 and 26.8 exercise public SessionManager.open, appendMessage, and flushPendingPersistence with real isolated SQLite storage. Each child verifies 558 complete outputs and measures 18 fixed workloads, with three sessions, three warmups, and five measured appends per session. All 12 children and 6,696 comparisons passed; no selective reruns.

Fenced 16K appends improve 8.932 to 3.021 ms on Node 24 and 10.869 to 3.149 ms on Node 26. Indented 4K and plain 64K also improve in all three pairs on both versions. These are elapsed times for complete persisted appends, not whole-application or provider latency.

Controls are mixed. Node 24 plain 1K, reply 4K, and audio 4K are slower in all three pairs; reply 4K moves 2.584 to 3.016 ms, with paired increases of 0.145–0.664 ms. Node 24 mixed content moves 2.283 to 3.049 ms (one faster pair), and empty content 1.823 to 2.255 ms (one faster pair). Node 26 also has adverse directive/empty controls. Unchanged nontext controls vary too; their cause is not established. No universal gain is claimed.

All warm append measurements

Values are medians of three child-process medians; each child summarizes three session medians. Faster counts retain paired direction and can differ from the direction of the overall medians.

Workload Node 24 before → after, ms Faster pairs Node 26 before → after, ms Faster pairs
plain-100 2.654 → 2.644 1/3 3.850 → 2.865 3/3
plain-1024 2.557 → 2.641 0/3 4.065 → 3.433 3/3
plain-4096 2.639 → 2.635 1/3 4.226 → 2.832 2/3
plain-16384 3.782 → 3.350 2/3 5.313 → 3.712 2/3
plain-65536 5.815 → 5.300 3/3 8.351 → 6.283 3/3
fenced-16k 8.932 → 3.021 3/3 10.869 → 3.149 3/3
indented-4k 4.399 → 2.526 3/3 5.357 → 2.893 3/3
whitespace-4k 2.674 → 2.347 3/3 3.240 → 2.810 2/3
unicode-4k 2.771 → 2.983 1/3 3.063 → 2.905 1/3
bracket-literal-4k 2.481 → 2.773 1/3 3.542 → 2.829 2/3
reply-4k 2.584 → 3.016 0/3 2.933 → 3.070 1/3
audio-4k 2.402 → 2.486 0/3 3.648 → 3.140 2/3
tts-4k 2.863 → 2.861 2/3 2.785 → 3.190 1/3
malformed-4k 2.587 → 2.838 1/3 2.348 → 2.916 1/3
literal-code-tags 2.666 → 3.308 1/3 2.434 → 2.903 1/3
mixed-blocks 2.283 → 3.049 1/3 2.612 → 2.508 2/3
empty 1.823 → 2.255 1/3 1.909 → 2.003 1/3
no-text 1.789 → 1.833 2/3 1.822 → 1.849 1/3

Setup and first appends are recorded separately. A first append uses a fresh session in an already warm process/database; it is not application cold start. First-append samples include adverse outliers, including 142.697 ms for a Node 26 literal-code control and 106.665 ms for a Node 24 empty control. They remain in the evidence.

Whole-process peak RSS medians were 988,672 → 974,808 KiB on Node 24 and 890,876 → 851,908 KiB on Node 26. These include imports, runner, both variants' parity work, and the full workload; they do not measure retained product memory.

The 69 directive tests and complete 21-case persistence suite passed. Core typechecking, all 18 test type graphs, preceding selected guards, formatting, targeted lint, and all nine remaining selected checks passed. The aggregate check failed only on canonicalProviderName and listPackagedStaticExtensionAssetOutputs, also reproduced on the clean baseline; both owning files are unchanged. Production unused-export analysis passed. No guard, baseline, timeout, or assertion was weakened.

Fresh independent P2 review completed with no actionable findings across all four evidence batches (confidence 0.80). The previous hosted head failed two inherited main defects: the removed sidebar deferred helper and the agents-other 702-root headroom overflow. Both repairs are now on main through #146862 and #146803. This branch was refreshed onto 2e0bfa16 with a byte-identical patch and unchanged affected source owners. Historical run 34748396850 ended in startup_failure with zero jobs, and the separate OpenGrep run did not acquire a runner across five attempts. Two initial recovery calls failed without changing the PR. A later verified close/reopen attached run 34750244280. Its first attempt failed before typechecking because @matrix-org/[email protected] postinstall received HTTP 500 and then threw ReferenceError: err is not defined; the raw log remains preserved. These historical failures are not passing results or evidence of a source defect. The subsequent second attempt completed successfully at the unchanged reviewed head. Current exact-head CI run 34750244280, attempt 2 completed successfully at 5d54b16f66557debc73af5b463f83172bce7dc19 (2026-09-13T10:07:29Z). The current required-check query reports openclaw/ci-gate SUCCESS. This supports native preparation; it does not claim merge or cleanup, or a rerun of unchanged local performance proof.

@clawsweeper

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

@openclaw-barnacle openclaw-barnacle Bot added agents Agent runtime and tooling size: XS maintainer Maintainer-authored PR labels Sep 13, 2026
@steipete
steipete marked this pull request as ready for review September 13, 2026 07:46
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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 13, 2026
@clawsweeper

clawsweeper Bot commented Sep 13, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 13, 2026, 5:59 AM ET / 09:59 UTC (Revision 5).

ClawSweeper review

What this changes

Skip delivery-directive parsing for assistant text without marker prefixes, extend transcript byte-preservation coverage, and close test database handles before removing fixtures.

Merge readiness

✅ Ready for maintainer review

This remains a useful, narrowly scoped optimization absent from current main and the latest release. No actionable correctness findings remain; the supplied real SQLite measurements support the bounded performance claim.

Priority: P2
Reviewed head: 5d54b16f66557debc73af5b463f83172bce7dc19

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A small, correct optimization with strong production-path measurements and focused compatibility coverage.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured PR body supplies before/after public SessionManager append-and-flush measurements through real SQLite on Node 24 and 26, with complete output parity and observed code-heavy append improvements; mixed controls appropriately limit the claim.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured PR body supplies before/after public SessionManager append-and-flush measurements through real SQLite on Node 24 and 26, with complete output parity and observed code-heavy append improvements; mixed controls appropriately limit the claim.
Evidence reviewed 9 items Verified introduced change: The pinned merge-base-to-head diff contains the text-block shortcut and focused persistence-fixture changes. Endpoint drift was excluded from patch attribution.
Shortcut matches the directive grammar: Reply, audio, malformed-prefix, and TTS recognition all require literal [[. Without it, the previous parser normalizes text but the delivery owner discards that result. The new continue stays inside the block loop, preserving final managed-media recording.
Current main still performs the unused work: The fetched main revision calls the parser for every assistant text block without the proposed prefix check.
Findings None None.
Security None None.

How this fits together

OpenClaw prepares assistant messages for live session state and transcript storage through a shared delivery-directive owner. It extracts reply and speech instructions while preserving ordinary text and recording managed-media references.

flowchart TD
  A[Assistant message blocks] --> B{Text contains marker prefix?}
  B -->|Yes| C[Existing directive parsing]
  B -->|No| D[Preserve original text]
  C --> E[Merge delivery facts and media references]
  D --> E
  E --> F[Live session and SQLite transcript]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +3, Tests +15. Total +18 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 3 0 +3
Tests 1 17 2 +15
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 20 2 +18

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #146829
Summary: This PR implements the specific optimization requested by the linked open issue.

Members:

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

Technical review

Best possible solution:

Keep the optimization at the existing transcript delivery owner while preserving parser behavior for other callers and exact stored message bytes.

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

Yes: current source unconditionally normalizes marker-free assistant text and discards the result; the supplied SQLite append measurements exercise that path. This review did not rerun the benchmark.

Is this the best way to solve the issue?

Yes: the owner-specific shortcut avoids unused work without changing the shared parser's existing normalization contract or adding another implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: Measured unnecessary work affects assistant transcript appends, with a narrow optimization and limited blast radius.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The captured PR body supplies before/after public SessionManager append-and-flush measurements through real SQLite on Node 24 and 26, with complete output parity and observed code-heavy append improvements; mixed controls appropriately limit the claim.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured PR body supplies before/after public SessionManager append-and-flush measurements through real SQLite on Node 24 and 26, with complete output parity and observed code-heavy append improvements; mixed controls appropriately limit the claim.

Evidence

What I checked:

  • Verified introduced change: The pinned merge-base-to-head diff contains the text-block shortcut and focused persistence-fixture changes. Endpoint drift was excluded from patch attribution. (src/config/sessions/transcript-assistant-delivery.ts:75, 5d54b16f6655)
  • Shortcut matches the directive grammar: Reply, audio, malformed-prefix, and TTS recognition all require literal [[. Without it, the previous parser normalizes text but the delivery owner discards that result. The new continue stays inside the block loop, preserving final managed-media recording. (src/utils/directive-tags.ts:182, 5d54b16f6655)
  • Current main still performs the unused work: The fetched main revision calls the parser for every assistant text block without the proposed prefix check. (src/config/sessions/transcript-assistant-delivery.ts:75, 0d1cf24318b8)
  • Latest release comparison: The supplied latest release, v2026.9.4, also lacks the shortcut; this optimization is not already shipped there. (src/config/sessions/transcript-assistant-delivery.ts:75, 3a9d69db306c)
  • Persistence and cleanup coverage: The complete persistence suite extends an existing public SessionManager test with CRLF, whitespace, and Markdown byte checks across live, persisted, and reopened messages. Cleanup drains owned session work and closes database handles before directory deletion; existing assertions remain intact. (src/agents/sessions/session-manager.persistence-compat.test.ts:31, 5d54b16f6655)
  • Real production-path performance evidence: The fully supplied PR body at captured sourceRevision 992b44a2edbf94907b1dd7ce641aa2debf71357c3c3727959afe74e2af71b229 reports public SessionManager open/append/flush runs against real isolated SQLite on Node 24.19 and 26.8: 12 child processes, 6,696 successful output comparisons, and 18 workloads. Fenced 16K append medians improved from 8.932 to 3.021 ms and 10.869 to 3.149 ms respectively. Slower controls and first-append outliers are explicitly retained. These are contributor observations, not executions performed during this review. (5d54b16f6655)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Vyctor H. Brzezowski: 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 (4 earlier review cycles)
  • reviewed 2026-09-13T07:53:06.231Z sha 49566e6430ed7b9ad9c4eab3cd16fe61790333aa :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T08:07:44.490Z sha 49566e6430ed7b9ad9c4eab3cd16fe61790333aa :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T08:54:22.932Z sha 5d54b16 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-13T09:45:30.457Z sha 5d54b16 :: needs maintainer review before merge. :: none

@steipete
steipete force-pushed the codex/v8-assistant-directive-scan branch from 49566e6 to 5d54b16 Compare September 13, 2026 08:43
@steipete steipete closed this Sep 13, 2026
@steipete steipete reopened this Sep 13, 2026
@steipete
steipete merged commit 8843203 into main Sep 13, 2026
327 of 332 checks passed
@steipete
steipete deleted the codex/v8-assistant-directive-scan branch September 13, 2026 10:15
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

vincentkoc added a commit that referenced this pull request Sep 13, 2026
* refs/heads/temp/pr-146883: (159 commits)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  fix(ui): let slow dashboard downloads finish before recovery (#146881)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
* refs/heads/temp/pr-146833: (43 commits)
  fix(memory): preserve newer indexes and disclose automatic rebuild costs (#146908)
  fix: retain route ownership while discovering conversations (#146927)
  refactor: reuse plugin fixture shell runner (#146920)
  fix(worker): stop preparing disabled live previews (#146896)
  fix(runtime): support Bun across tooling suite (#146807)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  ...
vincentkoc added a commit that referenced this pull request Sep 13, 2026
…ssion-list-roster-batch-20260913

* commit 'f513c0f345f7f2514c49ccfbc00adc3f78b9a755': (46 commits)
  chore(i18n): refresh native locales (#146924)
  perf(secrets): limit expiry metadata to transient credentials (#146882)
  fix(ui): preserve queued refreshes during session discovery (#146535)
  test(ui): wait for quiet scrolling and close named file tabs (#146836)
  fix(ui): prevent Usage hour filters from freezing during DST (#146919)
  test(ui): share browser page cleanup across layout fixtures (#146805)
  ci: balance complete PR runtime test groups (#146916)
  improve(infra): reduce scheduling work for session notice bursts (#146818)
  improve: prepare Gateway skill commands asynchronously (#146812)
  improve(agents): skip unused assistant delivery parsing (#146858)
  improve(ui): reuse date formatters across timestamp lists (#146789)
  fix(tests): isolate installer and Docker shell snippets (#146897)
  test(heartbeat): share explicit channel configuration fixtures (#146853)
  fix: retain conversation reply claims through write admission (#146866)
  perf(sessions): bound history reads and stabilize cursor paging (#146770)
  fix(ui): let slow dashboard downloads finish before recovery (#146881)
  fix: share Doctor lifecycle coordination with SQLite workers (#146714)
  fix: retain native session model provenance (#146801)
  fix: settle embedded transcript repairs before session cleanup (#146842)
  feat(macos): improve agent navigation and chat layout (#146531)
  ...
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 14, 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 P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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.

Avoid unused directive parsing when saving assistant replies

1 participant