Teammate spawns silently ignore isolation: "worktree" parameter (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1)
Summary
When dispatching a teammate via Agent({team_name, ..., isolation: "worktree"}) (with CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 enabled), the isolation: "worktree" parameter is silently ignored. The teammate inherits the team-lead's cwd and shares the team-lead's working tree — corrupting shared git state across concurrent teammates.
For standalone Agent({...}) dispatches (no team_name), isolation: "worktree" works correctly. The silent-ignore is specific to team-based dispatches.
Environment
- Claude Code: v2.1.114 (also reproduced on v2.1.96+)
- OS: Linux (WSL2)
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1set in~/.claude/settings.json
Steps to Reproduce
- Set
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1in settings. - Create a team via
TeamCreate. - From the team-lead, dispatch two teammates concurrently via
Agent({team_name: "<team>", isolation: "worktree", ..., prompt: "<task that creates a commit>"}). - Both teammates run their
git add/git commitin the team-lead's working tree rather than separate worktrees. - Observed corruption: one teammate's commit lands on the OTHER teammate's branch (because of HEAD races during
git checkout -binterleavings).
Expected Behavior
isolation: "worktree" should create a separate git worktree for each teammate, just as it does for standalone Agent dispatches. Concurrent teammates should not share working-tree state.
Actual Behavior
The parameter is silently accepted but not honored. Teammates inherit the team-lead's cwd. Concurrent teammates share working-tree state. Race conditions on git checkout -b interleavings cause commits to land on wrong branches.
Workaround
The team-lead must instruct git-touching teammates to invoke EnterWorktree as their first action before any git commands, e.g.:
First action: invokeEnterWorktree— your cwd inherits from the team-lead and you WILL corrupt shared git state if you don't. Verify you're in a worktree viapwdandgit -C . rev-parse --git-dirbefore touching any files.
This is fragile (relies on the teammate following the brief), and read-only teammates that don't touch git can skip it (which is fine, but the brief has to call out the read-only carve-out).
Why this matters
The whole point of isolation: "worktree" is to enable concurrent agents to share a repo without race conditions. For the team-based dispatcher pattern (which is what CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 enables and is presumably the experimental future of multi-agent workflows), the silent-ignore defeats the entire premise — and the failure mode is silent corruption of git state rather than a clean error.
A single-line fix would be to either:
- Honor the parameter for teammate spawns (the right fix), OR
- Reject it at parse time with a clear error pointing at the workaround (so users don't expect isolation that isn't there)
Related
#36182—Edittool absolute-path leak in worktrees (different surface, related root cause: harness not enforcing worktree boundaries on tool calls)#42282— sub-agent cwd drift back to parent (similar class of leakage, separate variant)- A receiving project documents the workaround in
CLAUDE.mdunder "Experimental agent teams: teammate self-isolation required for git-touching tasks."
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗