[BUG] /context over-counts memory files and custom agents in 2.1.191; 2.1.179 reports sane estimates

Open 💬 1 comment Opened Jun 25, 2026 by alygg77

Summary

Claude Code 2.1.191 appears to regress /context accounting for memory files, custom agents, and the system prompt. Tiny memory files and custom-agent metadata are reported as ~2k tokens each, and total startup context is shown as ~83k. After switching to stable 2.1.179, the same setup reports sane token estimates and ~39.7k total.

This looks like a /context accounting/display regression in 2.1.191, not actual prompt content growth.

Environment

  • macOS
  • Claude Code affected version: 2.1.191
  • Claude Code comparison version: 2.1.179
  • Model shown by /context: claude-opus-4-8[1m]
  • Tool search enabled: MCP tools shown as loaded on-demand
  • Session has user custom agents and normal CLAUDE.md / auto-memory files

Observed in 2.1.191

Fresh session /context reported:

83.2k / 1m tokens (8%)

System prompt: 22.1k tokens
Custom agents: 18.6k tokens
Memory files: 7.2k tokens
Skills: 24.5k tokens
Messages: 10.8k tokens

Custom agents were each shown at roughly a 2k token floor:

ship-verdict-auditor: 2.1k tokens
posting-reconciler: 2.1k tokens
fleet-sweep: 2.1k tokens
recreate-pipeline: 2.1k tokens
render-batch-runner: 2.1k tokens
notion-tasks: 2k tokens
navigator: 2k tokens
skill-auditor: 2k tokens
supabase-db: 2k tokens

Memory files were similarly over-reported:

.claude/CLAUDE.md: 2.8k tokens
CLAUDE.md: 2.1k tokens
.claude/projects/.../memory/MEMORY.md: 2.3k tokens

The actual files were much smaller. Example measured sizes:

~/.claude/CLAUDE.md                    29 lines, 306 words, 2225 bytes
./CLAUDE.md                             6 lines,  44 words,  346 bytes
auto-memory MEMORY.md                  10 lines,  80 words,  691 bytes

A one-line temporary CLAUDE.local.md with only 35 bytes also appeared as 2k tokens in 2.1.191.

A tiny custom agent file, 176 bytes / 24 words, also appeared as 2k tokens in 2.1.191.

Observed after switching to 2.1.179

After switching to stable 2.1.179, the same style of session reported:

39.7k / 1m tokens (4%)

System prompt: 4.5k tokens
Custom agents: 1.1k tokens
Memory files: 1.5k tokens
Skills: 24.8k tokens
Messages: 7.8k tokens

The same custom agents were then counted as realistic metadata sizes:

ship-verdict-auditor: 174 tokens
posting-reconciler: 154 tokens
fleet-sweep: 149 tokens
recreate-pipeline: 148 tokens
render-batch-runner: 147 tokens
notion-tasks: 99 tokens
navigator: 77 tokens
skill-auditor: 75 tokens
supabase-db: 59 tokens

Memory files also became realistic:

.claude/CLAUDE.md: 884 tokens
CLAUDE.md: 142 tokens
.claude/projects/.../memory/MEMORY.md: 440 tokens

Raw API body check

Using the supported raw API body logging:

OTEL_LOG_RAW_API_BODIES=file:/tmp/claude-otel-bodies \
OTEL_LOGS_EXPORTER=console \
claude -p 'Return exactly otel-body-ok'

In the affected setup where /context showed ~83k, the actual Messages API usage was about:

{
  "input_tokens": 24031,
  "cache_creation_input_tokens": 1709,
  "cache_read_input_tokens": 16502,
  "output_tokens": 9
}

The raw request body showed:

  • CLAUDE.md / auto-memory content is injected.
  • Custom agent names, descriptions, and tool lists are injected in an Available agent types for the Agent tool section.
  • Custom agent markdown bodies / system prompts were not present in the main request body.

So the actual behavior looks correct, but 2.1.191 /context made it look like every custom agent and memory file had a ~2k token cost.

Expected behavior

/context should report realistic estimated token usage for:

  • each memory file
  • each custom agent's routing metadata
  • system prompt / startup overhead

At minimum, if a reserved-budget/floor estimate is intentionally used, the UI should label it as such instead of presenting it as file/agent token usage.

Why this matters

This regression makes users think:

  1. tiny memory files are thousands of tokens each;
  2. custom subagent system prompts are loaded into the main context;
  3. startup context roughly doubled, even when the raw request body and stable version do not support that.

It also sends users down the wrong debugging path: trimming already-small files or removing useful subagents instead of looking at real startup payload and hooks.

Related but not exact duplicates

  • #66261: /context indicator/breakdown mismatch
  • #63630: wrong denominator / >100% context display
  • #42309: deferred tools / custom agents / prompt cache docs

View original on GitHub ↗

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