[BUG] Desktop idle-reaper (SessionIdleManager 300s) kills active autonomous-agent sessions and their background sub-agents — quantified weekly waste
Summary
On macOS Desktop, Claude Code sessions are being terminated by the Desktop app's SessionIdleManager ~5-minute (300s) idle archiver. When the session dies it takes its background sub-agents (Task tool, run_in_background) and in-flight git worktrees with it (SIGTERM / exit 143). For agentic / orchestrator workloads this is far worse than for interactive chat: a /build-style orchestrator that is waiting on its sub-agents produces no actionable output, so it looks "idle" to the reaper and is a prime target — exactly when killing it is most expensive.
This is not a new root cause. It is the same one as #23092 (closed not_planned, stale-bot), #62202 (open, but labelled stale), and #59449 / #59729 (both closed as duplicate). Reasons for re-filing: (1) it is still happening every day — a week of fresh incidents below; (2) no prior report quantifies the token / compute cost, which is substantial under autonomous multi-agent use; (3) the canonical issues keep being auto-closed by the stale-bot rather than fixed.
Note on costs: every dollar figure in this report is computed at published list price (Opus), not amounts actually billed. Token counts are the firm, directly-measured figures; the dollar conversions are derived from them at list price purely to convey scale. See the cost section for the rate card and caveats.
Environment
- Platform: macOS (Darwin 25.3.0), Apple Silicon
- Surface: Claude Code inside the Claude Desktop app (the CLI in a terminal is reportedly unaffected — see #62202)
- Workload: autonomous
/buildpipeline — an orchestrator session dispatching fresh sub-agents per phase, plusrun_in_backgroundbuild/test tasks - Window analysed: 2026-06-23 → 2026-06-30 (8 days), single solo developer, one machine
Mechanism (what actually kills the work)
Two independent local killers, established by direct log/ticket verification:
- (Primary) Desktop
SessionIdleManager300s idle archiver. Archives/kills a session after ~300s of no actionable output, SIGTERMs the childclaudeprocess (exit 143), and terminates its background sub-agents + worktrees. App-layer wall-clock event — independent of power / lid / display / sleep (observed firing on AC power, lid open, screen on). Documented in #23092 ([SessionIdleManager] Initialized with 300s timeout,was_killed: true) and #62202 (exit 143 at exactly 300s intervals; terminal CLI immune). #23092 was closed not planned → there is no official off-switch and env vars do not reach it. - (Secondary) macOS sleep. Lid-close clamshell sleep ignores software keep-awake assertions (incl.
caffeinate); battery idle-sleep ~1 min. Real, but not the primary driver here — the deaths below occurred on AC with the lid open.
Why orchestrators are uniquely exposed: the idle clock is keyed to no actionable output. A session emitting tool calls survives; an orchestrator blocked on its children is silent → reaped. So the reaper preferentially kills the long, expensive, multi-agent runs.
Evidence — last 8 days (2026-06-23 → 2026-06-30)
Counting only deaths that forced an explicit continuation/recovery prompt ("a prior agent died / the process exited / killed mid-run"), there were ≥26 reap-and-recover events in 8 days on one machine. This is a floor — silent deaths recovered inline (without a distinct continuation prompt) are not counted.
Representative incidents (timestamps UTC, from session transcripts):
- 2026-06-23 ~07:00 — an implementation agent: "a prior agent started this and DIED mid-implementation (the Claude Code process exited)". WIP only survived because it had been checkpoint-pushed.
- 2026-06-23 ~08:00 / ~08:50 — two later phases each came to rest INCOMPLETE; continuations dispatched.
- 2026-06-23 ~13:26 — "the prior agent died mid-run (the whole process exited)"; progress survived only because it was on the remote branch.
- 2026-06-23 21:07 / 21:31 / 21:48 / 22:03 — four separate recovery dispatches on one phase, each noting "a prior agent on this phase died on a host process-exit" → workers were then told to "push early and often" purely as a reap mitigation.
- 2026-06-24 ~14:04 — a tranche restarted "after the prior agent died (orchestrator process crash)".
- 2026-06-28 / 2026-06-29 — multiple
<task-notification> … No completion record was found for this background shell command **from the previous session**— the signature of a background task whose owning session was torn down underneath it. - 2026-06-29 ~12:38 — "FINISHING work a prior agent nearly completed before it was killed mid-run".
- 2026-06-30 ~10:54 — "CONTINUATION … after the prior agent died mid-run".
The 06-23 cluster alone shows ~8 process deaths in a single day during an overnight autonomous build. The pattern recurs on 06-24, 06-28, 06-29, and 06-30.
Cost of the reaping (token + compute estimate)
⚠️ All dollar amounts below are at published Opus _list price_ — not amounts billed. Rate card used: input $15/M, output $75/M, cache-write $18.75/M, cache-read $1.50/M. The token counts are the firm, measured figures; the dollars are a derived, list-price illustration of scale only. Actual cost depends on plan, subscription bundling, and any discounts, and will differ.
Tier 1 — directly measured hard floor (re-priming). Every continuation must rebuild context a fresh process cannot inherit: re-read skill files + project guide, re-run code retrieval, re-read the tracker, re-establish git state. Measured on turn 1 only of each of the 26 continuations:
- 1,761,486 tokens of uncached context rebuild (~68K tokens/incident), pure overhead that would not exist without the reap. ≈ $26–33/week (list price). This is a floor (turn 1 only).
Tier 2 — measured envelope. The 26 recovery sessions consumed, in total:
- input 3.59M · output 11.72M · cache-write 84.86M · cache-read 1.80B → 1.90 billion tokens, ≈ $5,229 (list price). Not all of it is waste (they did real finishing work), but it bounds the redone-work universe.
Tier 3 — modelled reap-attributable waste. Re-orientation, re-discovery, redone typecheck/build, and orchestrator detect→diagnose→dispatch that an uninterrupted session would not repeat. At 25–50% of continuation spend:
- ≈ 0.48B – 0.95B tokens/week, ≈ $1,300 – $2,600/week (list price) — for one solo developer.
Mechanism penalty (cache). A reap destroys the warm prompt cache; the continuation re-pays cache-write ($18.75/M) instead of cache-read ($1.50/M) — a 12.5× unit-cost penalty on the rebuilt context. The 26 continuations wrote 84.9M cache-creation tokens (≈ $1,591 at list price), a large share of which is rebuilding caches the reaped sessions already held warm.
Scaling. This is one developer on one machine. The per-seat waste scales with autonomy and fan-out (more concurrent sub-agents = more killed-with-parent), so across a fleet of agentic users the absolute compute waste is materially larger than the figures above.
Why the current state is unsatisfactory
- The root-cause issue (#23092) is closed not planned; #62202 is open but
staleand will likely be auto-closed; #59449 and #59729 were closed as duplicates. The stale-bot is closing live, reproducible, costly bugs. - There is no user-facing off-switch and no documented env var that reaches the Desktop archiver.
- The only working mitigations are workarounds, not fixes: run from the terminal CLI or cloud routines (immune), and commit + push after every step so a kill is cheap. These shift cost onto the user and don't help anyone who reaches for the Desktop app.
Requested fixes (in priority order)
- Do not reap a session that has live child processes / background sub-agents / running MCP operations. Liveness should include the work the session owns, not just its own stdout.
- Expose a setting to disable or extend the idle timeout (e.g.
SessionIdleManageroff / 30–120 min), reachable from Desktop preferences and/or an env var that actually takes effect. - If a session must be archived, detach (don't SIGTERM) its background sub-agents and worktrees, and preserve recoverable context.
- Stop the stale-bot from auto-closing this class of bug while it remains reproducible.
Happy to share raw transcript excerpts, the per-session token table, or ~/Library/Logs/Claude/main.log snippets on request.
This issue has 2 comments on GitHub. Read the full discussion on GitHub ↗