You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Worktree creation reports ref_not_found when the branch is checked out in another worktree #38027
What happens. Creating a thread worktree for a PR head branch fails with ref_not_found when that branch is already checked out in a sibling worktree. The branch exists; git refuses because it is in use elsewhere.
Expected. Say so: "branch X is checked out in worktree Y". Better: offer a detached worktree at the branch head.
Seen. 3 separate agent sessions in one week. Each made a detached worktree by hand.
@mihaisavezi Which action produced the ref_not_found error (opening a PR as a worktree thread in the app, t3_thread_launch from an agent with which baseRef/branch/startFromOrigin values, or something else), and what was the full error text?
Thanks, and a correction first: after pulling the exact calls from the logs, my original diagnosis was wrong. The branch being checked out in another worktree was a guess the agents made from the error; it wasn't the cause.
Action:t3_thread_launch from an agent in another thread (not the app UI), 2 occurrences (3 Nov and 10 Nov), each retried a few times with the same result:
No branch was passed. In both cases the baseRef was wrong: the launching agent built the branch name from memory, and no such branch existed on origin (git ls-remote origin confirms it). The PR head was a similar but different name (for example origin/feature/<id>-overview-header passed, real branch feature/<id>-overview).
Full error text (thread activity item, identical every time):
Workspace preparation failed during provision worktree: Git command failed in GitVcsDriver.createWorktree.createBranch (/path/to/project): git worktree add failed (ref_not_found)
So ref_not_found was correct. What went wrong is that the message never names the ref, and it is reported from createBranch. Both agents (and I) misread it: one decided the local base branch was missing and created it, the other decided the PR branch was checked out in another worktree. On Retry the same bad baseRef failed again.
Suggested fix (smaller than my original ask):
Name the ref and where it was looked up: baseRef "origin/feature/x" not found on origin.
Optionally, have t3_thread_launch check the baseRef before creating the thread and return the error to the calling agent, so it can correct the name instead of leaving a failed thread behind.
Activity
juliusmarminge commentedon Nov 17, 2026
@mihaisavezi Which action produced the ref_not_found error (opening a PR as a worktree thread in the app, t3_thread_launch from an agent with which baseRef/branch/startFromOrigin values, or something else), and what was the full error text?
mihaisavezi commentedon Nov 17, 2026
Thanks, and a correction first: after pulling the exact calls from the logs, my original diagnosis was wrong. The branch being checked out in another worktree was a guess the agents made from the error; it wasn't the cause.
Action:
t3_thread_launchfrom an agent in another thread (not the app UI), 2 occurrences (3 Nov and 10 Nov), each retried a few times with the same result:{"workspaceStrategy": {"type": "worktree", "baseRef": "origin/<feature-branch-name>", "startFromOrigin": true}}No
branchwas passed. In both cases thebaseRefwas wrong: the launching agent built the branch name from memory, and no such branch existed on origin (git ls-remote originconfirms it). The PR head was a similar but different name (for exampleorigin/feature/<id>-overview-headerpassed, real branchfeature/<id>-overview).Full error text (thread activity item, identical every time):
So
ref_not_foundwas correct. What went wrong is that the message never names the ref, and it is reported fromcreateBranch. Both agents (and I) misread it: one decided the local base branch was missing and created it, the other decided the PR branch was checked out in another worktree. On Retry the same badbaseReffailed again.Suggested fix (smaller than my original ask):
baseRef "origin/feature/x" not found on origin.t3_thread_launchcheck thebaseRefbefore creating the thread and return the error to the calling agent, so it can correct the name instead of leaving a failed thread behind.Happy to retitle the issue to match this.
juliusmarminge commentedon Nov 17, 2026
This is the same problem as #36268, so I'm closing it in favour of that one. If it is different, say how and it will be reopened.