perf(agent-manager): overlap MCP startup with worktree creation - #11074
Merged
Conversation
Contributor
Code Review SummaryStatus: 1 Issue Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
Other Observations (not in diff)Import grouping nit ( Files Reviewed (5 files)
Fix these issues in Kilo Cloud Reviewed by claude-sonnet-4.6 · 446,226 tokens Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
June 10, 2026 14:52
imanolmzd-svg
approved these changes
Jun 11, 2026
t7tran
pushed a commit
to t7tran/kilocode
that referenced
this pull request
Aug 14, 2026
perf(agent-manager): overlap MCP startup with worktree creation
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.
Cold Agent Manager worktree sessions currently initialize MCP servers only after worktree setup, session creation, and snapshot tracking. That makes MCP connection time a separate serial stage immediately before the first model request, even though MCP initialization does not depend on snapshot completion.
This change starts a directory-scoped MCP status request as soon as worktree setup finishes, before the CLI session is created. Session creation and the initial prompt continue without awaiting that request. The existing
mcp.tools()call remains the synchronization point before model dispatch, so tool resolution still waits if initialization is genuinely unfinished.The warmup lives in the shared Agent Manager worktree-session creation path. This covers normal New Worktree creation, configured and multi-version creation, imported worktrees, and Agent Manager tool-created worktrees without duplicating orchestration. It does not initialize MCP for unrelated directories or during extension startup. Warmup failures are caught and logged, so they cannot reject worktree/session creation or become unhandled promise rejections.
Observed cold-flow difference in the same repository and modal flow:
The end-to-end sample varied because worktree/session setup and snapshot tracking were slower in the after run. Backend ordering confirms the intended optimization independently of that variance: MCP discovery and client creation moved into snapshot initialization, completed about 4.5 seconds before snapshot tracking finished, and no longer occupied the serial
resolveTools()stage.This deliberately does not change snapshot behavior or shared CLI code. Snapshot startup remains the dominant cold-worktree cost and can be optimized independently, while this change ensures MCP initialization is already overlapped rather than becoming the next serial bottleneck.