[BUG] Conversations compacting prematurely at ~65% token capacity instead of near limit
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?
Preflight Checklist
- I am using the latest version of Claude Code
- I have searched existing issues to ensure this hasn't been reported
- I can reproduce this issue consistently
- I have run /clear to start fresh and the issue persists
What's Wrong?
Bug Description:
Claude Code is compacting conversations prematurely, well before reaching the 200,000 token limit. Compacting occurs at approximately 65-75% token capacity (~130k-150k tokens) instead of near the actual limit.
Steps to Reproduce:
- Run /clear to start a fresh conversation
- Engage in a conversation that uses approximately 130k-150k tokens
- Observe conversation being compacted despite having 50k+ tokens remaining
Expected Behavior:
Conversations should only be compacted when approaching the 200,000 token limit (e.g., at 90-95% capacity or higher), not when significant token budget remains available.
Actual Behavior:
- Conversations are compacted at approximately 64.9% capacity (129,795/200,000 tokens in current session)
- Compacting occurs even after using /clear to start fresh
- 50k+ tokens of available budget are unused when compacting triggers
Environment:
- Claude Code CLI
- Model: Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)
- Platform: macOS (Darwin 25.1.0)
Impact:
This premature compacting reduces the effective context window by 30-35%, limiting the ability to work on complex tasks that require maintaining extensive conversation context.
What Should Happen?
Preflight Checklist
- I am using the latest version of Claude Code
- I have searched existing issues to ensure this hasn't been reported
- I can reproduce this issue consistently
- I have run /clear to start fresh and the issue persists
What's Wrong?
Bug Description:
Claude Code is compacting conversations prematurely, well before reaching the 200,000 token limit. Compacting occurs at approximately 65-75% token capacity (~130k-150k tokens) instead of near the actual limit.
Steps to Reproduce:
- Run /clear to start a fresh conversation
- Engage in a conversation that uses approximately 130k-150k tokens
- Observe conversation being compacted despite having 50k+ tokens remaining
Expected Behavior:
Conversations should only be compacted when approaching the 200,000 token limit (e.g., at 90-95% capacity or higher), not when significant token budget remains available.
Actual Behavior:
- Conversations are compacted at approximately 64.9% capacity (129,795/200,000 tokens in current session)
- Compacting occurs even after using /clear to start fresh
- 50k+ tokens of available budget are unused when compacting triggers
Environment:
- Claude Code CLI
- Model: Claude Sonnet 4.5 (claude-sonnet-4-5-20250929)
- Platform: macOS (Darwin 25.1.0)
Impact:
This premature compacting reduces the effective context window by 30-35%, limiting the ability to work on complex tasks that require maintaining extensive conversation context.
Error Messages/Logs
Steps to Reproduce
- Start Claude Code session
- Run /clear to begin new conversation
- Activate a Serena project (note: this may be relevant)
- Continue normal conversation
- Observe compacting occurs at ~129,795 tokens (64.9% of 200k budget)
Expected Behavior
Conversations should only compact when approaching the 200k token limit (e.g., at 180k-190k tokens), leaving minimal buffer for continuation.
Actual Behavior
Compacting occurs at approximately 129,795/200,000 tokens (64.9% capacity), with 70,205 tokens (35%+ of budget) still remaining. User receives "This session is being continued from a previous conversation that ran out of context" message despite substantial remaining capacity.
Environment
- Platform: macOS (Darwin 25.1.0)
- Claude Code Version: Latest (as of 2025-12-25)
- Model: claude-sonnet-4-5-20250929
- Token Budget: 200,000
Additional Context
The premature compacting appears to correlate with Serena project activation, though the root cause is likely in Claude Code's conversation management. There may be an interaction between project activation and conversation state that triggers early compacting. Worth investigating whether Serena integration affects conversation lifecycle decisions.
Impact
This significantly reduces effective conversation length and forces unnecessary context loss, degrading the development experience when working on complex tasks that require extended context.
Claude Model
Sonnet (default)
Is this a regression?
Yes, this worked in a previous version
Last Working Version
_No response_
Claude Code Version
2.0.76 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
_No response_
This issue has 7 comments on GitHub. Read the full discussion on GitHub ↗