[Bug] Inconsistent context usage calculation between /context header and breakdown

Resolved 💬 3 comments Opened Mar 25, 2026 by stevexusc Closed Mar 29, 2026

Bug Description
❯ why there inconsitensy context usage in /context and statusline
⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛀ claude-opus-4-6 · 101k/200k tokens (50%)
⛁ ⛀ ⛁ ⛁ ⛁ ⛁ ⛀ ⛶ ⛶ ⛶
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ Estimated usage by category
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System prompt: 6.4k tokens (3.2%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ System tools: 8.2k tokens (4.1%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Custom agents: 1.7k tokens (0.8%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Memory files: 3.1k tokens (1.6%)
⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛶ ⛁ Skills: 3.3k tokens (1.6%)
⛶ ⛶ ⛶ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛁ Messages: 9.1k tokens (4.5%)
⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛶ Free space: 135k (67.6%)
⛝ Autocompact buffer: 33k tokens (16.5%)

Opus 4.6 │ my project ██████░░░░ 60%
⏵⏵ bypass permissions on (shift+tab to cycle) · PR #16115

⏺ The /context display and the status line measure different things:

  • /context shows estimated token counts — it breaks down system prompt, tools, agents, memory, skills, and messages into categories

with token estimates. It reported ~101k/200k (50%).

  • The status line shows actual API usage — it reflects the real token count from the most recent API call, which was 60%.

The gap (50% vs 60%) is because /context is a point-in-time estimate that doesn't account for everything sent in the actual API
request (e.g., deferred tool schemas, system reminders injected per-turn, the /context command output itself). The status line
updates after each API round-trip with the real count from the server.

In short: /context is an approximation; the status line is the ground truth.

❯ even in /context why ⛶ Free space: 135k (67.6%) vs claude-opus-4-6 · 101k/200k tokens (50%)

⏺ Good catch. The math doesn't add up within /context itself:

  • Header: 101k/200k (50%) — meaning ~101k used, ~99k free
  • Body: Free space 135k (67.6%) — meaning only ~65k used

The categories listed sum to roughly ~33k (6.4 + 8.2 + 1.7 + 3.1 + 3.3 + 9.1 = ~32.8k). Add the 33k autocompact buffer and you get
~65k, which matches the 135k free figure.

So the header (101k/200k) likely comes from the actual API response (real usage), while the body breakdown is an independent
estimate based on summing known categories — and it underestimates because it misses some overhead (deferred tool definitions,
system reminders, internal framing tokens, etc.).

It's a bug/inconsistency in the /context display — the header and the body are using different accounting methods.

Environment Info

  • Platform: darwin
  • Terminal: tmux
  • Version: 2.1.83
  • Feedback ID: 35d15ac1-d4d0-4625-a80e-9918beb3e1ab

Errors

[{"error":"Error: Plugin has an invalid manifest file at /Users/myname/.claude/plugins/cache/temp_github_1774479909784_jw4c26/.claude-plugin/plugin.json. Validation errors: hooks: Invalid input\n    at js_ (/$bunfs/root/src/entrypoints/cli.js:4160:18429)\n    at async iu$ (/$bunfs/root/src/entrypoints/cli.js:4164:11216)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-03-25T23:05:14.222Z"},{"error":"Error: Plugin has an invalid manifest file at /Users/myname/.claude/plugins/cache/temp_github_1774479909613_at9l5e/.claude-plugin/plugin.json. Validation errors: hooks: Invalid input\n    at js_ (/$bunfs/root/src/entrypoints/cli.js:4160:18429)\n    at async iu$ (/$bunfs/root/src/entrypoints/cli.js:4164:11216)\n    at processTicksAndRejections (native:7:39)","timestamp":"2026-03-25T23:05:14.223Z"}]

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗