Unnecessary session compaction on exit wastes tokens and breaks resume expectations
Resolved 💬 3 comments Opened Jan 31, 2026 by Steve-Klingele Closed Feb 4, 2026
Summary
Claude Code appears to auto-compact sessions on exit, which:
- Wastes tokens/time compacting a session that's ending anyway
- Causes resumed sessions (
-rflag) to have incomplete history with no indication this occurred
Steps to Reproduce
- Have a long session (not hitting 95% context limit during use)
- Exit the session normally
- Resume with
claude -r - Notice the conversation history is truncated/summarized
Investigation
Examined the session file and found:
- 101 lines total in the JSONL session file
- Line 101 (the last line) is
{"type":"summary","summary":"...","leafUuid":"..."} - The summary was added at session end, not during active use
- User never saw compaction happen during the session
Evidence from session file analysis
# Summary is on the very last line
$ grep -n '"type":"summary"' session.jsonl
101:{"type":"summary","summary":"Task Scheduling Strategy...","leafUuid":"..."}
# File has exactly 101 lines
$ wc -l session.jsonl
101 session.jsonl
Expected Behavior
- Sessions should NOT be compacted on exit
- If a session was compacted during use (hitting 95% limit), resuming should indicate this
- The
-rflag should restore the session as it was when the user left it
Current Behavior
- Sessions are silently compacted on exit
- Resumed sessions appear truncated with no explanation
- Users expect full history but get summarized version
Suggested Fix
- Remove exit-time compaction - there's no benefit to compacting a session that's ending
- Or make it opt-in via a setting
- At minimum - show a warning when resuming a compacted session: "This session was compacted. Some early conversation details may be summarized."
Environment
- Claude Code version: 2.1.27
- OS: Linux (WSL2)
This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗