Address the second trail-review round on following the agent

Commit

peyton-alt6d ago
  • A repeated payload is not a move. Claude Code resets its shell's working directory after each command, so an agent working in a worktree through cd keeps reporting the launch checkout; its own commit re-homed it there and the next turn boundary pulled it back. The tree a payload last named is recorded (SessionState.AgentWorktree) and only a change re-homes.
  • Resolve the payload cwd by asking git, with the hook's repository overrides stripped, instead of walking up for a .git entry that ignores safe.directory and ownership.
  • Compare the payload tree with the current one symlink-resolved, through one shared paths.SameDir/Canonical instead of two copies.
  • Flush and close the logger the follower opened in the worktree it moved into; its lines never reached the worktree's log.
  • Mark a turn capture-degraded whenever new-file detection was off, including a baseline from the worktree the agent left.
  • Clear TurnWorktreePath at turn end so an agent without turn-start hooks does not reach its next turn end pointed at an earlier turn's tree.

Co-Authored-By: Claude Opus 5.5 (1M context) noreply@anthropic.com Entire-Checkpoint: 01M3T0GM1PN2NGBXF2GDBW82S8

Checkpoints

Track Subagent Work Across Worktrees

Claude CodeOpus 5.5
View session
Checkpoint 1