perf(coding-agent): coalesce child runtime updates - #1130
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 02d8c32. Configure here.
|
Thank you for the report and proposed work. This root cause is now covered by maintainer-owned stacked PR #1162, authored independently from We did not inspect or reuse this PR's diff, branch, commits, implementation code, or tests; its public description/comments were used only as a bug report. To keep one review surface, this PR is superseded by #1162 and is being closed. The complete review stack is #1158–#1165. It is being left unmerged for human review after CI and review-bot findings are cleared. |

Stack position
This is the direct child of #1123. Please review and merge parent-first. Exact base
821a180763e2fd20b6134fe8e661e5308f6b4af0; exact headd2223258fa362e8fed5c5209cabf59d0eacc6e98.What this delivers
AgentSessionowner while preserving lifecycle transitions and exact terminal delivery.showError, and measures scheduler cancellation/fire conservation without double-counting.Correctness boundaries
Validation
Reserved Linux runner, pinned image digest
sha256:0f66af75e00e115a81a23a97c8cf16d6ed7d895d7dd7745971a03df8b4c4d70d:tsgo --noEmit, full build: passThe earlier remote attempt at
af66e5abaremains failed because it exposed the stale structural rename. Raw attempts with 1883.24 ms at8b9b191f3and 1636.83 ms at this exact head are also retained as failures; the exact full gate and subsequent complete raw materialization passed. None is relabeled as success.Evidence
8c8cae69c6ebef708ad47ed82d3a4b309d8e93765826cd504d4a25d7fbf10e1240b051649091d3b73442a32e79504b32f367ec548c291de1ef08ea4512208c3d154e6d7f9c9a973c416829a1806eb4c3fca842e461742d4cfde785cdab140126055dfb34abb6cc77912c8c00a7a49d2ecdb7ab3b871cc34ae5d4fac631c2f7fe91468f1e0ba38a0eee127e8de724fec0c88dfdcb7141b696365e731b384a6512coordination/REMOTE_C02_FINAL_VALIDATION.mdcoordination/C02_FINAL_INTEGRATED_REVIEW.md— APPROVEcoordination/C02_STRUCTURAL_RENAME_REVIEW.md— APPROVEcoordination/C02_BOT_INTERACTIVE_INDEPENDENT_REVIEW.md— APPROVEReview history
Independent owner, daemon attachment, interactive, evidence, structural rename, and exact integrated reviews all approve the published composition.
Note
Medium Risk
Changes observable delivery timing for running-child and UI progress (macrotask batching); lifecycle, terminal, and structural ordering are explicitly preserved but downstream code that assumed every snapshot was synchronous may need review.
Overview
Reduces event-loop churn by batching replaceable progress without changing admission, provider work, or terminal semantics.
AgentSessionroutesrlm_child_updatethrough a per-child pending map andsetTimeout(0)flush so recap/tool activity keeps only the latest snapshot per child. Queued/running edges, terminal statuses, and structural renames still publish immediately (with flush-before-terminal/rename ordering). Assignment C01 fences are rechecked at enqueue and flush; pending work is cleared on dispose, abort, and update restart. Event subscribers andafterToolCallhooks that throw are isolated with capped, content-freeconsole.warndiagnostics (beforeToolCallvetoes still propagate).DaemonSupervisorreplaces eagercatchUpClientfan-out withscheduleClientCatchup(setImmediateper socket),cancelClientCatchupon disconnect/shutdown, and simplified compact-catchup dedupe so slow clients do not starve healthy attachments.InteractiveModecoalesces replaceablemessage_update/tool_execution_update/ running RLM child events by entity key (cap 128 distinct keys—overflow drains the batch instead of evicting), flushes retained progress before structural events and session replace/resync/stop, and routes flush failures throughshowError.Adds unit/integration tests and a C02 integrated harness with signed swarm evidence metadata for owner, attachment, UI, and event-loop delay bounds.
Reviewed by Cursor Bugbot for commit d222325. Bugbot is set up for automated code reviews on this repo. Configure here.
Note
Coalesce child runtime updates in
AgentSessionandInteractiveModeto reduce redundant UI eventsAgentSessionnow batches nonterminalrlm_child_updateevents per child, flushing them via a zero-delay timer; initial queued, first running, structural (session_info_changed), and terminal statuses are still published synchronously.InteractiveModegains a symmetric coalescing layer for replaceable progress events (assistant message updates, tool execution updates, child activity) bounded at 128 entries; progress is flushed before structural or terminal events and cancelled on stop/replacement.DaemonSupervisordefers per-attachment catch-up work to the next event-loop turn viascheduleClientCatchup, debouncing drain and snapshot triggers and cancelling pending work on socket close and shutdown.AgentSession._emitandafterToolCallhook failures are now caught and counted with bounded diagnostics (up to 10 warnings) instead of propagating.Macroscope summarized d222325.