[BUG] Session cleanup leaves orphaned subagents folder when main .jsonl is deleted

Resolved 💬 3 comments Opened May 1, 2026 by RamaKrishna-4 Closed May 5, 2026

Preflight Checklist

  • [x] I have searched existing issues and this hasn't been reported yet
  • [x] This is a single bug report (please file separate reports for different bugs)
  • [x] I am using the latest version of Claude Code

What's Wrong?

Folders related to the sessions that are older than 30 days are not deleted properly leading to orphaned files and folders in ./claude/projects folder.

What Should Happen?

Entire session folder (including subagents/) is removed, or main .jsonl is retained as long as subagents exist

Error Messages/Logs

claude --resume <id> fails with "No conversation found" even though the session folder exists

Steps to Reproduce

Create a new session that uses Sub agents or identify any existing session id.
Wait for a session to be 30 days old so that its cleaned up automatically
Check ~/.claude/projects/<project>/ — the session folder and subagents/ directory remain but the main .jsonl file is gone .

Claude Model

Sonnet (default)

Is this a regression?

I don't know

Last Working Version

_No response_

Claude Code Version

v2.1.126

Platform

Anthropic API

Operating System

macOS

Terminal/Shell

Terminal.app (macOS)

Additional Information

_No response_

View original on GitHub ↗

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