[BUG] Subagent transcripts missing final assistant entry (stop_reason / final usage) since 2.1.280, undercounting output tokens

Status Open
Reported on v2.1.280
Maintainer reply None cached
Activity 1 comment · opened Oct 9, 2026

Summary

Since Claude Code 2.1.280, subagent transcripts (~/.claude/projects/<project>/<session>/subagents/*.jsonl) usually lack the final assistant entry for each API message — the one carrying message.stop_reason and the final message.usage.output_tokens. Only the streaming-start entry (input-side usage, output_tokens of a few tokens, stop_reason: null) is written. Main-session transcripts are not affected.

As a result, any tool that reads these logs (our own usage script, and presumably ccusage) undercounts subagent output tokens and cost from 2.1.280 onward.

Evidence

Extracted only version, message.id, message.model, message.usage.*, message.stop_reason from ~102K assistant entries (logs from 2026-09-15 to 2026-10-09, WSL2 / Linux). Per message.id, the entry with the max output_tokens was kept.

| kind | version | message ids | ids whose entries all have stop_reason: null | median output_tokens |
|---|---|---|---|---|
| subagent | 2.1.270 | 4,750 | 27 (0.6%) | 270 |
| subagent | 2.1.278 | 4,556 | 42 (0.9%) | 265 |
| subagent | 2.1.280 | 3,756 | 2,842 (76%) | 8 |
| subagent | 2.1.281 | 13,832 | 9,835 (71%) | 16 |
| subagent | 2.1.285 | 7,029 | 6,490 (92%) | 8 |
| subagent | 2.1.292 | 825 | 779 (94%) | 10 |
| main | 2.1.278 | 892 | 0 | 444 |
| main | 2.1.285 | 3,410 | 1 | 420 |
| main | 2.1.292 | 449 | 0 | 466 |

Input-side usage is unchanged, only output is missing. Same model (Sonnet 5) before/after the version boundary, mean per message id:

| version | cache_read_input_tokens | cache_creation_input_tokens | output_tokens |
|---|---|---|---|
| ≤ 2.1.278 | 147,062 | 3,713 | 644 |
| ≥ 2.1.280 | 152,468 | 4,071 | 202 |

The change lines up exactly with the 2.1.278 → 2.1.280 upgrade, reproduces with the same model on both sides, and does not occur in main-session transcripts, so it does not look like a model change or abnormal termination.

Expected

Subagent transcripts record the final assistant entry (with stop_reason and final usage) as they did in ≤ 2.1.278 and as main-session transcripts still do.

Impact

Subagent output tokens are undercounted roughly 3× (Sonnet) to ~20× (Opus) in log-based usage reports; estimated subagent cost undercount is ~10% (Sonnet) to ~30% (Opus) at standard price ratios.

Environment

  • Claude Code 2.1.280 – 2.1.292 (CLI), Linux (WSL2)
  • Subagents launched via the Agent tool (not broken down by foreground / background or worktree isolation)

View original on GitHub ↗

This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗