Repository navigation
fix(agent-manager): evict stale worktree pool slots and cold-create - #14556
Merged
Merged
Conversation
A pooled slot deleted on disk outside the pool made every create fail, because simple-git throws when constructed on a missing directory and the exception bypassed the pool discard path. Validate the slot before use, evict stale entries, and try remaining slots before falling back to a cold worktree add. Log worktree creation failures to the Output channel.
Contributor
Code Review SummaryStatus: No Issues Found | Recommendation: Merge The stale-slot eviction is guarded before Files Reviewed (5 files)
Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0 Review guidance: REVIEW.md from base branch |
marius-kilocode
enabled auto-merge
September 25, 2026 07:57
chrarnoldus
approved these changes
Sep 25, 2026
This was referenced Sep 25, 2026
This was referenced Sep 26, 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
Fixes #14453.
When a pooled Agent Manager worktree slot was deleted on disk outside the extension (for example by a worktree-hygiene script), every later worktree create failed in about 1.7 s with no git side effects. The pool kept returning the dead slot, so every create failed until the extension host restarted.
Why This Change Was Made
WorktreeManager.createWorktreeImplasks the pool to claim a slot before runninggit worktree add. The pool constructed a simple-git client on the slot path before checking that the directory existed. When the directory was gone, simple-git threwCannot use simple-git on a directory that does not exist, the exception skipped the pool discard path, and the poisoned slot stayed cached in memory.The pool now validates the slot on claim. A slot whose
.gitis missing is logged, discarded, and evicted, and the claim tries the remaining slots before falling back to a normal coldgit worktree add. Worktree creation failures are also written to the extension Output channel throughctx.log(), not only the webview toast and telemetry.User Impact
Worktree creation recovers automatically after an externally deleted pool slot. Users no longer need to disable the worktree pool or reload the window.
Evidence
New regression tests use a real temporary git repository:
Automated checks from
packages/kilo-vscode/:bun test tests/unit/worktree-pool.test.ts tests/unit/worktree-create.test.ts- 14 pass, 0 failbun test tests/unit/worktree-manager.test.ts- 133 pass, 1 skipbun run typecheck- cleanbun run lint- clean