fix: subagent file modifications invisible to checkpoint detection (ENT-297)#323
Draft
fix: subagent file modifications invisible to checkpoint detection (ENT-297)#323
Conversation
…gents This function extracts modified file paths from both the main transcript and any subagent transcripts spawned via the Task tool. It follows the same pattern as CalculateTotalTokenUsage: parse once, extract agent IDs, read subagent transcripts, and merge results with deduplication. This is the foundation for fixing ENT-297 where subagent-only file changes were invisible to checkpointing. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 732abe6dd3e4
Replace extractModifiedFiles (main transcript only) with claudecode.ExtractAllModifiedFiles which also parses subagent transcripts. This fixes the core bug where subagent-only file changes produced totalChanges=0, causing checkpoints to be skipped. Falls back to main-transcript-only extraction on error. Also reuses the subagentsDir variable for token usage calculation to avoid redefinition. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 732abe6dd3e4
…difications The PrepareCommitMsg hook's live transcript check only scanned the main transcript via ExtractModifiedFilesFromOffset, missing file changes made by subagents spawned via the Task tool. When the main transcript contained only Task calls (no direct Write/Edit), modifiedFiles was empty and the function returned false -- causing missing checkpoint trailers on commits that included subagent-written files. After the existing main transcript scan, also call claudecode.ExtractAllModifiedFiles which parses both the main and subagent transcripts, picking up Write/Edit tool calls from subagent files. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 732abe6dd3e4
…-297) Verify that the Stop hook creates checkpoints when only subagents modify files. The test constructs a main transcript with only a Task tool call and a subagent transcript with Write tool calls, then confirms both auto-commit and manual-commit strategies detect the changes via ExtractAllModifiedFiles. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 732abe6dd3e4
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes ENT-297 by ensuring checkpoint detection includes file modifications performed by Claude Code subagents (spawned via the Task tool), so turns aren’t skipped when only subagents write/edit files.
Changes:
- Added
claudecode.ExtractAllModifiedFiles()to aggregate modified files across main + subagent transcripts. - Updated Claude Code stop hook (
commitWithMetadata) and mid-session “new content” detection to include subagent transcripts. - Added unit and integration tests to cover subagent-only modification scenarios.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| cmd/entire/cli/agent/claudecode/transcript.go | Adds ExtractAllModifiedFiles() to collect modified files from main + subagent transcripts. |
| cmd/entire/cli/hooks_claudecode_handlers.go | Stop hook now uses ExtractAllModifiedFiles() for subagent-aware modified-file detection. |
| cmd/entire/cli/strategy/manual_commit_hooks.go | Mid-session commit detection now checks subagent transcripts for Claude Code sessions. |
| cmd/entire/cli/agent/claudecode/transcript_test.go | Adds unit tests for ExtractAllModifiedFiles() (subagent inclusion + dedupe cases). |
| cmd/entire/cli/strategy/mid_turn_commit_test.go | Adds test ensuring subagent-only changes are detected as “new content.” |
| cmd/entire/cli/integration_test/hooks_test.go | Adds integration regression test for stop-hook checkpointing when only subagents modify files. |
| cmd/entire/cli/strategy/registry.go | Updates //nolint:ireturn rationale comment. |
| cmd/entire/cli/strategy/manual_commit.go | Updates //nolint:ireturn rationale comment. |
| cmd/entire/cli/strategy/auto_commit.go | Updates //nolint:ireturn rationale comment. |
This was referenced Feb 13, 2026
- Add logging.Debug when ExtractAllModifiedFiles errors in sessionHasNewContentFromLiveTranscript (was silently swallowed) - Fix AddTaskToolResult to produce "agentId: <id>" format matching real Claude Code transcripts (was "Task completed by agent <id>") - Use AddTaskToolResult in integration test instead of reaching into TranscriptBuilder internals Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> Entire-Checkpoint: 1facd4391816
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ExtractAllModifiedFiles()that scans both the main agent transcript and subagent transcript files (agent-<id>.jsonl) for Write/Edit/NotebookEdit tool callscommitWithMetadata) to useExtractAllModifiedFilesso checkpoints aren't skipped when only subagents modify filessessionHasNewContentFromLiveTranscript(mid-session commit detection) to also check subagent transcriptsFixes ENT-297
Test plan
ExtractAllModifiedFiles(4 cases: includes subagent files, deduplicates, no subagents, subagent-only changes)sessionHasNewContentFromLiveTranscriptwith subagent-only modificationsTestHookRunner_SimulateStop_SubagentOnlyChanges(both auto-commit and manual-commit strategies)mise run fmt && mise run lint && mise run test:ci)🤖 Generated with Claude Code