Match background subagents' shell-written files by mtime

Commit

Soph3d ago

The transcript analyzer only sees edit tool calls, so a background subagent that changed files through Bash (printf > file, scripts, formatters) recorded no files on its task, and its lines were counted as the user's. agent-scenarios saw this in every Bash-only run; in local transcripts, 99% of subagents use Bash and 13% use edit tools.

Claude Code now reports the time window of each Bash and edit call (ToolCallWindowExtractor). A changed file the analyzer did not name is the subagent's when its mtime falls inside one of the subagent's write-looking shell calls and no other agent's write-capable call in the session. When calls overlap, the side whose calls name the file wins; otherwise the file is ambiguous: it counts as agent work for attribution but is not listed on the task. Files modified outside every agent call stay the user's.

A prototype over 339 known subagent edits in local transcripts attributed none to the wrong agent; 88% matched one agent and 12% were ambiguous.

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

Checkpoints

Fix Claude Code Subagent Attribution Issues

Claude CodeOpus 5.5
View session
Checkpoint 1