Repository navigation
Isolate orchestration workers in their own git worktree - #50
Merged
currentbits merged 2 commits intoAug 15, 2026
Merged
Conversation
… Agents panel re-queries all threads' messages on every strea
thread_fork copied provider/model/permissionMode but never set up isolation, so every worker edited the project checkout — N parallel workers, one working copy. Mark the fork pendingWorktree so the runner materializes a worktree + branch at first run, the same lazy path threads:create uses. Skipped when the project cannot host one (remote, or not a git repo) or when the caller passes worktree:false, so those forks share the checkout as before instead of failing the run. Co-Authored-By: Claude Opus 5 <[email protected]>
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
currentbits
deleted the
coder/orchestration-workers-share-the-project--a2f5ed
branch
October 3, 2026 16:07
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.
Fixes #30.
Problem
thread_fork(thecoder-threadsMCP tool an orchestrator uses to spawn workers) copied provider, model and permissionMode from the source thread but never set up any isolation.runner.jsresolves a run's cwd tothread.worktreePath || project.path, so every forked worker ran in the project checkout — N parallel workers editing one working copy. BRAINSTORM.md names this as the #1 agent disaster to prevent ("Isolation by default", "merge hell factory").Change
thread_forknow marks the forkpendingWorktree: truealongsideorchWorker: true. That reuses the existing lazy worktree path already used bythreads:create—runner.materializePendingWorktree→worktrees.ensureWorktreecreates the worktree + branch at first run start, so a fork that never runs still leaves nothing on disk. No new worktree machinery.Two escape hatches, so this never turns a working fork into a failing one:
canHostWorktree()skips remote projects (same rule asthreads:create) and directories that aren't git repos, wheregit worktree addwould just fail the worker's run. Those forks share the project checkout exactly as before.worktree: falsefor workers that should deliberately run in the project checkout.The tool description and server instructions now tell the orchestrator that workers are isolated and that a worker's branch needs merging when its work lands.
Verification
node --test electron/test/orch-server.test.js— tool-handler suite 13 pass, including a new test covering all four branches (default →pendingWorktree,worktree: false, remote project, non-repo). The 9 failures in the HTTP and provider-injection suites are pre-existing in this worktree (baseline before the change: 12 pass / 9 fail); they need@modelcontextprotocol/sdk, which isn't installed here.Not included
Base-branch inheritance: a worker forked from a thread that is itself in a worktree branches off project HEAD, not the parent's branch. Worth adding if orchestrators routinely run inside worktrees themselves.