Workflow tool: no per-agent wall-clock/heartbeat timeout — a stalled agent() call hangs 15–50min instead of failing fast
What happened
The Workflow tool (background multi-agent workflow orchestration, where a script calls agent() many times) has no per-agent() wall-clock or heartbeat timeout. When a single agent() call's model stream stalls, nothing terminates it — the call hangs for 10–50 minutes and then returns a near-empty payload, and the workflow makes no progress in the meantime.
A 4-phase workflow that should take a few minutes ran for ~3h16m during a window of API stream slowness. One phase alone burned ~2h53m.
Evidence
A representative stalled workflow agent's transcript had only 13 events:
- It loaded two skills and never reached its actual work.
- Each
assistantturn emitted a one-token output but was preceded by a ~15-minute gap (observed gaps: 946s, 948s, 621s). - So ~42 minutes of wall-clock produced two skill-loads — i.e. the time was pure time-to-first-token / mid-stream stall, not heavy work, not a retry loop.
The same session's API was healthy before and after (a trivial probe agent returned in ~2s once the slow window passed), so the stalls were transient infra slowness — but unbounded because nothing capped them.
Contrast — the main-loop Agent tool does cap this
The interactive Agent (subagent) tool appears to have a ~600s stream watchdog: in the same session, two foreground subagents that stalled were killed at almost exactly the 10-minute mark and surfaced as failures, which is recoverable. The Workflow runtime's agent() has no equivalent, so an identical stall there is unbounded.
Why the workflow script can't self-cap
Workflow scripts can't implement the timeout themselves: the sandbox bans Date.now()/timers, and agent() isn't cancelable from the script. So the cap has to live in the runtime.
Request
Give the Workflow runtime a per-agent() heartbeat / wall-clock cap (ideally configurable), matching the main-loop Agent watchdog: if a call makes no stream progress within the budget, kill it and surface a failure (or auto-retry once) so the orchestrating script can handle an ordinary failed step instead of hanging indefinitely.
Environment
- Claude Code CLI, macOS (darwin 24.6.0)
- Feature: Workflow tool (background workflows spawning subagents via
agent())