Worktree isolation: a subagent spawned before EnterWorktree has every Bash call refused afterward
Status Open
Maintainer reply None cached
Workaround ✓ Mentioned in description ↑
Activity 0 comments · opened Sep 23, 2026
Summary
In a background job, a subagent that was started before the parent session called EnterWorktree had every Bash call refused once the parent entered the worktree, including trivial commands such as ls. Its task ended half-done.
Details
- Claude Code 2.1.2xx (Linux), background job session.
- Sequence: the parent spawns a subagent (Agent tool) for a read-only investigation. The parent then calls
EnterWorktreeto begin editing. From then on, each of the subagent's Bash calls came back with the worktree-isolation refusal, so it couldn't continue. - This is from a field report in my own job logs. I haven't built a minimal repro yet, because reproducing it means deliberately breaking a running subagent.
Expected
Either:
- a subagent that was already running keeps its original working directory and isolation state, or
- it is moved into the parent's worktree, so plain commands inside that worktree still pass.
Refusing every command, including ones that never touch git, leaves the subagent stuck with no way forward.
Workaround
Call EnterWorktree before spawning any subagent.
Related: #88312, #85266 (Bash refusing every command after entering a sibling worktree).