/context 'Messages' token bucket includes ~8.8k tokens with no corresponding text in context or transcript

Status Open
Reported on v2.1.220
Maintainer reply None cached
Activity 0 comments · opened Jul 29, 2026

Bug description

/context reports token usage under a "Messages" category that is significantly larger than the sum of all literal text content that is either (a) visible in the model's own conversation context, or (b) persisted in the local session transcript (~/.claude/projects/<project>/<session>.jsonl).

Evidence

Session transcript usage field (Anthropic API usage object, exact figures, not estimated) for the first turn of a fresh session that invoked a single slash-command-backed skill (SKILL.md body ~4.4KB) and nothing else:

"usage": {
  "input_tokens": 2,
  "cache_creation_input_tokens": 23513,
  "cache_read_input_tokens": 21192,
  ...
}
  • cache_read_input_tokens (21192) matches the session's pre-existing baseline (system prompt + system tool schemas), consistent with /context's own breakdown ("System prompt" + "System tools" ≈ 21.1k).
  • cache_creation_input_tokens (23513) is the new content added by turn 1. /context, run moments later, broke the running total (44.7k ≈ 21192+23513) into: System prompt 10.3k, System tools 10.8k, Memory files 5.6k, Skills 7.1k, Messages 11k.
  • The turn-1 user entry actually persisted in the .jsonl transcript is 211 characters (~53 tokens) — just the literal slash-command argument text.
  • Reconstructing every other piece of text that was visible in-context for that turn (the invoked SKILL.md body, a deferred-tools name list, an agent-types list, a hook-success reminder line, the command-name/args wrapper) totals ≈2.2k tokens (measured via wc -c on each block, /4).
  • grep -c 'system-reminder\|claudeMd' over the entire session .jsonl shows these blocks are never written to the transcript file as text — they exist only in the API request, not on disk.

Result: ~8.8k tokens of the "Messages" category (11k total, all logged in the billed usage.cache_creation_input_tokens) have no corresponding text anywhere — not in the model's visible context, not in the persisted transcript.

Why this matters

  • /context's "Messages" figure can't be audited or reconciled against anything a user (or the model itself, when asked to introspect) can inspect.
  • It make it impossible to verify what is contributing to a session's token budget beyond the categories /context already breaks out (System prompt, System tools, Memory files, Skills).

Environment

  • Claude Code version: 2.1.220 (native install, latest channel)
  • OS: macOS (Darwin 25.5.0)
  • Reproduced in a real project session; happy to share the anonymized transcript line-count/usage figures above, not the full transcript (contains project-specific content).

Request

Either have /context's "Messages" bucket reconcile fully against loggable/inspectable content, or document what non-text overhead (message formatting, role/delimiter tokens, etc.) accounts for the gap so it's not opaque.

View original on GitHub ↗