Context display double-counts reserved buffer

Resolved 💬 5 comments Opened Sep 30, 2025 by SalesforceRocks Closed Oct 4, 2025

Bug Description

The /context command appears to double-count the reserved buffer (45k tokens) when calculating context usage and free space.

Current Behavior

Context Usage 95k/200k tokens (47%)
- System prompt: 3.0k tokens (1.5%)
- System tools: 13.0k tokens (6.5%)
- Reserved: 45.0k tokens (22.5%)
- MCP tools: 27.3k tokens (13.6%)
- Custom agents: 201 tokens (0.1%)
- Memory files: 6.0k tokens (3.0%)
- Messages: 8 tokens (0.0%)
- Free space: 60k (30.2%)

Problem

Adding up the actual context usage:

  • System prompt: 3.0k
  • System tools: 13.0k
  • MCP tools: 27.3k
  • Custom agents: 0.2k
  • Memory files: 6.0k
  • Messages: 0.008k
  • Total: ~49.5k tokens

The header shows "95k/200k (47%)" which only adds up if we include the 45k reserved buffer.

However, the free space shows 60k, which is calculated as:
200k - 95k - 45k = 60k

This means the 45k reserved buffer is being counted twice:

  1. Once in the "Context Usage" total (95k)
  2. Once again when calculating free space

Expected Behavior

Either:

  • Option A: "Context Usage" should show ~50k (excluding reserved), and free space should show ~105k
  • Option B: "Context Usage" should show ~95k (including reserved), and free space should show ~105k (not subtracting reserved again)

Impact

Users see misleading information about available context space. In this case, it appears there's only 60k free space when there's actually ~105k available for new content.

Environment

  • Claude Code CLI
  • Context budget: 200k tokens

View original on GitHub ↗

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