SDK-spawned subagent sessions are persisted as independent top-level sessions (flood the resume picker)
Environment
- Claude Code version: 2.1.211
- Platform: macOS (darwin 25.5.0)
- Entrypoint of affected sessions:
sdk-py(subagents / review fan-outs spawned via the Python SDK)
Bug
Subagent runs spawned through the SDK (Agent tool, /security-review fan-out agents, etc.) are persisted as independent top-level sessions in ~/.claude/projects/<project>/. Each agent gets its own <uuid>.jsonl with:
isSidechain: falseuserType: "external"parentUuid: nullon the first user message- no parent-session pointer anywhere in the file
The only hint that they are agent transcripts is entrypoint: "sdk-py" / promptSource: "sdk" on the message records.
Because isSidechain is false and there is no parent link, the resume/session picker lists every subagent as if it were a real interactive session.
Impact
In one active project directory, 267 of ~440 session files are SDK-spawned agent transcripts — 265 of them are security-review fan-out agents whose first message is "Review this change for security vulnerabilities…". The session list is ~60% agent noise, and real sessions are hard to find in claude --resume.
Sample record (first user message of one such file)
{
"parentUuid": null,
"isSidechain": false,
"type": "user",
"permissionMode": "default",
"promptSource": "sdk",
"userType": "external",
"entrypoint": "sdk-py",
"cwd": "/Users/<user>/<project>",
"sessionId": "4825e1eb-...",
"version": "2.1.211",
"gitBranch": "main"
}
Expected
Subagent transcripts should either be marked as sidechains (isSidechain: true), carry a parent-session reference, or otherwise be excluded/grouped in the session picker — not listed as standalone user sessions.
Repro
- In any project, run a command that fans out SDK subagents (e.g.
/security-review, or spawn agents via the Agent tool). ls ~/.claude/projects/<project>/— one new top-level<uuid>.jsonlper agent.claude --resume— each agent appears as an independent session.
This issue has 1 comment on GitHub. Read the full discussion on GitHub ↗