Repository navigation
Description
Summary
Orca persists orchestration tasks, dispatches, and messages, but the coordinator run loop is still poll-driven and keeps important campaign state in memory. A successful worker_done, escalation, or decision gate may remain unseen until an explicit inbox check or the next coordinator poll; if the coordinator/runtime restarts, an in-flight campaign does not reconstruct all of its state and resume deterministically.
Introduce a durable, event-driven coordinator contract: lifecycle-message persistence should wake the owning coordinator, and a restarted coordinator should reconstruct its complete campaign state from the orchestration database without manual re-dispatch.
User-visible failures this would unify
- Orchestration completion can remain unseen without an explicit inbox poll #8698: successful completion remains unseen without an explicit inbox poll.
- [Bug]: A failed dispatch never propagates to the task — dead agents leave tasks 'ready' forever and work is silently dropped #8984: failed dispatches do not propagate to task state, silently dropping work.
- [Bug]:
worker_donewith null taskId/dispatchId silently fails to complete the task #7429: malformed/null lifecycle provenance does not complete the active task. - [Bug]: Remote disconnect is misclassified as agent completion #9151: disconnect can be misclassified as completion.
- [Bug]: Terminal/session handle instability breaks orchestration message addressing and injection #9163: routing through changing terminal handles delays or prevents message injection.
orca statuscan report ready while individual orchestration RPCs transiently returnruntime_unavailable, leaving the coordinator unable to determine whether it should wait, retry, or fail work.
These have separate immediate causes, but they violate the same invariant: every terminal lifecycle outcome must deterministically advance the durable task graph and wake its owner.
Source evidence on current main
src/main/runtime/orchestration/coordinator.tsrunstick()followed bysleep(pollIntervalMs); messages are read on the next tick rather than waking the loop when persisted.- The coordinator's completed tasks, failed tasks, escalations, and stop state are held in process memory.
runFromExistingRun()can reopen a coordinator run row, but restart convergence does not reconstruct the complete prior in-memory state, active wait position, and escalation context.lifecycle-reconciliation.tsreconciles lifecycle messages, but it is not a durable process/session supervisor and does not turn every endpoint exit into an authoritative task transition.
Expected invariants
- Persisting
worker_done,escalation,decision_gate, heartbeat, or endpoint-exit state wakes the owning coordinator immediately. - Every dispatched attempt reaches one durable terminal outcome: completed, failed, retryable, blocked, or explicitly cancelled.
- A coordinator restart reconstructs completed/failed sets, active gates, unresolved escalations, attempts, and dependencies from durable state.
- Delivery and lifecycle authority are keyed by stable dispatch/pane identity rather than a transient terminal handle.
- Duplicate/replayed messages are idempotent.
- Aggregate runtime health reflects whether the orchestration subsystem can service a trivial request for the current generation.
Suggested acceptance tests
- Persist
worker_donewhile the coordinator is sleeping; assert it wakes and advances the dependent task without an explicit inbox poll. - Kill a dispatched worker; assert the dispatch and task converge on an explicit failed/retry state and an escalation is emitted.
- Restart Orca with a three-task DAG containing one completed task, one active decision gate, and one dispatched worker; assert the coordinator resumes exactly once with the same dependency and escalation state.
- Remint a terminal handle while preserving pane/dispatch identity; assert lifecycle messages still route to the correct coordinator.
- Replay the same completion message after restart; assert no duplicate completion or worker launch.
- Make orchestration RPC health fail while the runtime socket remains reachable; assert
orca statusreports a degraded orchestration subsystem rather than aggregate ready.
Related implementation work
- fix: harden orchestration lifecycle messages #8388, fix(orchestration): fail direct dispatches on agent exit #9001, fix(orchestration): complete null-id worker_done from active dispatch #7790 and fix(orchestration): emit message timestamps as RFC3339 UTC (partial, refs #8698) #9167 harden individual lifecycle paths.
- PR Recover stale coordinator runs #6981 approaches stale coordinator-run recovery.
- PR feat(orchestration): Orcastrator — a persistent director for multi-worktree orchestration #6293 explores a persistent director.
This issue is intended as the durable/event-driven contract tying those paths together, not a replacement for their focused fixes. Prepared with AI assistance from source inspection and live orchestration failures. Reporter: @ericjung.
Activity
seankwon816 commentedon Jul 22, 2026
Field data supporting this, from a multi-team deployment (8 concurrently coordinated teams, macOS 1.4.148, heavy
orca orchestrationuse):Over the last 3 days we logged 11 incidents/repairs in exactly this failure family ("worker finished; coordinator never learned"), including 5 recurrences of the same pattern across different agent runtimes. Every one ended with the human operator manually waking the coordinator pane — today the operator is effectively the delivery layer.
Two concrete findings that may sharpen the contract:
The dispatch preamble actively fights the only workaround. The injected worker preamble says "worker_done ends your turn… take no further actions." Until lifecycle-message persistence wakes the owning coordinator, the only reliable surfacing path is the worker injecting a wake line (
terminal send --enter) after worker_done — which the preamble forbids. Compliant workers are precisely the ones that strand their coordinators. Filed with a cheap preamble-level fix option as a separate issue.Delivery semantics are ambiguous across three signals. We have measured messages where
delivered_atremainsnullpermanently even after the recipient read and acted on the message (thereadflag flips and the pane visibly processes it), while CLIok:trueis only enqueue acceptance. Suggest the event-driven contract expose explicit states — e.g.queued/delivered/surfaced(coordinator woken) — so senders can verify a handoff without screen-scraping.Also +1 on restart durability: we hit the adjacent gap where a worker restarted from a handoff (previous dispatch already terminal) has no valid task/dispatch coordinates for its first minutes — honest heartbeats are impossible (reusing the dead dispatch IDs would mask a hung retry). A first-class dispatch reissue/adopt step — coordinates issued before work starts — would close that window.
Workarounds we currently maintain that this contract would delete outright: mandatory wake-ping rules, an atomic worker_done+wake helper script, spec trailers overriding the preamble, and low-frequency coordinator self-checks. Happy to share traces.
mhingston commentedon Oct 4, 2026
This contract still looks important, but quite a bit of the surrounding orchestration machinery has landed since the issue was written and #15190 is now tracking the loop in detail.
Would it be useful to reconcile this issue against current
mainand turn the acceptance criteria into a remaining-gap checklist? In particular, which of these are still open today:If #15190 now owns most of this contract, linking/closing individual criteria there may be clearer; otherwise this could remain the higher-level durability invariant with the current gaps called out explicitly.
0xAlbertChen commentedon Nov 30, 2026
Strong +1. This is one of the most important requirements for production-grade orchestration.
I am moving a multi-host agent fleet from an LLM-driven coordinator to a deterministic program coordinator, with a target of supporting up to 100 concurrent agent seats.
We need:
Reading a message should not be equivalent to successfully processing it.
This would allow us to eliminate custom polling, terminal inspection, and recovery scripts. Orca should own the execution lifecycle, while external coordinators own business policies.
Related: #37407, #11229, #15828.