Skip to content

fix: subagent file modifications invisible to checkpoint detection (ENT-297)#323

Draft
khaong wants to merge 6 commits intomainfrom
alex/ent-297-fix-subagent-only-changes-checkpointing
Draft

fix: subagent file modifications invisible to checkpoint detection (ENT-297)#323
khaong wants to merge 6 commits intomainfrom
alex/ent-297-fix-subagent-only-changes-checkpointing

Conversation

@khaong
Copy link
Contributor

@khaong khaong commented Feb 13, 2026

Summary

  • Added ExtractAllModifiedFiles() that scans both the main agent transcript and subagent transcript files (agent-<id>.jsonl) for Write/Edit/NotebookEdit tool calls
  • Updated the Stop hook (commitWithMetadata) to use ExtractAllModifiedFiles so checkpoints aren't skipped when only subagents modify files
  • Updated sessionHasNewContentFromLiveTranscript (mid-session commit detection) to also check subagent transcripts
  • Added integration test verifying checkpoint creation when only subagents modify files

Fixes ENT-297

Test plan

  • Unit tests for ExtractAllModifiedFiles (4 cases: includes subagent files, deduplicates, no subagents, subagent-only changes)
  • Unit test for sessionHasNewContentFromLiveTranscript with subagent-only modifications
  • Integration test TestHookRunner_SimulateStop_SubagentOnlyChanges (both auto-commit and manual-commit strategies)
  • Full CI suite passes (mise run fmt && mise run lint && mise run test:ci)

🤖 Generated with Claude Code

khaong and others added 4 commits February 13, 2026 17:58
…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
Copilot AI review requested due to automatic review settings February 13, 2026 12:42
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

khaong and others added 2 commits February 14, 2026 09:25
- 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant