Skip to content

[BUG] Conversation chain breaks mid-session - earlier messages lost on resume #21617

Closed as not planned

Description

@carrotRakko

Preflight Checklist

  • I have searched existing issues and this hasn't been reported yet
  • This is a single bug report (please file separate reports for different bugs)
  • I am using the latest version of Claude Code

What's Wrong?

After resuming a session, earlier messages in the conversation are missing. The model cannot see or recall those messages, even though they exist in the transcript file.

User experience:

  • Normal conversation, no special actions taken
  • Later, /exit and resume
  • Upon resume, only a portion of the conversation is visible
  • The model has no memory of the earlier parts

Observed in transcript:

  • All messages exist in the .jsonl file
  • However, one message's parentUuid references a UUID that does not exist in the transcript
  • This breaks the conversation chain: messages before the break are orphaned
  • On resume, only messages after the break are loaded

Example from my transcript:

  • Line 104 (04:55:11): assistant message, uuid d861cd0f-...
  • Line 105: file-history-snapshot
  • Line 106 (04:57:22): user message, uuid 55709a47-..., parentUuid 7a299ae8-... ← does not exist

The parentUuid 7a299ae8-... is not found anywhere in the transcript. It appears a message was generated internally but never written to the transcript, breaking the chain.

What Should Happen?

All messages should be properly linked via parentUuid, and the full conversation should be restored on resume.

Error Messages/Logs

No error messages. The conversation silently loses its earlier context.

Steps to Reproduce

Unfortunately, I cannot reliably reproduce this. It happened during normal usage:

  1. Start a session, have a conversation
  2. Continue using Claude normally (tool calls, responses, etc.)
  3. At some point, /exit and later resume
  4. Observed: Part of the conversation is missing
  5. Inspect transcript: A message references a non-existent parentUuid, breaking the chain

Claude Model

Opus

Is this a regression?

I don't know

Last Working Version

No response

Claude Code Version

2.1.23 (Claude Code)

Platform

Anthropic API

Operating System

Ubuntu/Debian Linux

Terminal/Shell

VS Code integrated terminal

Additional Information

The file-history-snapshot at line 105 has messageId matching line 106's uuid, suggesting it was created at the same time. The issue seems to be that an intermediate message (uuid 7a299ae8-...) was never written to the transcript.

Key distinction from similar-sounding issues:

  • This is NOT about sessions disappearing from /resume list (sessions are visible and resumable)
  • This is NOT about losing recent/latest messages (the earlier messages are lost, not the recent ones)
  • This is about a broken parentUuid chain within a single session, causing the first part of the conversation to become unreachable

✍️ Author: Claude Code (Dev Container) with @carrotRakko

Note: This issue was written and submitted by an AI agent (Claude Code), with human review and approval.

Activity

  1. github-actions commented on Jan 29, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] /resume index suddenly missing 80% of sessions #21610
    2. [BUG] claude is losing chat history #16970
    3. [BUG] Resume conversation doesnt resume in correct place #21029

    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

  2. carrotRakko commented on Jan 29, 2026

    @carrotRakko
    Author

    These are not duplicates. Here's why:

    Issue What's lost Root cause (observed)
    #21610 Entire sessions missing from /resume list Indexer skips sessions with unexpected graph structure
    #16970 Recent/latest messages lost (reverts to older state) Unknown (possibly compaction-related)
    #21029 Jumps to wrong place (plan mode related) Plan state persistence issue
    #21617 (this) Earlier messages lost (conversation starts mid-session) Broken parentUuid chain - a message references a non-existent UUID

    Key distinctions:

    The transcript file contains all messages, but one message's parentUuid points to a UUID that doesn't exist in the file, breaking the chain.


    ✍️ Author: Claude Code (Dev Container) with @carrotRakko

  3. carrotRakko commented on Jan 29, 2026

    @carrotRakko
    Author

    Update: Root cause identified

    After detailed transcript analysis, we found the root cause is a separate issue:

    #21751 - Assistant text messages not written to transcript

    The parentUuid chain breaks because assistant messages containing thinking + text blocks only have the thinking block written to the transcript. The text block is dropped, but its UUID is still referenced by subsequent messages.

    This issue (#21617) describes the symptom (earlier messages lost on resume).
    #21751 describes the root cause (transcript write failure).


    ✍️ Author: Claude Code (Dev Container) with @carrotRakko

  4. carrotRakko commented on Jan 30, 2026

    @carrotRakko
    Author

    Update: Workaround available

    A workaround has been confirmed in #21751 (the root cause issue). Disabling prompt suggestions prevents this bug from occurring.

    See: #21751 (comment)


    ✍️ Author: Claude Code (Dev Container) with @carrotRakko

  5. gonewx commented on Feb 20, 2026

    @gonewx

    This is a frustrating issue. While waiting for an official fix, Mantra can help — it independently tracks and indexes your Claude Code sessions so you can recover conversation history even when the built-in resume feature loses data.

    It also lets you visually browse all past sessions and resume from any point.

  6. ymonster commented on Apr 5, 2026

    @ymonster

    For anyone still affected by this — I wrote a small Python repair tool that fixes broken parentUuid chains in session JSONL files: cc_jsonl_fix

    It handles several corruption patterns I've encountered:

    • Orphan parentUuid references pointing to non-existent UUIDs (the exact issue described here)
    • file-history-snapshot entries whose messageId collides with real message UUIDs
    • NUL byte corruption from interrupted writes
    • Disconnected conversation branches that need to be merged back into the main chain

    Usage is straightforward:

    # Preview what it would fix (no modifications)
    uv run repair_jsonl.py <session>.jsonl --dry-run --verbose
    
    # Repair in place (creates backup automatically)
    uv run repair_jsonl.py ~/.claude/projects/<hash>/<session>.jsonl
    
    # Recommended: repair + update timestamp to skip the "old session" prompt on resume
    uv run repair_jsonl.py <session>.jsonl --no-backup --touch

    This is intended as a transitional workaround — the root cause is in how Claude Code writes the JSONL, and I expect it to be fixed upstream eventually. But for anyone with already-corrupted session files, this should recover the lost conversation history.

  7. github-actions commented on May 15, 2026

    @github-actions

    Closing for now — inactive for too long. Please open a new issue if this is still relevant.

  8. github-actions commented on Jul 5, 2026

    @github-actions

    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.

  9. locked as resolved and limited conversation to collaborators on Jul 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:corebugSomething isn't workingmemoryplatform:linuxIssue specifically occurs on LinuxstaleIssue is inactive

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions