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:

  1. Wastes tokens/time compacting a session that's ending anyway
  2. Causes resumed sessions (-r flag) to have incomplete history with no indication this occurred

Steps to Reproduce

  1. Have a long session (not hitting 95% context limit during use)
  2. Exit the session normally
  3. Resume with claude -r
  4. 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 -r flag 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

  1. Remove exit-time compaction - there's no benefit to compacting a session that's ending
  2. Or make it opt-in via a setting
  3. 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)

View original on GitHub ↗

This issue has 3 comments on GitHub. Read the full discussion on GitHub ↗