Bug: deleted session's UUID gets reused for a brand-new session (stale lastSessionId pointer)

Status Closed — not planned
Maintainer reply None cached
Activity 2 comments · opened Aug 12, 2026 · closed Aug 22, 2026

Repro

  1. Run claude in a project, then delete that session's transcript file (~/.claude/projects/<encoded-cwd>/<uuid>.jsonl) while the CLI is not running.
  2. Launch a fresh, bare claude in the same project directory.
  3. Check ~/.claude.jsonprojects["<cwd>"].lastSessionId.

Result

lastSessionId still points at the UUID of the session that was just deleted in step 1. The new claude invocation reuses that same UUID for its own (brand-new, unrelated) session file, instead of generating a new one.

Why this matters

  • The deleted session's UUID "comes back to life" attached to completely different content, which is confusing when cross-referencing IDs (e.g. in logs, /resume history, or scripts).
  • If anything external keeps a reference to the old UUID (notes, bug reports, tooling), it will silently now resolve to unrelated content once the ID is recycled.
  • More generally, lastSessionId is never invalidated/cleared when the session file it points to is removed, so this pointer can go stale any time a session is deleted out from under the CLI.

Verified

Reproduced live: deleted a session's .jsonl, confirmed via direct inspection that ~/.claude.json's lastSessionId for that project still referenced the deleted UUID, then launched a fresh claude and observed the new session file created on disk using that exact recycled UUID.

(Related to #85907 — same root cause class of "per-project state not cleaned up on session deletion," but this one is the lastSessionId pointer specifically rather than orphaned session files.)

View original on GitHub ↗

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