Keep turn tokens on undetected changes; snapshot only live sessions

main

Commit

Soph2d ago
  • A turn whose change detection found nothing now goes through the normal turn-end path with SkipWhenUnchanged, instead of a bare snapshot: when the snapshot does capture a change (a shell edit to a pre-existing untracked file), the step carries the turn's tokens. SaveStep returns ErrNothingToSnapshot when nothing changed, and only then does the old checkpoint-less tail (out-of-band tokens, transition, cleanup) run.
  • Agent-stop snapshots use ExistingSessionOnly: SaveStep skips session initialization and checks for an ended session under its own state lock, so a snapshot racing SessionEnd or cleanup can neither write to an ended session nor recreate a removed one.

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com Entire-Checkpoint: 01M43NM148NVHRBS14MRNJ7PBJ

Checkpoints

Fix Claude Code Subagent Attribution Issues

Claude CodeOpus 5.5
View session
Checkpoint 1