Agent isolation: "worktree" branches from a stale commit, not session HEAD

Status Open
Maintainer reply None cached
Activity 1 comment · opened Aug 23, 2026

What happened

I spawned three background agents with isolation: "worktree" from a session whose repo was on branch spec/183-strip-table-rules, which I had just created and pushed. Every worktree was created on a branch based on 1b8faf5 — a real commit on main from six days earlier, 77 commits behind the branch head and 76 behind main's own tip.

$ git log -1 --format='%h %ad %s' --date=short 1b8faf5
1b8faf5 2026-08-17 Absorb xcodebuild's reserialisation of the test group

$ git rev-list --count 1b8faf5..main
76

The session HEAD at spawn time was b6b5be8 on spec/183-strip-table-rules. Nothing in any of the three prompts mentioned 1b8faf5, and no agent asked for it.

Two of the three agents noticed on their own and ran git reset --hard onto the branch before starting. The third did not: it implemented its ticket, built, tested and ran a release check — all green — against a tree 77 commits stale. Its work then produced genuine merge conflicts when landed, and its verification evidence was against a tree that existed nowhere else.

Why it matters

A stale worktree is not a loud failure. The agent works, reports success, and the merge resolves. From the orchestrating session it is indistinguishable from a clean run, and every test result the agent reports is against the wrong tree.

Expected

A worktree created by isolation: "worktree" branches from the session's current HEAD, or at minimum from the tip of the current branch.

Notes

  • Three worktrees, spawned across two separate Agent calls several minutes apart, all landed on the same stale commit — so it is not a race with the push.
  • A fourth worktree, created later in the same session after further commits, was correctly at the branch head. So it is not unconditional.
  • .claude/worktrees/ had no leftover directories before the run; git worktree list showed only the main checkout.

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗