isolation: "worktree" silently fails when combined with team_name parameter
Description
When using isolation: "worktree" together with team_name on an Agent call (agent teams feature via CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1), the worktree creation silently fails. Agents land in the main working directory instead of an isolated worktree. No error is raised — the agent proceeds as if no isolation was requested.
Reproduction
- Enable agent teams:
"CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS": "1"in settings - Create a team via
TeamCreate - Spawn an agent with both
team_nameandisolation: "worktree":
````
Agent(
name: "worker",
team_name: "my-team",
isolation: "worktree",
run_in_background: true,
prompt: "Run git rev-parse --show-toplevel and report the result"
)
- The agent reports the main repo root, not a worktree path
Expected behavior
The agent should run in a temporary git worktree (a separate directory), and git rev-parse --show-toplevel should return the worktree path, not the main repo root.
Actual behavior
git rev-parse --show-toplevel returns the main project root. The agent is in the main working directory with no isolation.
Impact
- All 3 agents dispatched in a single session hit this — it's 100% reproducible, not intermittent
- Without the worktree, parallel agents editing the same repo can cause conflicts
- Workaround: verify file disjointness upfront and allow agents to proceed in the main directory, but this defeats the purpose of isolation
Environment
- macOS (Darwin 25.3.0)
- Claude Code with
CLAUDE_CODE_EXPERIMENTAL_AGENT_TEAMS=1 - Model: Claude Opus 4.6
Workaround
Add a "worktree check" to agent prompts (git rev-parse --show-toplevel) so agents detect the failure immediately. If agents are file-disjoint, the lead can override and allow them to proceed in the main directory.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗