Background-session write guard blocks Edit/Write into a subagent's OWN fresh worktree (guard keys off parent state, not target path)
Environment
Claude Code background session (bg job), Agent-tool subagent dispatched WITHOUT isolation: "worktree", where the subagent's own procedure creates a git worktree under .claude/worktrees/ (via EnterWorktree or git worktree add) and then edits files inside it.
Symptom
The subagent's Edit/Write calls into its own freshly-created worktree are refused with the background-session isolation guard ("parent session hasn't isolated / EnterWorktree first") — even though the write target is exactly the isolation the guard exists to enforce: a path inside a registered .claude/worktrees/* worktree.
Additionally, EnterWorktree is unsatisfiable from inside such a seat when its cwd was pinned at launch: both the path-switch and name-create forms are rejected, so the seat cannot cure the guard's demand itself.
Evidence
Five consecutive production builds hit it back-to-back (2026-08-13) in adiahealth/gen-ui-kit (private; issues gh#1207–#1211 record per-build Findings). Each seat fell back to Bash-driven edits (python heredocs cd'd into the worktree) — functionally fine, but it bypasses Edit/Write's file-state tracking and made every build slower and riskier.
Expected
The guard should pass any write whose RESOLVED TARGET lies inside a registered .claude/worktrees/* worktree of the repo, regardless of the parent session's own isolation state. Keying the check off parent state makes the guard reject precisely the behavior it wants to encourage.
Notes
- Subagents dispatched WITH
isolation: "worktree"are unaffected (the harness-created worktree is recognized); the failure is specific to seats that create their own worktree as part of their procedure — a common pattern for build agents that manage a branch/PR lifecycle. - Related report from the same session family: #86243 (concurrent sibling EnterWorktree race).
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗