Skip to content

fix: include nested Claude subagent usage - #180

Open
raphberube wants to merge 2 commits into
graykode:mainfrom
raphberube:fix/claude-nested-subagent-usage
Open

raphberube wants to merge 2 commits into
graykode:mainfrom
raphberube:fix/claude-nested-subagent-usage

Conversation

@raphberube

@raphberube raphberube commented Sep 30, 2026 •

Copy link
Copy Markdown

When Claude Code executes a Workflow, its subagent transcripts can be stored under subagents/workflows/<workflow-id>/. The collector previously scanned only the immediate subagents directory and required metadata files, so these nested workflow agents could be missing from abtop while actively working. Parent-session token totals also excluded subagent usage, leaving reported usage incomplete during workflow execution.

This change discovers those agents and includes their input, output, cache-read, and cache-write tokens in parent-session totals. Usage continues updating while subagents work, even when the parent transcript is unchanged.

Changes:

  • Recursively discover agent-*.jsonl transcripts, using the filename when metadata is unavailable.
  • Parse appended data incrementally and cache usage per transcript.
  • Handle partial lines, truncation, and file replacement; retain collected totals when completed-agent files disappear.
  • Skip symlinks and workflow journals, and sort agents by transcript path for stable display ordering.
  • Preserve the parent’s context percentage and turn count.

Regression coverage includes nested discovery, updates without parent activity, repeated polling without double-counting, delayed metadata, transcript lifecycle handling, stable ordering, and cache cleanup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant