[BUG] context_window metrics not updated after /compact until next API interaction
Preflight Checklist
- [x] I have searched existing issues and this hasn't been reported yet
- [x] This is a single bug report (please file separate reports for different bugs)
- [x] I am using the latest version of Claude Code
What's Wrong?
After running /compact, the context_window object in the status line JSON retains pre-compaction values until the next API interaction. This affects any status line configuration that displays context usage.
What Should Happen?
After /compact completes, the context_window metrics should immediately reflect the new (reduced) context state.
Steps to Reproduce
- Have a conversation with some context built up
- Run
/compact - Observe:
context_window.used_percentagestill shows pre-compaction value - Send any message
- Observe: value now reflects actual post-compaction state
Claude Model
Opus
Is this a regression?
I don't know
Claude Code Version
2.1.14 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
Entire context_window object is stale after /compact, not just used_percentage. Manual calculation from cache_read_input_tokens + input_tokens shows the same stale behavior—confirming the issue is that the context_window object isn't refreshed after compaction until the next API round-trip.
This issue has 11 comments on GitHub. Read the full discussion on GitHub ↗