[Bug] Non-deterministic sub-session termination breaks long-running automation
Bug Description
Subject: Background/sub-session process killing (~v2.1.212) is non-deterministic and breaks long-running automation
Since ~v2.1.212 (mid-Jul 2026), nested headless sub-sessions (claude -p launched from a background Bash task) are SIGTERM'd at a variable, unpredictable 7–28 minutes — the sub-session's transcript ends in
"[Request interrupted by user]". This is not explained by any configured timeout: my wrapper timeout was 90 min, CLAUDE_AFK_TIMEOUT_MS is 24h, and background jobs aren't subject to the Bash tool timeout.
Before this version, the same long-lived sub-sessions ran fine.
Notably it's inconsistent: a bare background sleep survived 40 min unharmed in my testing, but a nested claude -p gets killed early. The behavior appears undocumented (docs mention "process tree of a running
Bash command terminated on SIGTERM" and "idle background sessions stop after ~1h", but nothing about a 7–28 min window).
Why this matters — real use cases it breaks:
- Multi-stage autonomous orchestration (one claude -p sub-session per stage).
- Asking Claude to verify a long build/test suite passes before committing (e.g. a 30-min Maven run with heavy integration coverage). Related: the foreground Bash cap of 10 min (BASH_MAX_TIMEOUT_MS) also
blocks this unless backgrounded — please consider raising/removing that cap for opted-in long commands.
- Any real automation meant to run for hours unattended.
Requests (if the reaper is intended):
- Make it deterministic and documented — a fixed, published timeout, not a random 7–28 min window. Unpredictable kills are impossible to design around.
- Give users an override — an env var / flag to extend or disable it, so legitimate multi-hour sub-processes can run to completion (parallel to how BASH_MAX_TIMEOUT_MS works for the Bash tool).
- Signal it, don't kill silently — surface a clear reason/event when a sub-session is reaped, so it's diagnosable instead of a mysterious mid-run interruption.
Environment: macOS (darwin 25.5), Claude Code CLI 2.1.216.
Environment Info
- Platform: darwin
- Terminal: intellij
- Version: 2.1.216
- Feedback ID: 59eccb1c-54a9-4eab-a923-b319366966f6
Errors
[]