Skip to content

Chat history loss after PC restart, /resume recovers only 20-40% of context #23800

Closed as not planned

Description

@Darkwing4

Description

Chat history is being lost after PC/session restart. The /resume command fails to fully restore conversation context, recovering only approximately 20-40% of the original chat history. The agent loses all memory of previous conversations.

Timeline

  • First observed: ~2 weeks ago when latest channel reached version 2.1.29
  • Persisted through: latest versions 2.1.29 → 2.1.35
  • Now affects stable: Issue appeared on stable channel starting with version 2.1.25

Steps to Reproduce

  1. Have an active conversation with significant context
  2. Restart PC or terminal session
  3. Use /resume to restore the previous conversation
  4. Observe that 60-80% of the conversation context is missing

Expected Behavior

/resume should fully restore the conversation history and context.

Actual Behavior

  • Chat history is lost after restart
  • /resume only recovers 20-40% of the conversation
  • Agent has no memory of previous discussion topics

Environment

  • Claude Code version: 2.1.25 (stable)
  • OS: Ubuntu 25.10
  • Kernel: Linux 6.17.0-12-generic x86_64
  • Desktop: GNOME Shell 49.0 (Wayland)

Activity

  1. Darkwing4 commented on Feb 6, 2026

    @Darkwing4
    Author

    My colleague is experiencing the same issue on Windows with version 2.1.34

  2. github-actions commented on Feb 6, 2026

    @github-actions

    Found 3 possible duplicate issues:

    1. [BUG] 2.1.27 session resume logic is loosing context #22107
    2. [Bug] /resume loads incomplete session context despite full file on disk #22614
    3. [Bug] Resume function returns incomplete history with incorrect timestamps #22942

    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

  3. Darkwing4 commented on Feb 6, 2026

    @Darkwing4
    Author

    Same issue as #22107

    This bug is making Claude Code practically unusable for me. I can't take advantage of the new Claude Opus 4.5 model properly because every session restart loses most of the conversation context.

    As a result, I'm forced to use Cursor Agent instead for any serious work that requires maintaining context across sessions.

  4. 2jfs904judsw20600jikn613d0dookl23jsig commented on Feb 7, 2026

    @2jfs904judsw20600jikn613d0dookl23jsig

    +1 same exact issue. Cursor crashing (I use it only as IDE and have my CC sessions inside its integrated powershell) leaves me unable to resume conversations. I see the screen (tui) flash briefly with my conversation history but then goes back to the empty state. Pressing 'crtl + w' closes that powershell window and doesnt 'show all worktrees'

    really bad issue for me as I have ongoing conversations with a lot of time spent on planning.

  5. fredpottier commented on Feb 16, 2026

    @fredpottier

    Additional data: sessions-index.json stops being updated

    Environment:

    • Claude Code 2.1.42 (stable)
    • Windows 11 Pro 10.0.26200
    • Issue started: February 15, 2026

    Observation

    I noticed that /resume couldn't find my recent sessions. I compared sessions on disk vs sessions registered in the index and found a discrepancy:

    Sessions on disk:  118
    Sessions in index: 87
    
    LAST 15 sessions on disk (sorted by mtime):
    2026-02-14 22:46 | 318148cd | 1,478KB | IN INDEX
    2026-02-15 09:21 | 5d158395 |     5KB | *** MISSING ***
    2026-02-15 11:38 | a22bc060 |   526KB | IN INDEX
    2026-02-15 11:38 | bf049b7b |   396KB | IN INDEX
    2026-02-15 11:38 | c1d91bfa |   454KB | IN INDEX
    2026-02-15 11:38 | 0435bc47 |    73KB | IN INDEX
    2026-02-15 12:25 | 1d003a66 |   611KB | IN INDEX
    2026-02-15 13:13 | 66d486cc |   365KB | *** MISSING ***
    2026-02-16 00:08 | 9546067c |19,803KB | *** MISSING ***
    2026-02-16 07:48 | 621e03cb |    18KB | *** MISSING ***
    2026-02-16 08:03 | 90a2c3f3 | 5,187KB | IN INDEX (created before the issue)
    

    Facts

    • sessions-index.json was last modified on Feb 15 at 13:08
    • 4 sessions created after that timestamp exist on disk but are missing from the index
    • These sessions are invisible to /resume despite being fully intact on disk
    • One of them (9546067c, 20MB) represents several hours of work

    Additional finding: manually adding entries doesn't fix /resume

    I tried manually adding the missing sessions to sessions-index.json with the correct structure (identical keys: sessionId, fullPath, fileMtime, firstPrompt, summary, messageCount, created, modified, gitBranch, projectPath, isSidechain). The entries were successfully added and the JSON file validates correctly (118 entries, all keys matching existing entries).

    However, /resume still doesn't show the added sessions, even after restarting Claude Code in a new terminal. The file was not overwritten by Claude Code on restart (still shows our modifications with correct timestamp).

    This suggests that either:

    • /resume does not read sessions-index.json directly (or uses it only as a cache that gets regenerated from another source)
    • There is an additional mechanism or secondary index that controls which sessions appear in the picker
    • The index file may be read only once at some initialization point and cached in memory differently

    Possible investigation leads

    • The index file stopped being updated at a specific point in time — something may have caused writes to sessions-index.json to silently fail from that point on
    • I notice that at 2026-02-15 11:38, 4 sessions were created almost simultaneously — could be worth checking if concurrent index writes are properly handled
    • The 31 other missing sessions (118 on disk vs 87 in index) suggest this may have happened before as well, or that some session types are never indexed
    • Manually patching the index file does not restore visibility in /resume — the picker seems to rely on something else than (or in addition to) this file

    Diagnostic scripts

    Script 1 — Compare disk vs index (adapt <PROJECT> to your project path):

    import json, os, datetime
    
    index_path = os.path.expanduser("~/.claude/projects/<PROJECT>/sessions-index.json")
    sessions_dir = os.path.dirname(index_path)
    
    with open(index_path, encoding="utf-8") as f:
        indexed_ids = {e["sessionId"] for e in json.load(f).get("entries", [])}
    
    for f in sorted(os.listdir(sessions_dir)):
        if not f.endswith(".jsonl"):
            continue
        sid = f.replace(".jsonl", "")
        fpath = os.path.join(sessions_dir, f)
        mtime = datetime.datetime.fromtimestamp(os.path.getmtime(fpath))
        size = os.path.getsize(fpath) // 1024
        status = "OK" if sid in indexed_ids else "*** MISSING ***"
        print(f"{mtime:%Y-%m-%d %H:%M} | {sid[:12]} | {size:>6}KB | {status}")

    Script 2 — Add missing sessions to index (attempted fix, did not restore /resume visibility):

    import json, os, datetime, shutil
    
    index_path = os.path.expanduser("~/.claude/projects/<PROJECT>/sessions-index.json")
    sessions_dir = os.path.dirname(index_path)
    
    shutil.copy2(index_path, index_path + ".bak")
    
    with open(index_path, encoding="utf-8") as f:
        data = json.load(f)
    
    indexed_ids = {e["sessionId"] for e in data.get("entries", [])}
    
    for fname in os.listdir(sessions_dir):
        if not fname.endswith(".jsonl"):
            continue
        sid = fname.replace(".jsonl", "")
        if sid in indexed_ids:
            continue
        fpath = os.path.join(sessions_dir, fname)
        if os.path.getsize(fpath) == 0:
            continue
        mtime = os.path.getmtime(fpath)
        ctime = os.path.getctime(fpath)
        # Parse first user prompt
        first_prompt = "No prompt"
        msg_count = 0
        try:
            with open(fpath, encoding="utf-8") as sf:
                for line in sf:
                    try:
                        msg = json.loads(line.strip())
                        if msg.get("type") in ("user", "assistant"):
                            msg_count += 1
                            if first_prompt == "No prompt" and msg.get("type") == "user":
                                content = msg.get("message", {}).get("content", "")
                                if isinstance(content, list):
                                    for c in content:
                                        if isinstance(c, dict) and c.get("type") == "text":
                                            txt = c.get("text", "")
                                            if txt and not txt.startswith("[Request"):
                                                first_prompt = txt[:200]
                                                break
                    except json.JSONDecodeError:
                        continue
        except Exception:
            continue
        data["entries"].append({
            "sessionId": sid,
            "fullPath": fpath,
            "fileMtime": int(mtime * 1000),
            "firstPrompt": first_prompt,
            "summary": "",
            "messageCount": msg_count,
            "created": datetime.datetime.fromtimestamp(ctime).strftime("%Y-%m-%dT%H:%M:%S.000Z"),
            "modified": datetime.datetime.fromtimestamp(mtime).strftime("%Y-%m-%dT%H:%M:%S.000Z"),
            "gitBranch": "main",
            "projectPath": "<YOUR_PROJECT_PATH>",
            "isSidechain": False,
        })
    
    with open(index_path, "w", encoding="utf-8") as f:
        json.dump(data, f, ensure_ascii=False, indent=2)
  6. Darkwing4 commented on Feb 16, 2026

    @Darkwing4
    Author

    /resume has been broken for over a month. This makes Claude Code unusable for me. I had to build a workaround skill (“/resume-fix”) that searches the conversation history and exports it to Markdown, but it’s still inconvenient. I’m honestly surprised such a critical bug hasn’t been fixed yet. This was the first time in months I switched to other agents, and I ended up downgrading my Claude Code subscription because of it.

  7. Lennie commented on Feb 25, 2026

    @Lennie

    I had a similar problem:

    Title: Resuming migrated sessions fails due to thinking/redacted_thinking block validation
    Problem: After migrating ~/.claude to a new machine, resuming an existing session fails with API 400 errors:

    messages.X.content.0.thinking: each thinking block must contain non-whitespace thinking
    Invalid 'signature' in 'thinking' block
    Invalid 'data' in 'redacted_thinking' block

    Root cause: The API validates signatures on thinking/redacted_thinking blocks, but these become invalid after migration. There's no graceful fallback — the entire session is unresumable.
    Workaround: Manually strip all thinking and redacted_thinking blocks from the session JSONL file.
    Expected behavior: Claude Code should handle this gracefully — either by stripping invalid thinking blocks automatically when replaying a session, or by not sending them to the API at all (since they're not needed for conversation continuity).
    Environment: Claude Code on Linux, session migrated between machines (copied .claude/ and .claude.json*) - maybe have some official docs about how to do it properly ?

  8. github-actions commented on Mar 25, 2026

    @github-actions

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

  9. github-actions commented on Apr 2, 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.

  10. locked as resolved and limited conversation to collaborators on Apr 2, 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 workinghas reproHas detailed reproduction stepsmemoryplatform: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