Repository navigation
Description
Bug report: a headless run started via POST /api/chat/runs stops executing steps mid-task and stays running indefinitely, with no error and no way to cancel. Seen 2026-08-27 on a scheduled-report test; the same shape ("runs sit ~40 minutes between steps") was observed on 2026-08-25 runs and never filed. Business context, once: a customer's weekly report that stalls after collecting data never sends, and the customer sees nothing — not even a failure.
Summary
Run wrun_01M10C21FAQ52YYC42ATJ78E9F (chat ab6305ae-ef22-4d0b-bee5-f4d3c7946eed, account 7ad6c0e8…, model moonshotai/kimi-k3) started 00:55 UTC, executed 22 agent steps (95 tool-bash calls, all with state: output-available), and made its last LLM call at 01:12:36 (usage_events, 18 events, 630 credits). Its last persisted part is a completed bash call whose output is the computed medians for six artists — the agent was about to write the email. At 01:58 UTC GET /api/chat/runs/{runId} still returns "status":"running", completedAt: null; no new usage_events, no Apify runs, no email_send_log row for 46 minutes. The chat_messages row for the assistant turn was written at 01:07:08 and never updated after 01:12.
Steps to reproduce (or the trigger)
POST /api/chat/runswith a long multi-step prompt (the roster-signal prompt: ~18 scrapes, ~100 tool calls, ~15 minutes of collect) on a Pro account.- Poll
GET /api/chat/runs/{runId}every 75 s. - Observe
runningcontinuing past the point whereusage_eventsand tool activity stop. Compare a healthy run of the near-identical prompt 30 minutes earlier:wrun_01M1077P4T4NC7PBKRH61DF74V, 22:55 → completed 00:15 (41 min), email delivered.
Expected vs actual
- Expected: every agent step is followed by the next step within seconds; if a step cannot be scheduled or fails, the run ends
failedwith a reason, andGET /api/chat/runs/{runId}says so. - Actual: the run is silent for 46+ minutes with
status: running. There is no cancel (DELETE /api/chat/runs/{id}→ 405,/canceland/stop→ 404), so the only remedies are waiting or re-firing (which double-charges credits and, for a real task, double-sends if the stalled run later wakes).
Where to look
- The durable workflow behind
POST /api/chat/runs(api/app/api/chat/runs,lib/chat/runAgentWorkflow): what happens between a tool step'soutput-availableand the next model step — a step-queue/scheduling gap, a lost continuation after a long tool call, or a step retry that never fires. The last tool call before the stall was a ~2 spython3 -cover a local JSON file, not a long-running scrape. - Whether the workflow has any step timeout at all; the prompt's own "35-minute" instruction is advisory and the platform enforced nothing.
Done when
- A run whose next step does not start within N minutes (N to be chosen; 5 is generous) ends
failedwitherror: "step timeout"and the status endpoint reflects it. POST /api/chat/runs/{runId}/cancelexists and is documented, so an operator can stop a wedged run before re-firing.- Re-running the stalled prompt shape three times completes every time within the collect + write budget;
wrun_01M10C21…'s stall does not recur across those runs.
Evidence
- Run:
wrun_01M10C21FAQ52YYC42ATJ78E9F· createdAt 2026-08-27T00:55Z · statusrunningat 01:58Z. - Healthy control:
wrun_01M1077P4T4NC7PBKRH61DF74V(22:55 → 00:15Z, delivered, Resend id on file). usage_eventsfor account7ad6c0e8…after 00:54Z: 18 rows, last 01:12:36Z.- Apify runs after 00:54Z: 30, last 01:13:45Z (all SUCCEEDED).
- Earlier sightings, unfiled: 2026-08-25 Secondhand Talent test runs sat ~40 minutes between steps before completing.
Activity
sweetmantech commentedon Aug 27, 2026
Update 2026-08-27 02:08 UTC: the run did resume on its own.
wrun_01M10C21FAQ52YYC42ATJ78E9Fsent its email at 02:00:xx UTC and now reportscompleted— total 65 minutes, of which ~48 minutes (01:12:36 → ~02:00) had no step execution at all. So the failure mode is a very long step-scheduling gap, not a permanent hang; the ask stands (a bounded gap, plus a cancel), and the re-fire I did at 01:59 (wrun_01M10F25GFDHWKC4D0HBKAEDTV) will now double-send, which is exactly the operator-side consequence of having no cancel.sidneyswift commentedon Nov 6, 2026
An operator can already stop a headless run with
POST /api/chat/{chatId}/stop, using thechatIdreturned byPOST /api/chat/runs. Runs claim the chat's active stream, so Stop cancels them.Left: no step timeout (a stalled run still reads
running), and no run-id cancel route. Decide whether the chat Stop route is enough, and document it on the runs page if it is.sidneyswift commentedon Nov 8, 2026
Status: stalled scheduled runs are now detected after the fact (live), but the stall itself isn't fixed.
recoupable/api#1236 checks every hour for scheduled runs that started 2–3 hours earlier and sent no email. A run that stalls shows up in the Telegram alert as
no email (no send attempted; run executing), with its account and run ids.Still open: no step timeout inside the workflow, so the run itself still reads
running, and there's no run-id cancel route.