[Bug] Agent isolation: "worktree" flag ignored for concurrent background agents

Open 💬 5 comments Opened Apr 15, 2026 by bretesq

Bug Description
--- Title: Agent tool's isolation: "worktree" flag silently ignored for concurrent background agents Summary The Agent tool accepts isolation: "worktree", documented as "creates a temporary git worktree so the agent works on an isolated copy of the repo." When launching 3 concurrent background agents with this flag, no worktrees were created — all three agents ran in the shared main working tree and clobbered each other's uncommitted files via concurrent branch switches. Repro 1. From a branch with some existing state, launch 3+ agents in a single message: Agent({ subagent_type: "general-purpose", isolation: "worktree", run_in_background: true, prompt: "git checkout -b test-<N> origin/main, write some new files, build, commit, push, open PR" }) 2. Let them run concurrently. Expected: each agent gets its own worktree under .claude/worktrees/<something>. Main working tree and other agents' trees remain untouched. Actual: - task-notification result includes worktreePath: /path/to/repo/.claude/worktrees/null (literal string "null") for every agent. - No worktrees appear in git worktree list that correspond to the agents. - All agents operate on the shared main working tree. When one runs git checkout -b …, it switches the branch for all; uncommitted/untracked files from the other agents get stashed, lost, or reverted. - Multiple agents independently reported: "a concurrent /batch agent clobbered the main repo working tree mid-run, dropping my first set of file writes." …
Note: Content was truncated.

View original on GitHub ↗

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