fix(agent-manager): speed up long-session forks - #13666
Merged
Merged
Conversation
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Files Reviewed (14 files)
Reviewed by grok-4.6 · Input: 329K · Output: 21.1K · Cached: 895.1K Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
September 1, 2026 12:35
iscekic
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
Forking a long Agent Manager transcript waits for the backend to copy the entire history. A synthetic session with 2,000 messages and 6,000 parts took approximately 7.10 seconds before the fork's first transcript page arrived. Most of that time was outside the webview: copying used thousands of individual durable-event transactions, and every copied message/part was then sent twice over SSE.
Why This Change Was Made
Batch copied history into one transaction per flush while retaining the existing projectors, durable event rows, per-session sequence ordering, and notifications after commit. This also applies to copied child sessions and reference remapping. Keep the implementation and publishing adapter in Kilo-owned files, with small integration hooks in shared code.
VS Code now opts out of only the duplicate
syncenvelopes for copied message/part events, before those envelopes enter the SSE queue. Normal message/part updates, live sync events, in-process cloud ingestion, and default SSE clients remain unchanged. Workspace replication still receives the complete durable stream.User Impact
The matched long-session scenario improved from approximately 7.10 seconds to 2.8617 seconds for first-page arrival, approximately 4.24 seconds less waiting (59.7% lower latency, 2.48x faster). The final fork was ready after two animation frames at 2.9081 seconds.
History, parent-message references, and independent child sessions remain intact. This is not a constant-time or instant fork: the full history is still read, copied, serialized, and persisted, so larger sessions can take longer.
Evidence
Recorded performance
vscode-self-test. All retained captures report no trace data loss.The duplicate-transfer change alone reduced response latency by 367.4 ms (12.0%) and the two-frame readiness measurement by 390.1 ms (11.8%) relative to batching alone. The original capture recorded only 80.457 ms of webview JavaScript time, which ruled out tab rendering as the main source of the multi-second wait.
Precision and scope: baseline and intermediate page-arrival values above are retained rounded measurements; final timings and the later semantic marks are reported to 0.1 ms. These are single matched captures, not medians or p95 estimates. Capture windows differ, so aggregate renderer CPU/DOM counters are not presented as before/after improvements. Captures were recorded against base
ff9d04b0efduring implementation, before the behavior-preserving helper extraction/test reduction and fast-forward to currentmain.Correctness and validation