[BUG] cleanupPeriodDays does not delete subagent transcripts — 2,388 files dating back 3 months persist past 30-day cutoff

Resolved 💬 4 comments Opened May 11, 2026 by saurabhav88 Closed May 15, 2026

Per code.claude.com/docs/en/sub-agents: "Transcripts are cleaned up based on the cleanupPeriodDays setting (default: 30 days)." But code.claude.com/docs/en/claude-directory lists projects/<project>/<session>.jsonl as the only transcript path in the cleanup scope — subagent JSONLs at projects/<project>/<session>/subagents/agent-*.jsonl are not listed and are not deleted in practice.

Reproduction

On macOS 26, Claude Code with default cleanupPeriodDays (no override in ~/.claude/settings.json):

$ find ~/.claude/projects -name "*.jsonl" -not -newermt "$(date -v-30d +%Y-%m-%d)" -path "*/subagents/*" | wc -l
2388

$ find ~/.claude/projects -name "*.jsonl" -not -newermt "$(date -v-30d +%Y-%m-%d)" -not -path "*/subagents/*" | wc -l
0

Main session transcripts are correctly cleaned at 30 days. Subagent transcripts in the subagents/ subdirectory are not. Oldest subagent transcript on disk is from 2026-02-14 (87 days ago). Total size of stale subagent transcripts: 604 MB.

Impact

  1. Standing data-on-disk footprint grows unbounded. ~604 MB on my machine; will be much larger for heavy subagent users.
  2. Privacy/security: subagent transcripts can contain secrets (env vars, API keys, tool results, file contents). Users expecting the documented 30-day cap have an unbounded leak surface — local disk theft, backup compromise, accidental sharing of ~/.claude/.
  3. Docs contradiction: sub-agents.md promises cleanup; claude-directory.md omits the subagent path from the cleanup scope.

Related issues

  • #51779 — flags missing cleanup for tasks/, backups/, shell-snapshots/. Doesn't cover subagent transcripts.
  • #38576 — notes sub-agents docs claim cleanupPeriodDays covers transcripts, but is scoped to tool result files.

Suggested fix

Either:

  • Include projects/<project>/<session>/subagents/ in the cleanup walker so subagent JSONLs age out at the same 30-day cutoff as main transcripts, or
  • Update sub-agents.md to clarify subagent transcripts are exempt from cleanupPeriodDays and document a manual cleanup recommendation.

The first option matches user expectations set by the existing sub-agents documentation.

View original on GitHub ↗

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