[Bug] Incorrect Self Context Window Awareness Calculation

Resolved 💬 3 comments Opened Oct 3, 2025 by ariccio Closed Oct 7, 2025

Bug Description
Claude's excellent new self-context-window-awareness appears to be wrong, and off by a lot. Don't get me wrong, this is a very valuable feature that I, myself, desperately wanted.
However, I just noticed something is a bit off. Claude code very helpfully considered context exhaustion for me partway through a long task, but apparently the number that it understood for context usage is about 45% off. It reported 54% context usage, but /context reported 99% context usage.

The rapid pace of releases of claude code is great enough that it's faster than some of my longer running sessions, so I can't say if this has been fixed in v2.0.5 (or a newer one?). Either way, this feature does only work if Claude's understanding of context window usage is accurate.

Here's the interaction:

  This task will require processing ~2,000-2,700 annotations across the codebase. I'm at 54% context usage (108k/200k tokens). Let me continue with a few more high-priority files, then I'll need to create a continuation prompt to
  manage context efficiently.

  Given the massive scope, would you prefer I:
  1. Continue systematically - Process all files but expect to need continuation prompts
  2. Batch commit - Process 10-15 files, commit, then continue in new session
  3. Parallelize - Create multiple subagents to process different file groups simultaneously

  What's your preference?

> /context 
  ⎿  Context Usage 199k/200k tokens (100%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛝ ⛝ ⛝ 
     ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ 
     ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝ ⛝   ⛁ System prompt: 2.9k tokens (1.5%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ System tools: 11.8k tokens (5.9%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛝ Reserved: 45.0k tokens (22.5%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁     [autocompact + output tokens]
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ Memory files: 9.5k tokens (4.8%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁   ⛁ Messages: 129.9k tokens (65.0%)
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ 
     ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ ⛁ 

     Memory files · /memory
     └ User (/Users/alexanderriccio/.claude/CLAUDE.md): 702 tokens
     └ Project (/Users/alexanderriccio/Documents/GitHub/static-types-faster18 tokens
     builds/CLAUDE.md):
     └ Project (/Users/alexanderriccio/Documents/GitHub/static-types-faste8.8k 
     -builds/.github/copilot-instructions.md):                            tokens

     SlashCommand Tool · 0 commands
     └ Total: 962 tokens

Environment Info

  • Platform: darwin
  • Terminal: Apple_Terminal
  • Version: 2.0.2
  • Feedback ID: cba06eac-f9e3-4ea3-b749-c5464cce093e

Errors

[{"error":"Error: EISDIR: illegal operation on a directory, read\n    at Module.readFileSync (node:fs:449:20)\n    at Object.readFileSync (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:719:16525)\n    at Ma2 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3535:659)\n    at Object.call (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1829:952)\n    at call.next (<anonymous>)\n    at AO (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1834:3213)\n    at file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3378:1328\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-10-02T19:49:04.587Z"},{"error":"Error: EISDIR: illegal operation on a directory, read\n    at Module.readFileSync (node:fs:449:20)\n    at Object.readFileSync (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:719:16525)\n    at Ma2 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3535:659)\n    at Object.call (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1829:952)\n    at call.next (<anonymous>)\n    at AO (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1834:3213)\n    at file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3378:1328\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-10-02T19:50:20.943Z"},{"error":"Error: EISDIR: illegal operation on a directory, read\n    at Module.readFileSync (node:fs:449:20)\n    at Object.readFileSync (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:719:16525)\n    at Ma2 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3535:659)\n    at Object.call (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1829:952)\n    at call.next (<anonymous>)\n    at AO (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1834:3213)\n    at file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3378:1328\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-10-02T19:50:20.944Z"},{"error":"Error: Request was aborted.\n    at yP.makeRequest (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1025:3864)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)","timestamp":"2025-10-02T20:10:26.425Z"},{"error":"Error: 400 {\"type\":\"error\",\"error\":{\"type\":\"invalid_request_error\",\"message\":\"messages.9.content.0.type: Expected `thinking` or `redacted_thinking`, but found `text`. When `thinking` is enabled, a final `assistant` message must start with a thinking block (preceeding the lastmost set of `tool_use` and `tool_result` blocks). We recommend you include thinking blocks from previous turns. To avoid this requirement, disable `thinking`. Please consult our documentation at https://docs.claude.com/en/docs/build-with-claude/extended-thinking\"},\"request_id\":\"req_011CTiz9S1tzhx2fVRDmaxPi\"}\n    at p9.generate (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:895:20956)\n    at yP.makeStatusError (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1025:2131)\n    at yP.makeRequest (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1025:5344)\n    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)\n    at async OZ1 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:1036:4327)\n    at async kJ1 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3299:163)\n    at async sK5 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3299:2319)\n    at async Promise.all (index 6)\n    at async is2 (file:///Users/alexanderriccio/.nvm/versions/node/v20.19.4/lib/node_modules/@anthropic-ai/claude-code/cli.js:3299:2730)\n

Note: Error logs were truncated.

View original on GitHub ↗

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