Agent tool isolation: "worktree" forks from default branch instead of caller's current HEAD
Summary
When dispatching a subagent via the Agent tool with isolation: "worktree" from a non-default branch, the resulting worktree consistently forks from the default branch (main) instead of the caller's current branch HEAD. This silently gives subagents the wrong baseline.
Environment
- Claude Code: 2.1.96 (observed in-session)
- Platform: darwin 25.3.0
- Repo: standard git repo with
mainas default, other local branches checked out
Reproduction
git checkout -b feature-branchand make one or more commits on it- Dispatch a subagent from the Agent tool with
isolation: "worktree"and anysubagent_type - Inside the worktree, the subagent sees
git log --oneline -5showingmain's HEAD, notfeature-branch's HEAD - Files modified on
feature-branchare missing from the subagent's working tree
Observed frequency
In a single session running an iterative multi-agent loop, 8 of 9 dispatches forked from \main\ instead of the current branch. One dispatch had no worktree created at all; the agent edited the parent checkout directly.
Expected
Worktree should fork from the caller's current branch HEAD, matching what \git worktree add\ does with no explicit ref.
Impact
Subagents receive stale baselines, silently revert or skip work from prior commits, and produce diffs that cannot cleanly merge back. In iterative workflows where each step builds on the previous one, this breaks the pipeline unless every dispatch includes a manual baseline-sync workaround.
Workaround
Have the subagent run \git checkout <current-branch> -- <paths>\ and commit a \"baseline-sync\" as its first action, then extract only its incremental work via \git diff baseline-sync HEAD\ on merge.
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗