Expose token usage to the model within sessions
Problem
Claude Code has no visibility into its own token consumption during a session. The model cannot see how many tokens have been used or how many remain. This leads to:
- Silent degradation — the model starts producing lower-quality outputs (speculative fixes, shallow reasoning) as context fills up, without being able to flag this to the user
- Wasted budget on low-value operations — expensive research agents get spawned late in sessions when the budget would be better spent on clean commits
- No pacing — the model can't decide "I have 20% left, let me prioritise finishing clean over starting new work"
- User surprise — sessions end abruptly or quality drops without warning
Proposed solution
Expose token usage metadata within the conversation context. Something like:
session_tokens_used: 450000
session_tokens_limit: 1000000
This could be:
- A field in tool call results
- A periodic system reminder (every 100k tokens)
- Available via a dedicated tool (like
budget.spent()in workflows)
What this would enable
- Model can pace expensive operations (agent spawns, large file reads)
- Model can warn the user: "We've used ~80% of this session's budget, should I prioritise X or Y?"
- Model can avoid starting multi-step tasks it can't finish
- Model can explain quality tradeoffs honestly instead of degrading silently
Context
This came up during a long coding session where the model made 3 consecutive failed attempts at a CSS fix (each commit making things worse), likely because reasoning quality was degrading without any internal signal to stop and document rather than keep trying. The user had to observe the pattern externally and ask the model to stop.
The information exists at the infrastructure level — it's just not shared with the model.
This issue has 5 comments on GitHub. Read the full discussion on GitHub ↗