Token counting ~2x inflated in 2.1.7 vs 2.1.2
Preflight Checklist
- [x] I have searched the existing issues to make sure this bug has not been reported yet
- [x] I am filing a single bug report (not multiple bugs in one issue)
- [x] I am using the latest version of Claude Code
What's Wrong?
Token context usage is approximately 2x inflated in version 2.1.7 compared to 2.1.2. Measuring from the raw API response (message.usage.cache_creation_input_tokens + message.usage.cache_read_input_tokens), a session reached ~160K tokens before hitting "Prompt is too long". After downgrading to 2.1.2 and resuming the same session, the API reported ~89K tokens for equivalent context.
This suggests 2.1.7 is sending significantly more tokens to the API per request, not just displaying incorrectly.
What Should Happen?
Token usage should be consistent between versions. The same session content should not result in ~2x more tokens being sent to the API in 2.1.7 vs 2.1.2.
Steps to Reproduce
- Use Claude Code 2.1.7 with auto-compact disabled
- Work through a session with moderate file reads/writes
- Observe token count (from
cache_creation_input_tokens + cache_read_input_tokensin JSONL transcript) climbing higher than expected - Session hits "Prompt is too long" error at ~160K tokens
- Switch to stable channel and run
claude updateto downgrade to 2.1.2 - Resume the same session
- Observe API-reported token count is roughly half (~89K)
Is this a regression?
Yes
Claude Code Version
- Bug present: 2.1.7
- Works correctly: 2.1.2
Platform
Anthropic API
Operating System
Other Linux
Terminal/Shell
Other (Kitty)
Claude Model
Opus
Error Messages/Logs
Prompt is too long
Additional Information
- Auto-compact disabled via
~/.claude.json - Token counts measured from JSONL transcript:
message.usage.cache_creation_input_tokens + message.usage.cache_read_input_tokens - Token count climbed steadily to ~160K before hard stop (counter then showed 0)
- Same session showed ~89K tokens after resuming on 2.1.2
_Content written by Claude Code as directed by cseickel_
This issue has 6 comments on GitHub. Read the full discussion on GitHub ↗