Agent sub-sessions pollute /resume picker — isSidechain never set to true

Resolved 💬 3 comments Opened Mar 18, 2026 by exurocommits Closed Mar 22, 2026

Problem

When the Agent tool spawns sub-agents, each sub-agent creates a separate .jsonl session file in the same directory as user sessions (~/.claude/projects/<project>/). These are indistinguishable from real user sessions in the /resume picker.

In heavy agent-delegation workflows, this creates massive pollution. One project accumulated 106,777 agent session files (avg ~7KB each) alongside only 11 real user sessions (50KB-6.7MB).

Root Cause

The sessions-index.json schema already includes an isSidechain boolean field on every entry — but it is never set to true for agent-spawned sessions. All 5,510 indexed entries in one project show isSidechain: false, including obvious agent sessions whose firstPrompt starts with agent system prompts like <purpose>Terse quality-check agent....

Evidence

Total session files: 107,692
Files < 15KB (agent sessions): 106,699
Files 15-50KB: 981  
Files > 50KB (real sessions): 12

sessions-index.json entries: 5,510
isSidechain=true: 0 (should be ~5,500)

Agent session first messages contain structured agent prompts (e.g., <purpose>...</purpose>), while real sessions contain natural language user messages.

Proposed Fix

  1. Set isSidechain: true when the Agent tool creates a sub-agent session
  2. Filter /resume picker to exclude isSidechain: true entries by default (or show them in a separate section)
  3. Optional: Store agent sessions in a subdirectory (e.g., agents/) for filesystem-level separation

The infrastructure is already there — the isSidechain field just needs to be populated correctly.

Environment

  • Claude Code version: 2.1.77
  • Platform: macOS Darwin 24.6.0
  • Workflow: Heavy sub-agent delegation (explore, implement, verify patterns)

Workaround

Currently the only workaround is manually deleting or moving small session files, which is not sustainable.

View original on GitHub ↗

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