Auto-compaction can leave zero usable context in long sessions

Resolved 💬 3 comments Opened Mar 29, 2026 by elgabrielc Closed May 3, 2026

Description

After a long, image-heavy session (~20 hours elapsed, ~30+ user messages with multiple screenshot pastes and large CSS diffs), auto-compaction fired and left the assistant with zero prior context. The assistant had no knowledge of what was being worked on and hallucinated an unrelated response.

Steps to reproduce

  1. Run a long session with many image pastes (screenshots of a desktop app) and large file diffs
  2. Session ID: bc9de747-22e8-4301-83e6-6e7af81bd0f6 (project: dicom-viewer)
  3. Session ran from 2026-03-28 21:05 UTC to 2026-03-29 17:54 UTC
  4. After the last user message at ~17:54, the next assistant response had no context from the session at all

What happened

  • The JSONL session file has all 537 messages intact on disk
  • But the active context window was completely empty after compaction
  • The assistant responded with fabricated content unrelated to the session
  • /resume output "Resume cancelled" -- it's designed for switching sessions, not recovering from bad compaction
  • Manually reading the JSONL file and extracting user messages was the only way to reconstruct what was happening

Expected behavior

Auto-compaction should preserve enough context for the assistant to continue the current task. At minimum:

  • What the user is working on
  • The most recent instructions
  • Key decisions made in the session

If compaction fails to preserve meaningful context, there should be a recovery mechanism (e.g., /resume re-reading the JSONL transcript, or a /restore command).

Environment

  • Model: claude-opus-4-6 (1M context)
  • Platform: macOS (Darwin 25.3.0)
  • Session type: image-heavy design iteration (multiple screenshot pastes, large CSS diffs)

View original on GitHub ↗

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