Repository navigation
Description
Environment
- Orca macOS 1.4.137 (
com.stablyai.orca), macOS 26.5.2 (25F84), Apple Silicon - Local runtime healthy throughout (
orca status→runtimeState: ready,runtimeReachable: true) - Local dispatch, Claude Code workers
- Evidence below is from
~/Library/Application Support/orca/orchestration.db(read-only queries)
Summary
When a dispatched agent dies (last_failure = "Agent exited with code -1"), Orca records the failure on the dispatch row but never propagates it to the task row. The task stays status='ready' forever — indistinguishable in orca orchestration task-list from a task that simply hasn't started yet.
There is no retry, no re-queue, no escalation message, and no circuit_broken transition. The work is silently dropped.
In my case a 6-PR implementation campaign produced only 5 PRs. Nothing surfaced that PR 4 of 6 had been dispatched, run for 12 minutes, died, and been abandoned. I only discovered it days later by reading the DB by hand.
Evidence
1. Orca was alive and actively processing the failure — it wrote status and last_failure onto the dispatch row, but wrote nothing to the task:
task dispatch_wrote dispatch_reason task_left_at task_result
----------------- -------------- ------------------------- ------------ -------------------
task_b81cc199e541 failed Agent exited with code -1 ready (no result written)
So this is not "the app died before it could update" — it updated one table and not the other.
2. It is systematic, across 5 separate days / independent campaigns (not a single crash):
SELECT COUNT(*) FROM tasks t JOIN dispatch_contexts d ON d.task_id = t.id
WHERE t.status = 'ready' AND d.status = 'failed';
-- 25day orphaned tasks
2026-07-01 3
2026-07-03 8
2026-07-09 2
2026-07-10 2
2026-07-15 10
All 25 share last_failure = 'Agent exited with code -1'.
3. Overall state divergence:
task_status dispatch_status n
----------- ------------------ ---
completed completed 106 <- happy path is fine
ready failed 25 <- the bug: silently abandoned
ready (never dispatched) 5
dispatched dispatched 3
failed failed 2 <- only because a human ran task-update by hand
The only 2 tasks that ever reached failed have the same "Agent exited with code -1" reason but carry an explicit hand-written result: {"reason":"cancelled: worker context-saturated"}. i.e. failure reaches the task table only when a human types it in.
4. The workers were healthy right up to death — heartbeats and even decision_gate question/answer traffic, then the whole bus went silent at 12:41:51Z and never emitted another message.
Correlation: serial dispatch survived, parallel fan-out did not
Same campaign, same day, same machine:
- 00:09Z → 12:15Z — 14 tasks dispatched one at a time (each after the previous completed) → 14/14
completed. - 12:16Z → 12:30:54Z — coordinator fanned out 9 dispatches in ~100 seconds → 9/9 died with
"Agent exited with code -1"within ~12 minutes.
Given the two hand-labelled cases say worker context-saturated, I suspect the workers exhausted context (each was pointed at a ~3,300-line spec) and exited. That part may be expected agent behaviour — the bug I'm reporting is that the death is silently swallowed rather than surfaced.
Expected
When a dispatch fails, at minimum one of:
- Propagate — set
tasks.status = 'failed'(or back topending/readywith a recordedresult/attempt count) so the ledger reflects reality; and/or - Retry / circuit-break —
failure_countstays stuck at1and the schema already has acircuit_brokenstate that never engages; and/or - Escalate — emit an
escalationmessage so a supervising coordinator learns its worker died; and/or - Surface —
orca orchestration task-listshould visibly distinguish "ready (never dispatched)" from "ready (last dispatch died)". Today they render identically, which is what made the loss invisible.
A stale last_heartbeat_at is already recorded and would be a sufficient signal for a reaper.
Actual
tasks.status stays ready indefinitely. task-list shows [ready]. Nothing indicates the agent ran and died. Work is dropped with zero signal.
Reproduction
- Create and dispatch a task to a worker agent.
- Kill the agent (or let it exit non-zero / saturate context) so the dispatch records
Agent exited with code -1. orca orchestration task-list→ the task is still[ready].- Query the DB:
SELECT t.status AS task_status, d.status AS dispatch_status, d.failure_count, d.last_failure
FROM tasks t JOIN dispatch_contexts d ON d.task_id = t.id
WHERE d.status = 'failed';→ task_status='ready' while dispatch_status='failed'.
Impact
This is a silent correctness/data-loss failure for any multi-agent campaign. A fan-out of N tasks can return N−k results and the operator has no way to notice from the tooling — the missing tasks look identical to queued ones. It scales badly: the more parallel the fleet, the more likely a worker dies, and every death is invisible.
Related but distinct: #8698 (successful worker_done needs an explicit inbox poll to be seen). This one is the failure path, where the outcome is dropped entirely rather than merely delayed.
Activity
AKarode commentedon Jul 16, 2026
Correction — root cause of the agent deaths identified, and it strengthens this report.
In the original post I speculated the workers died of context saturation. That was wrong, and the real trigger is more mundane and more likely to hit other users:
macOS auto-installed an OS update and restarted the machine out from under the running fleet.
Evidence it was an external kill, not per-agent exhaustion:
Writetool call + successfultool_result— it was working normally, then simply ceased.Why this matters for the bug: an OS-initiated restart is a completely ordinary event for a long-running agent fleet (it's the default setting on macOS). So the "dispatch dies → task silently stays
ready" path is not an exotic edge case — any unattended overnight campaign on a default-configured Mac can hit it. That is exactly what happened here: the reboot was recoverable (I could have just re-run the 9 tasks), but because the failure never reached the task ledger, 1 of the 9 was silently dropped and stayed lost until I read the DB by hand days later.The core report is unchanged and still fully evidenced: Orca wrote
status='failed'+last_failure='Agent exited with code -1'onto the dispatch rows (so the app was alive and processing the failure after the reboot) and never propagated it totasks.status, which remainsreadytoday across 25 tasks / 5 separate days.AKarode commentedon Jul 16, 2026
Code-level root cause (from
app.asar, 1.4.137) — this is more specific than my original framing, and I think it makes the fix clearer. It is not a missing propagation; it's a requeue-for-retry into a queue that only exists when a coordinator loop is running.failDispatch:and the agent-exit handler:
So on an agent death with no active coordinator run (i.e. the CLI / manually-dispatched workflow — my
coordinator_runstable is empty, I have only ever dispatched viaorca orchestration dispatchfrom a supervising agent):tasks.statusis set back toready— intentionally, to be retried.ready.failure_counttherefore stays at 1 forever — it only increments per dispatch attempt — so the>= 3circuit_brokenpath (the one that would settasks.status='failed'and make the loss visible) is unreachable by construction.if (run).Net effect: the task lands back in
ready, indistinguishable from "never dispatched", with no message, no retry, and no possible escalation tocircuit_broken. That matches my data exactly — 25 orphans, every onefailure_count = 1, across 5 separate days.Suggested fixes (any one would have saved me)
failDispatchfires with no active coordinator run, don't silently requeue toready— either mark the taskfailed/blocked, or record the death on the task itself so it isn't indistinguishable from untouched work.task-listshow it: a task requeued after a dead dispatch should not render identically to a never-dispatched one (e.g. surfacefailure_count/last_failure/last_heartbeat_at).orca orchestration dispatchwhen no coordinator run is active, since in that mode retry, circuit-breaking and escalation are all silently inert. That contract isn't documented anywhere I could find, and it's the entire safety net.Happy to test a fix against my DB (25 real orphans, preserved and untouched) if that helps.
AKarode commentedon Jul 16, 2026
Empirical repro + confirmation that the coordinator loop DOES recover — which pins the bug precisely.
I reproduced both paths on a clean scratch worktree (1.4.137). Summary: the recovery machinery works correctly when a coordinator run is active. Without one, the exact same death is silently swallowed. That asymmetry is the bug.
With a coordinator run active — works as designed ✅
orca orchestration run --spec … --max-concurrent 1 --worktree name:<scratch>, one canary task, thenkill -9the worker PTY:failActiveDispatchOnExitfired, the task was requeued, the loop spun up a replacement terminal and re-dispatched it, and a high-priority escalation was emitted. Exactly right.Without a coordinator run — identical death, silently dropped ❌
That is my production case:
coordinator_runsempty,if (run)false → no escalation, and nothing drainsready→ no retry →failure_countfrozen at 1 →circuit_broken(the only state that would settasks.status='failed'and make it visible) is unreachable. 25 tasks, 5 days, allready/failed.So the entire safety net — retry, escalation, circuit-breaker — is silently conditional on a coordinator run existing, and
orca orchestration dispatchwill happily dispatch without one and give no hint. That contract isn't documented anywhere I could find.Minimal ask: warn (or refuse) on
orchestration dispatchwhen no coordinator run is active, since in that mode every failure is invisible by construction.Two further findings from the same repro
1. A worker that dies without a PTY exit wedges its task forever, and
--max-concurrentslots leak.Killing the agent process (
claude, a child of the shell) left the PTY alive, sofailActiveDispatchOnExitnever fired:task=dispatched, dispatch=dispatched, failure_count=0, last_heartbeat_at=NULL— permanently. SinceslotsAvailable = maxConcurrent - count(status='dispatched'), that task permanently consumes a slot, and a--max-concurrent 1loop is wedged forever at 0 slots.tick()callswarnStaleDispatches(), which the source says intentionally only warns:I understand the false-positive reasoning, but "keeps its terminal slot until a human notices" is doing a lot of work when nothing tells the human. My DB has 3 such tasks stuck
dispatchedsince 2026-07-01 withlast_heartbeat_at = NULL— 2 weeks, zero heartbeats, never surfaced. A stale-dispatch reaper (or at least surfacinglast_heartbeat_atintask-list) would close this.2. The loop's auto-created worker is a bare login shell, so auto-dispatch produces garbage.
When no idle terminal exists, the loop does
createTerminal(worktree, {title: 'Worker: …'})— which starts/bin/zsh -l, not an agent. It then dispatches the task spec into it, and zsh just tries to execute the prompt:So the loop only works if you pre-create agent terminals in the target worktree; its own fallback silently produces a non-worker that will never complete the task (and holds a slot). Happy to split this into its own issue if you'd prefer.
yoyofreeman commentedon Oct 16, 2026
Independent reproduction on Linux + a new dimension: this also happens when the Run did have a coordinator (not only when none ever existed).
Confirming #8984 on a different platform and a different workflow shape, with a variant that your analysis doesn't cover.
Environment
orca-ide --version)run-create → task-create → worker-start --agent pi), always inside a bound Run~/.config/orca/orchestration.db, read-onlySame signature, larger scale
32 of 208 tasks (15%), across 26 distinct Runs, multiple workspaces (harness / writing / ziwu_lan / video_studio / …), oldest 205h stale — and still growing (3 such tasks created on the most recent day). Every one has its dispatch at a terminal state (
failed); none has a live dispatch. So it's not a snapshot artifact — it keeps accumulating.New dimension: a coordinator was present — it just doesn't help after the Run settles
Your root-cause comment pins it on
getActiveCoordinatorRun()returning null when no coordinator run exists (if (run) { …escalation… }), and your fleet had an emptycoordinator_runstable.In ours the picture is:
run_coordinator_handleshas 119 rows across 115 Runs — these Runs did have a live coordinator — andcoordinator_runsis empty because those Runs have since settled. The re-queue-to-readystill happens, and still nothing drains it, because by the time the dispatch died the Run had no active coordinator.So the failure mode is broader than "dispatched without a coordinator run": any Run that has settled still leaves its dead dispatches stranded in
ready/blockedforever. Theif (run)guard means escalation is skipped precisely in the common case where the coordinator has already moved on. A reaper keyed onlast_heartbeat_at(still recorded) would fix both cases.failure_countis not always 1Your data showed every orphan at
failure_count = 1(hencecircuit_brokenunreachable). Ours splits two ways:28/32 are
failure_count = 1(consistent with your finding), but 4 arefailure_count = 0withdispatch.status='failed'— a dispatch that recorded a failure without ever incrementing the count.last_failurefor these isstopped/Terminal closed by operator request. Whatever the cause, it's a second path into the same dead-end state, and it also can never reach the>= 3circuit_brokenbranch.Impact (matches yours)
tasks.statusstaysready/blocked, rendering identically to never-dispatched work in anytask-list-style view; completion stats are wrong; a supervising "unfinished tasks" audit false-positives on 15% of the ledger. We only found it by reading the DB by hand (via a read-only audit tool we wrote).Repro (read-only, cross-platform)
Expected (same as your list): propagate to
tasks.status, and/or retry/reap on stalelast_heartbeat_at, and/or surfacefailure_count/last_failureintask-listso a dead-dispatch task is distinguishable from a queued one. Plus: don't gate the escalation onif (run)— a settled Run's dead dispatches are exactly the ones a human most needs told about.