Credit background subagent edits to the agent, not the user

Commit

Soph3d ago

A Claude Code background subagent finishes after the parent's turn ended. Its completion writes no shadow snapshot, and the task-notification starts the next turn in the same instant. Turn-start prompt attribution then diffs the worktree against a snapshot that lacks the subagent's edits and counts every line as user work, so the checkpoint records agent_lines: 0.

Track files a subagent wrote since the last snapshot in PendingSubagentFiles. Task completion adds them; turn start adds files from still-running subagents' transcripts, covering the notification turn that wins the race with SubagentStop. Turn-start attribution skips them, turn end snapshots them, and SaveStep clears them, including on a skipped step whose tree already holds them. A commit before the next snapshot uses their committed content in place of the stale snapshot, and condensation drops the committed ones.

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

Checkpoints

Fix Claude Code Subagent Attribution Issues

Claude CodeOpus 5.5
View session
Checkpoint 1