Workflow stall watchdog kills agents during auto-compaction
Summary
Inside a Workflow-tool run, the per-agent stall watchdog (stalled — no progress for 180000ms) fires while the agent is auto-compacting its context. Compaction at 180K to 350K tokens takes 150 to 205 seconds and streams nothing the watchdog counts as progress. The runtime then retries the agent from scratch up to six times; each retry re-reads the same material, reaches the same context size, compacts, and dies again.
Environment
- Claude Code 2.1.252, 2.1.257 and 2.1.260 (native binary), macOS 25.5
- Headless
claude -pdriver,--output-format stream-json,CLAUDE_CODE_PRINT_BG_WAIT_CEILING_MS=0 - Workflow scripts with
parallel()fan-outs of 7 to 15 Sonnet 5 / Opus 5 agents,--allowedToolsexplicit
Data (751 workflow agent transcripts from one project, 2026-08-31 to 2026-09-02)
- 33 agents failed with the stall message. In all 33 the last persisted record is a tool result and the interrupt lands 179 to 180 s later with no assistant output in between.
- Final-attempt context of those 33: 160K to 358K tokens; 28 of 33 within 185K to 195K.
- 166 auto compactions that survived in sibling agents: last record to
compact_boundarymedian 156 s, p90 176 s, max 180 s; to the first post-compaction assistant record median 160 s, p90 183 s, max 205 s. Context at compaction: median 224K. - Ordinary completed turns at 185K to 200K context: median 3 s, p90 7 s. Completed
Writecalls of 35KB to 55KB took 182 to 288 s and were not killed, so streamed output does count as progress. - Every stalled agent shows six attempts in the workflow state file, 0.78M to 1.17M cumulative tokens each.
Expected
Compaction is a runtime action. The watchdog should treat it as progress (or pause during it), and a stall retry should not restart with an identical prompt six times.
Workarounds tried
CLAUDE_CODE_AUTO_COMPACT_WINDOW moves the compaction trigger but the 180 s limit and the retry count have no knob. Bounding each agent's reads below the compaction band avoids the kill.