Teammate spawns silently ignore isolation: "worktree" parameter (CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1)

Resolved 💬 3 comments Opened Apr 18, 2026 by mikehenson Closed Apr 21, 2026

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=1 set in ~/.claude/settings.json

Steps to Reproduce

  1. Set CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 in settings.
  2. Create a team via TeamCreate.
  3. From the team-lead, dispatch two teammates concurrently via Agent({team_name: "<team>", isolation: "worktree", ..., prompt: "<task that creates a commit>"}).
  4. Both teammates run their git add/git commit in the team-lead's working tree rather than separate worktrees.
  5. Observed corruption: one teammate's commit lands on the OTHER teammate's branch (because of HEAD races during git checkout -b interleavings).

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: invoke EnterWorktree — your cwd inherits from the team-lead and you WILL corrupt shared git state if you don't. Verify you're in a worktree via pwd and git -C . rev-parse --git-dir before 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

  • #36182Edit tool 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.md under "Experimental agent teams: teammate self-isolation required for git-touching tasks."

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗