/resume session list is incomplete and not chronologically sorted

Resolved 💬 6 comments Opened Apr 11, 2026 by AliceLJY Closed Jul 3, 2026

Description

The /resume command in Claude Code CLI shows an incomplete and incorrectly sorted session list. Sessions created via the Agent SDK (@anthropic-ai/claude-agent-sdk query()) and CLI sessions share identical JSONL metadata (entrypoint: "cli", same cwd, same version), but /resume fails to list many of them and does not sort chronologically.

Environment

  • Claude Code version: 2.1.101 (also reproduced on 2.1.98, 2.1.100)
  • OS: macOS (Darwin 25.5.0)
  • ~950 session JSONL files in the project directory

Steps to Reproduce

  1. Have sessions created by both CLI (interactive terminal) and Agent SDK (query() with cwd set to home directory)
  2. Both produce identical JSONL structure — same entrypoint, cwd, version, permissionMode fields
  3. Run /resume in the terminal

Expected Behavior

All sessions listed in reverse chronological order (by file mtime), regardless of whether they were created by CLI or Agent SDK. This is how it used to work.

Actual Behavior

  • Ordering is wrong: entries jump between "15 min ago → 56 hours ago → 2 hours ago → 12 hours ago" instead of being sorted chronologically
  • Sessions are missing: many valid .jsonl files in the same project directory are not listed
  • No data difference: verified that missing sessions have identical metadata structure to listed sessions — same type: "permission-mode", type: "attachment", entrypoint: "cli", cwd, version fields

Workaround

A simple Python script that scans all .jsonl files under ~/.claude/projects/, sorts by mtime, and extracts the last user message as preview produces the correct and complete list — confirming the data is there, just not being read properly by /resume.

Additional Context

The Agent SDK adapter uses query() which spawns the same CLI subprocess, so sessions are indistinguishable at the JSONL level. The regression appears to have started around version 2.1.98 (April 10, 2025).

View original on GitHub ↗

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