Three ways I miscounted my own AI agents, and what the transcripts actually say
说明与用途
用户在 Claude 的转录文件中错误地计数 AI 代理的输出和使用。roundtable 脚本正确处理子代理,去重行并准确计数钩子,显示子代理占 58.4% 的输出和 6,898 次钩子触发。
问题
Users miscount AI agent outputs and usage because of transcript file structure and duplicate lines, leading to inaccurate metrics.
结果
Accurate measurement of child agent output (58.4% of total tokens), correct token usage (deduplicated to 46.96M), and precise hook firing counts (6,898 firings). Identified 13 silent children that produced no output.
工作流
- 1. List all subagent JSONL files under ~/.claude/projects/*/*/subagents/*.jsonl and subagent workflow agent files.
- 2. Count lines per file and deduplicate by message.id to get true token usage.
- 3. Grep for "hookName" entries, sort, uniq, and count per hookName, then deduplicate by toolUseID to get true hook firings.
- 4. Run the provided script npx github:Kostakurta8/roundtable --stats to aggregate statistics across all sessions.
- 5. Review the output to understand child share, token usage, and hook activity.
- 6. Use the viewer component of the project to visualize agent timelines if needed.
证据
On my machine, across 51 runs that used subagents, the children wrote 58.4% of all output tokens.
Summed per line that is 90,955,151 output tokens. Deduplicated on message.id it is 46,959,967.
Deduplicate and my 8,831 records become 6,898 firings.
- 记录日期: 2026-09-21T18:45:23.513Z