Repository navigation
Conversation
Reuse the existing settled-directive append path when raw and projected deltas differ only in edge whitespace. Gate the comparison with existing inline-marker state so media-only streams avoid unnecessary scans. Preserve exact emitted bytes and canonical parsing at syntax and terminal boundaries. Extend the subscriber work-count regression and add a reproducible subscriber benchmark. Reply-tagged synthetic streams use 53% less CPU and 31% less allocation with block delivery off. Validation: 117 focused tests and clean Codex autoreview; changed checks retain attributed changelog and unused-export failures on the exact main parent.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex review: needs maintainer review before merge. What this changesThis PR avoids repeated whole-answer parsing when reply or voice directives leave raw and projected stream deltas differing only in edge whitespace. Example: A 32 KiB answer beginning with [[reply_to_current]] streams in 32-character deltas.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it makes a focused, worthwhile improvement to the existing streaming fast path, with no definite introduced correctness defect found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherThe embedded-agent subscriber receives provider text events, projects visible text, resolves reply directives, and forwards prepared text and metadata to preview and block-delivery consumers. flowchart LR
A[Provider text events] --> B[Embedded subscriber]
B --> C[Directive accumulator]
B --> D[Visible text projection]
C --> E[Streaming reply resolver]
D --> E
E --> F[Preview callbacks]
E --> G[Block delivery]
Technical reviewBest possible solution: Keep the fix in the existing streaming resolver, preserving exact emitted deltas and canonical parsing whenever append safety is uncertain. Do we have a high-confidence way to reproduce the issue? Source inspection confirms that edge-whitespace differences reject the existing fast path; the supplied red-on-base work counts substantiate the resulting repeated parsing, but no target code was executed during this review. Is this the best way to solve the issue? This is the smallest complete runtime repair: normalize only the eligibility comparison, retain the exact projected append, and reuse the existing parser and invalidation checks. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3a25991e37c4. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +1, Tests +8, Other +150. Total +159 across 5 files. Added test files: 0. View PR surface stats
Preflight sourceSource 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
LabelsLabel changes:
Label justifications:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed November 8, 2026, 4:38 AM ET / 09:38 UTC. |
…tooling-lint-selection-20261108 * commit 'b0e90e6a4b359fff7756698067fdce4758b1907b': (38 commits) fix(android): Talk button demands a realtime provider on a native Talk setup (#191194) chore: trace first-run Gateway work and verify later replies (#195185) fix(knowledge): keep deleted messages out of reply previews (#195126) fix(agents): preserve streamed replies across Gateway restarts (#195164) perf(ci): reuse SDK transport path boundaries (#195180) fix(sandbox): avoid pauses for unchanged command checkpoints (#195120) fix(test): make retention checks portable across runtimes (#195091) fix(knowledge): clarify temporal kind filters (#194995) improve: reduce Gateway allocation while draining SQLite receipts (#195129) fix: reduce streaming CPU after reply and voice directives (#195145) fix: reduce Markdown reparsing during streamed tool-call checks (#195161) fix: restore the main dead-export gate (#195158) improve(ci): pack small UI selections into fewer jobs (#195107) fix(muse): quota and sign-in failures end with no reply (#195148) fix: allow first release push with shipped patch bytes (#195174) fix(ci): narrow single-config tooling selections (#195147) fix(packaging): reject incompatible prepublish plugin cohorts (#195152) fix(ci): prepare verified Bun before parity checks (#195155) fix: Incognito agent turns stall before execution (#195005) fix: credentialed search and speech providers work without picking a provider (#195169) ...
…195145) Reuse the existing settled-directive append path when raw and projected deltas differ only in edge whitespace. Gate the comparison with existing inline-marker state so media-only streams avoid unnecessary scans. Preserve exact emitted bytes and canonical parsing at syntax and terminal boundaries. Extend the subscriber work-count regression and add a reproducible subscriber benchmark. Reply-tagged synthetic streams use 53% less CPU and 31% less allocation with block delivery off. Validation: 117 focused tests and clean Codex autoreview; changed checks retain attributed changelog and unused-export failures on the exact main parent.
What Problem This Solves
Fixes repeated whole-answer directive parsing while a long reply with a reply or voice tag is streaming.
User Impact
Long tagged answers need less subscriber CPU and allocation while preserving streamed text, block replies, media extraction, and final output. No configuration change.
Why This Change Was Made
The raw directive accumulator and visible projection can differ only in edge whitespace. Compare their trimmed append text before rejecting the existing settled-directive append path. Output still uses the exact projected delta; Markdown ownership, new markers, media lines, and final snapshots retain their existing checks.
Evidence
Acceptance rule, set before baseline measurement: replay 32 KiB synthetic prose, media, reply-tag, voice-tag, and mixed replies through subscribeEmbeddedAgentSession in 32-character deltas, with block delivery on and off. Five interleaved A/A/B rounds, eight warm turns per sample, identical Node/runtime compilation. Require fewer parsed characters, lower CPU and allocated bytes for tagged replies, identical final/block output hashes, and no >20% regression in control workloads. Report wall/CPU/allocated bytes per complete reply, median/p95/spread, and A/A drift. Imports and provider/network/database/workspace I/O are outside this owner benchmark.
Measured medians per complete reply (five samples × eight turns; decimal MB). Node 26.12.1 on a shared 32-CPU host; one-minute load ranged 6.98–14.07. Imports are excluded from timing:
All final-text and block-payload hashes match across all arms. Plain CPU medians moved +4.4%/+6.0%, with overlapping A/A-control ranges; no plain-stream speedup is claimed. One mixed/block wall sample rose to 276.76 ms (base maximum 212.91 ms); a separate five-pair isolated recheck did not reproduce that tail: mixed/block wall median 206.12 → 193.59 ms, maxima 225.21 → 210.66 ms; CPU median 225.10 → 212.26 ms. The original outlier remains recorded. Mixed replies still retain full parsing after media changes the cleaned suffix.
The existing subscriber work-count test now includes reply and voice prefixes. On a 32 KiB reply in 3-character deltas, the base fails with 32,619,097 and 97,714,197 parsed characters; the candidate passes the existing <1,000,000 bound. A separate 32-character-delta probe reduces reply parsing from 311 calls / 5,109,669 characters to 1 call / 32 characters (4,985.04 → 0.031 parsed characters per delta). Voice drops from 311 / 5,129,509 to 1 / 32. Block consumers add two snapshot parses totaling 32 characters to each side; final snapshot/media parses remain required.
CPU profiles over the same reply workload show inclusive directive-parser time 975.91 → 36.30 ms, including splitMediaOutput 579.33 → 19.47 ms. These are profile-window totals, separate from uninstrumented timing samples.
Run the workload with
node --expose-gc --import ./scripts/tsx.mjs scripts/perf/reply-directives-stream-measure.ts; passmixedto isolate the recheck. The fixture uses the real subscriber and delivery owners with a synthetic event source. It does not run a live model, Gateway, channel network, database or workspace. No whole-Gateway or production savings claim.Runtime production delta: +1 line, for the existing-marker guard. No new cache/state/config/parser. Tooling adds a 147-line reproducible benchmark plus its Knip entry; regression growth is eight lines extending one existing table, with an exact eight-line allocation record. The first unguarded candidate was rejected for a measured media-only slowdown; the final guard avoids that wasted path. No changes to stream normalization or shared UI modules.
Validation: 117 focused tests passed (three wrapper shards, 54.22 s including cold compilation; work-count/lifecycle tests 48 cases, 2.24 s wrapper duration). Full-context Codex autoreview is scoped-clean at P0–P2 against base
64b382cf3d73and the final five-file candidate, committed ascd9f34bd76ff. Both Knip unused-file scans passed with zero entries.pnpm check:changed --staged --base 64b382cf3d73completed with failures; its changelog-attribution check has 20 inherited violations, reproduced exactly from the frozen main-parent sources. The current signature comes from266a7aa0fe69(#194364), which expanded the excluded handles without reconciling historical changelogs. Its parent has 26 different human-credit violations and none of these 20. This is a main regression to repair, not a passing check; this PR does not change its owner or changelog data. Two benchmark-only brace lint errors were fixed and the targeted script lint rerun passed. All typechecks, core lint, format and other selected guards passed. CI seconds are pending.Timing distribution and unchanged-code controls
Values are median / p95 in milliseconds; with five eight-turn batch samples, p95 is the largest batch mean, not an estimate of individual production reply tails. A-control reruns unchanged base code. Raw final/block output hashes match for every arm.
The dead-export check also fails identically on the exact main parent
64b382cf3d73, verified in an isolated checkout with the same workspace dependencies (no module-resolution errors):scripts/plugin-npm-evidence-reuse.mjs:NPM_EVIDENCE_FILEc9e6370bb191(#195099), which added the file/exportsrc/infra/path-containment.ts:canonicalizeForContainmentSync,UncanonicalReasonce840d8a8290(#195061), which added the file/exportssrc/test-utils/retention.ts:expectCollected,expectLiveObjects,forceFullGc754b41c65df0(#195064), which added these exportsThese are outstanding main regressions, not ignored noise. No affected source, baseline, or guard is changed by this PR. The first baseline scan lacked nested workspace dependencies and was discarded; the qualified rerun reproduced the exact six-symbol set.