Session metadata corrupted on /exit - loses conversation context on resume

Resolved 💬 4 comments Opened Feb 1, 2026 by orangemelon69 Closed Mar 2, 2026

Bug Description

When using /exit to leave a session, the sessions-index.json metadata gets corrupted, causing the session to lose its conversation context when resumed.

Steps to Reproduce

  1. Have an active session with substantial conversation history
  2. Rename the session using /rename <name>
  3. Exit using /exit
  4. Resume the session (either automatically or via /resume)
  5. Result: Claude has no memory of the previous conversation

Root Cause Analysis

I debugged this issue and found the following:

Before /exit:

  • Session JSONL file: 5,140 lines, 6.9 MB of conversation history
  • Session started: 2026-01-31T20:03:36.916Z
  • Actual user messages: 326

After /exit - sessions-index.json was corrupted:

{
  "sessionId": "b1eeadf9-3cac-4f43-9b95-f24302f55111",
  "firstPrompt": "No prompt",
  "summary": "User Exits Conversation",
  "messageCount": 3,
  "created": "2026-02-01T09:19:39.950Z"
}

Key Observations:

  1. The created timestamp was overwritten to the exact time when /exit was run
  2. The messageCount was reset to 3 instead of the actual ~326 user messages
  3. The summary was changed to "User Exits Conversation"
  4. The firstPrompt was set to "No prompt"

The session JSONL file still contains all 5,140 lines of conversation history - only the index metadata was corrupted.

Expected Behavior

  • created should preserve the original session creation timestamp
  • messageCount should reflect the actual number of messages
  • summary should not be overwritten with "User Exits Conversation"
  • On resume, Claude should have access to the full conversation history

Workaround

Manually editing ~/.claude/projects/<project>/sessions-index.json to restore the correct metadata values allows the session to be resumed with context.

Environment

  • Claude Code version: 2.1.27 → 2.1.29 (upgraded during session)
  • OS: macOS (Darwin 25.0.0)
  • Session had custom hooks from plugins (beads workflow, etc.)

Impact

This is a significant issue because:

  • Users lose hours of conversation context without warning
  • The bug is silent - no error message indicates the corruption
  • It happens during normal usage patterns (rename + exit + resume)

View original on GitHub ↗

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