[BUG] Subagent processes not cleaned up when Claude.app session ends
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?
Subagent processes spawned by Claude.app are not being terminated when the parent session ends or when the app is closed. This leads to significant memory accumulation over time.
After a Claude.app session, I found 22 stale subagent processes still running, each consuming ~450-510MB of memory (totaling ~10GB). All processes shared the same resume session ID and persisted overnight.
What Should Happen?
Subagent processes should be terminated when:
- The parent conversation/session ends
- Claude.app is quit (Cmd+Q)
- The spawning session is closed
Error Messages/Logs
/Users/<username>/.local/bin/claude --output-format stream-json --verbose --input-format stream-json --model opus --resume 388bb4f1-024f-492c-912b-8cb180b6cf6a --disallowedTools Bash,Read,Write,Edit,Grep,Glob,WebFetch,WebSearch,Task,NotebookEdit,AskUserQuestion,TodoWrite --setting-sources --permission-mode default
22 instances of this process running, each consuming ~450-510MB of memory.
Steps to Reproduce
- Use Claude.app desktop application with subagent-spawning features
- Have a session that spawns multiple subagents (e.g., using Task tool)
- Close the conversation or quit Claude.app
- Run
ps aux | grep claudeto see orphaned subagent processes still running - Note that processes persist even after the app is closed
Workaround: pkill -f "claude.*--resume" to manually clean up
Claude Model
Opus
Is this a regression?
I don't know
Last Working Version
_No response_
Claude Code Version
2.1.2 (Claude Code)
Platform
Anthropic API
Operating System
macOS
Terminal/Shell
Terminal.app (macOS)
Additional Information
This issue was observed with Claude.app (desktop application) spawning subagents for Task tool operations. The subagents use the --resume flag with a shared session ID, suggesting they're meant to be part of the same conversation context.
Impact: ~450-510MB per orphaned process, totaling ~10GB when 22 processes accumulate overnight.
Environment: macOS Darwin 25.2.0
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗