fix(agent): scan full transcript for spawned agent IDs#660
Open
mvanhorn wants to merge 1 commit intoentireio:mainfrom
Open
fix(agent): scan full transcript for spawned agent IDs#660mvanhorn wants to merge 1 commit intoentireio:mainfrom
mvanhorn wants to merge 1 commit intoentireio:mainfrom
Conversation
ExtractAllModifiedFiles and CalculateTotalTokenUsage were extracting spawned agent IDs from a sliced transcript (startLine onward). After a checkpoint advances startLine, subagents spawned in earlier turns became invisible - their file modifications and token usage were missed. Now agent ID extraction scans from line 0 (full transcript) while file and token extraction remains bounded to startLine. This affects both ClaudeCode and FactoryAIDroid implementations. Closes entireio#329 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
5 tasks
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
Closes #329
Fixes a bug where subagent token usage and modified files were undercounted when a checkpoint boundary (
startLine) was set.The Problem
CalculateTotalTokenUsageandExtractAllModifiedFilesboth:startLineto get the current turn's dataThe issue: subagents spawned before
startLine(in a previous turn) may still be actively writing to their transcript files during the current turn. By only scanning fromstartLine, those agent IDs were never discovered, so their token usage and file modifications were silently dropped.The Fix
Agent ID extraction now scans the full transcript from the beginning (line 0), while file/token extraction still respects the
startLineboundary. This ensures all subagents are discovered regardless of when they were spawned.Added
extractAllSpawnedAgentIDs()helper that parses the full transcript bytes independently of the startLine-sliced data.Changes
Claude Code agent (
claudecode/transcript.go):CalculateTotalTokenUsage- UsesextractAllSpawnedAgentIDs(transcriptData)instead ofExtractSpawnedAgentIDs(parsed)ExtractAllModifiedFiles- Same fixextractAllSpawnedAgentIDs()helperFactory AI Droid agent (
factoryaidroid/transcript.go):CalculateTotalTokenUsageFromBytes/ExtractAllModifiedFilesFromBytes- AddedextractAllSpawnedAgentIDsFromBytes()helper with same full-scan approachCalculateTotalTokenUsageFromTranscript/ExtractAllModifiedFilesFromTranscript- Re-parses full transcript file at line 0 for agent ID discoveryTesting
🤖 Generated with Claude Code
Co-Authored-By: Claude Opus 4.6 noreply@anthropic.com