claude-code - 💡(How to fix) Fix --continue loads oldest messages instead of most recent in large sessions [2 comments, 3 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#49217Fetched 2026-04-17 08:47:33
View on GitHub
Comments
2
Participants
3
Timeline
6
Reactions
0
Timeline (top)
labeled ×4commented ×2

Fix Action

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.

RAW_BUFFERClick to expand / collapse

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

  1. Have a long-running session with many messages (~1,000+ user messages, ~1,350+ assistant messages)
  2. The session file has no compaction/summary entries ("type":"summary" count = 0)
  3. Run claude --continue from the project directory
  4. 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:

  1. Prioritize recent messages over old ones
  2. Or auto-compact the session on resume, summarizing old messages and keeping recent ones intact

extent analysis

TL;DR

The issue can be mitigated by modifying the session loading logic to prioritize recent messages over old ones when the session exceeds the context window.

Guidance

  • Review the session loading logic in the claude --continue command to understand how it handles large sessions with no compaction summaries.
  • Consider implementing a mechanism to truncate the session from the beginning (oldest messages) instead of the end (newest messages) when the session is too large to fit entirely in the context window.
  • Investigate the possibility of auto-compacting the session on resume, summarizing old messages and keeping recent ones intact, as suggested in the issue.
  • Verify that the modified logic correctly loads the most recent messages into the context window for large sessions.

Example

No code snippet is provided as the issue does not contain sufficient technical details to create a concrete example.

Notes

The issue lacks information about the internal implementation of the claude --continue command and the session loading logic, making it difficult to provide a more detailed solution.

Recommendation

Apply a workaround by modifying the session loading logic to prioritize recent messages, as this is the most direct approach to addressing the issue. This will allow users to resume large sessions with the most recent context, rather than having to start a new session.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING

claude-code - 💡(How to fix) Fix --continue loads oldest messages instead of most recent in large sessions [2 comments, 3 participants]