Resume after compaction loses conversation content — exports truncated

Status Fixed / completed
Maintainer reply None cached
Activity 4 comments · opened Apr 3, 2026 · closed Apr 3, 2026

Description

When a long session is compacted (via /compact) and then resumed later (via --resume or /resume picker), the resumed session loads from a late checkpoint instead of the compaction point. This causes:

  1. Truncated exports — /export from the resumed session produces a fraction of the content vs /export from the original running session (527 lines vs 8,902 lines for the same session)
  2. Lost context for Claude — Claude operates with partial conversation history after resume, degrading response quality
  3. Non-deterministic checkpoint selection — the same session ID resumes from different points depending on when you resume

Reproduction

  1. Start a session, work for several hours (4,000+ messages)
  2. /compact mid-session
  3. Continue working (adds ~2,000 more messages)
  4. /export from the running session → complete export (8,902 lines)
  5. Exit
  6. claude --resume <session-id>
  7. /export from resumed session → truncated export (527 lines, starts from a random late point)

Expected

Resume should load from the compaction point (or the full session), and exports should be identical regardless of whether exported from the original or resumed session.

Environment

  • Claude Code v2.1.91
  • Opus 4.6 (1M context)
  • Windows 11 / MSYS2/Git Bash
  • Session JSONL: 41MB, 6,149 lines, 4,451 messages
  • Multiple compactions in the same session

View original on GitHub ↗

4 Comments

belumume · 6 months ago

Closing — filed prematurely without proper diagnosis. The resume issue appears to be related to /desktop session transfer, not a general compaction bug. Will refile with accurate root cause if confirmed.

github-actions[bot] · 6 months ago

Found 3 possible duplicate issues:

  1. https://github.com/anthropics/claude-code/issues/42376
  2. https://github.com/anthropics/claude-code/issues/22107
  3. https://github.com/anthropics/claude-code/issues/40027

This issue will be automatically closed as a duplicate in 3 days.

  • If your issue is a duplicate, please close it and 👍 the existing issue instead
  • To prevent auto-closure, add a comment or 👎 this comment

🤖 Generated with Claude Code

kolkov · 6 months ago

@belumume Don't refile — the root cause is already identified and documented.

Your symptoms (41MB JSONL, truncated resume, 527 vs 8,902 lines) match exactly what we found through source code analysis. It's NOT specific to /desktop session transfer — it's a general v2.1.91 regression in the session loading pipeline.

Three specific code changes cause this:

  1. walkChainBeforeParse removed in v2.1.91 — fork pruning for >5 MB files no longer happens
  2. New ExY timestamp fallback bridges across unrelated fork branches
  3. Missing leafUuids check in getLastSessionLog (line 3900)

Full analysis with exact file:line references from v2.1.88 TypeScript source: #43044

If you need to recover the lost session content now, you can use our Go tool that reads JSONL directly (bypassing the broken resume):

go install github.com/kolkov/ccdiag@latest
ccdiag recover --output full -o recovery.md <your-session.jsonl>

https://github.com/kolkov/ccdiag

github-actions[bot] · 6 months ago

This issue has been automatically locked since it was closed and has not had any activity for 7 days. If you're experiencing a similar issue, please file a new issue and reference this one if it's relevant.