Context compaction drops recent messages, keeps old ones

Resolved 💬 2 comments Opened Apr 10, 2026 by NickPitas Closed Apr 11, 2026

Bug Description

Context compaction is behaving backwards: it keeps the oldest summary/messages and drops the most recent work. This causes loss of significant context mid-session.

Expected Behavior

Compaction should compress older messages and preserve recent ones, so the model retains awareness of the latest work and decisions.

Actual Behavior

Compaction preserves the initial summary (from session start / prior compaction) and wipes out all intermediate and recent work, leaving the model with stale context and no knowledge of what was just done.

Reproduction

  • Long-running session: 37MB transcript, 10,946 lines (JSONL)
  • Session spanned ~3 days of iterative development (April 8–11, 2026)
  • After compaction triggered:
  • Kept: Initial compaction summary from April 8 (dataset build, early monitoring setup)
  • Lost: All work from April 9–11 — OpenVINO model export & integration, voice server expansion (836 → 1253 lines), XPU debugging, OOM root-cause analysis, multiple code iterations
  • Result: Model reverted to stale context, re-suggested already-completed work, lost awareness of architectural decisions and root-cause findings

Impact

  • ~3 days of iterative context wiped
  • Model lost awareness of 400+ lines of code it had written
  • Model lost debugging findings (XPU failure root cause, OOM root cause)
  • User had to manually re-explain what was already done
  • Memory files (.claude/memory/) partially mitigated the loss, but conversational context (why decisions were made, what was tried and failed) was gone

Environment

  • Claude Code CLI (desktop app on Ubuntu 24.04)
  • Model: Claude Opus 4.6 (1M context)
  • Session ID: 16bf4830-c72a-4f7a-b2b5-13aba43044d4
  • Transcript: 37MB, 10,946 lines JSONL

Suggestion

Compaction should use a recency-biased strategy: always keep the N most recent turns verbatim, compress middle history, and keep (or refresh) the initial summary. The current behavior appears to keep the head and drop the tail, which is the worst possible outcome for an interactive development session.

View original on GitHub ↗

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