--continue loads oldest messages instead of most recent in large sessions
Bug Description
When using claude --continue on a large session (8.6 MB, ~2,377 messages, 0 compaction summaries), the resumed conversation context shows messages from weeks ago (the beginning of the session) instead of the most recent messages.
Steps to Reproduce
- Have a long-running session with many messages (~1,000+ user messages, ~1,350+ assistant messages)
- The session file has no compaction/summary entries (
"type":"summary"count = 0) - Run
claude --continuefrom the project directory - The conversation context shown is from the earliest messages in the session, not the most recent ones
Expected Behavior
--continue should prioritize loading the most recent messages into the context window. When a session is too large to fit entirely, it should truncate from the beginning (oldest messages), not from the end (newest messages).
Actual Behavior
The context window is filled with the oldest messages from the session file. Recent work (in this case, API key creation and testing done the same day) is completely absent from the resumed context. The model responds based on topics from weeks ago.
Session Details
- Session file size: 8.6 MB
- Entry counts:
assistant: 1351, user: 1026, system: 395, progress: 364, file-history-snapshot: 302, queue-operation: 244, attachment: 210, last-prompt: 32, permission-mode: 27 - Compaction/summary entries: 0
--resume <session-id>exhibits the same behavior
Environment
- Claude Code CLI (latest)
- Linux (Ubuntu)
Workaround
None for the affected session. Starting a new session is the only option. Extracting conversation content directly from the .jsonl file can recover the lost context.
Suggestion
When loading a session that exceeds the context window:
- Prioritize recent messages over old ones
- Or auto-compact the session on resume, summarizing old messages and keeping recent ones intact
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗