/resume command silently drops sessions with large first messages (>~15KB)

Resolved 💬 2 comments Opened Feb 14, 2026 by esperie Closed Feb 16, 2026

Bug Description

The /resume <session-id> command returns "Session was not found" for sessions where the first user message exceeds approximately 15KB, even though the session file exists and claude --resume <session-id> from the terminal works correctly.

Steps to Reproduce

  1. Start a session where the first user message is large (e.g., pasting a detailed plan >15KB)
  2. End the session
  3. Try /resume <session-id> from within another session
  4. Observe: "Session <id> was not found."
  5. Try claude --resume <session-id> from the terminal
  6. Observe: Session loads successfully

Root Cause

Traced through the compiled binary (v2.1.42). The /resume command's session lookup pipeline:

  1. UR0() scans project directories for .jsonl session files via dpT()works correctly, session is found
  2. V1T() enriches entries by calling ky8() for each session
  3. ky8() calls by8() which reads only the first 16,384 bytes (16KB) of the .jsonl file
  4. by8()yy8() splits the buffer by newlines and tries to JSON.parse() each line looking for the first user message
  5. If the user message line extends beyond the 16KB buffer, the line is truncated and JSON.parse() fails silently (caught by try/catch)
  6. firstPrompt remains empty
  7. ky8() applies the filter: if (!_.firstPrompt && !_.customTitle) return nullsession is dropped

The relevant code path:

/resume <uuid>
  → Cp(f9())        // get project paths via git worktree list
  → nPR(paths)      // load sessions
    → $lT(paths)
      → UR0(paths)  // scan dirs, create lite entries with sessionId from filename
      → V1T(entries, 0, 10)  // enrich first 10
        → ky8(entry) // reads first/last 16KB
          → by8()    // buffer too small for large first messages
          → yy8()    // JSON.parse fails on truncated line
          → returns null (no firstPrompt, no customTitle)

Example File Layout

line 0: {"type":"file-history-snapshot",...}     ~236 bytes
line 1: {"type":"progress",...}                   ~617 bytes  
line 2: {"type":"user","message":{...}}          ~19,301 bytes  ← exceeds remaining buffer

The 16KB buffer contains lines 0-1 fully and only ~15,530 bytes of line 2. The truncated JSON fails to parse, so firstPrompt is never extracted.

Expected Behavior

/resume <session-id> should find and resume any valid session, regardless of the first message size.

Suggested Fixes

  • Option A: When looking up by exact UUID (not searching by title), skip the ky8 enrichment filter entirely — the session ID match is sufficient
  • Option B: Increase the read buffer or implement line-aware reading that follows truncated lines
  • Option C: Fall back to reading more data when the first user message isn't found in the initial buffer

Environment

  • Claude Code version: 2.1.42
  • OS: macOS (Darwin, arm64)
  • The session file exists in the correct project directory and has valid content

🤖 Generated with Claude Code

View original on GitHub ↗

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