Events
Every status change in a running workflow fires an event: a thread starts, an action completes, a device faults. This page is for anyone hooking something up to that stream, whether that is a live view of a run, an audit trail, a dashboard, or a step inside a workflow that waits for something else to happen first. If you are not integrating anything, you can skip it.
What you would use events for
- Watch a run from outside. The daemon stores every event and streams them live. Read stored events with
orca events listorGET /api/events, or subscribe to the/ws/eventsWebSocket. See Reading events from the daemon. - Feed an external system. Subscribe to the WebSocket, poll
GET /api/eventswith a cursor, or have the daemon POST each event to a URL with the webhook plugin. See The webhook plugin. - Make one step wait for another. Inside workflow code, an action emits a named event and another action, thread or branch waits on it. See Custom events from actions.
Two layers
| Layer | What it carries | Where you meet it |
|---|---|---|
EventBus (per workflow) | event_name + ExecutionContext | wf.on(event_name, handler) inside @orca.workflow. Events from this workflow's runs only. |
RuntimeEvent (whole system) | One JSON-serializable record per event | Stored events, the WebSocket feed and the webhook plugin. Every event from every run. |
The runtime turns each per-workflow EventBus event into a RuntimeEvent. A few events belong to no single run and exist only at the system level: incidents, device faults, device commands and labware record changes.
Event name shape
Events are dot-separated. Two forms:
<entity_type>.<entity_id>.<status> # specific (most common)
<entity_type>.<status> # generalized (subscribe-friendly)
When the engine emits THREAD.{thread_id}.STARTED it also fans out to any handler subscribed to the generalized THREAD.STARTED. A sink that wants every thread start across the system subscribes to the generalized form once. A workflow that wants to react to one specific thread subscribes to the 3-part form.
Entity types and their statuses
| Entity | Status enum | Statuses |
|---|---|---|
ACTION | ActionStatus | CREATED, RESOLVED, AWAITING_LOCATION_RESERVATION, AWAITING_CO_THREADS, EXECUTING_ACTION, AWAITING_MOVE_RESERVATION, PREPARING_TO_MOVE, PICKING, PLACING, COMPLETED, ERRORED, SKIPPED, ABORTED |
METHOD | MethodStatus | CREATED, IN_PROGRESS, COMPLETED, SKIPPED, PARTIAL_COMPLETE |
THREAD | LabwareThreadStatus | CREATED, AWAITING_MANUAL_PLACE, RESOLVING_ACTION_LOCATION, AWAITING_ACTION_RESERVATION, ACTION_LOCATION_RESOLVED, AWAITING_MOVE_RESERVATION, AWAITING_MOVE_TARGET_AVAILABILITY, MOVING, AWAITING_CO_THREADS, EXECUTING_ACTION, AWAITING_EVENT, AWAITING_MANUAL_REMOVE, PAUSED, COMPLETED, STOPPING, STOPPED, ABORTED, FAILED (crash-only: the thread's task died on an unhandled error) |
WORKFLOW | WorkflowStatus | CREATED, IN_PROGRESS, COMPLETED, ERRORED |
EXECUTION | runtime-level | COMPLETED, PARTIAL_COMPLETED, FAILED, ABORTED (terminal only), and FAILED_INTERRUPTED for a run the last daemon process left running |
SUBMISSION | SubmissionStatus | ACCEPTED, then the submission's own terminal status |
A run is recorded as ended only after every event it fired is saved. Its submissions' end events and its EXECUTION.<id>.<STATUS> end event fire after the statuses are set, and the run counts as ended only once those are saved too, so a reader that sees the run end finds all its events. Each wait is bounded at 30 seconds: if the event store does not answer, the run still ends, a RECORD_NOT_SAVED incident names it, and the run is not paused.
Engine-emitted special events
| Event | When |
|---|---|
INCIDENT.<incident_id>.<category> | Any incident was recorded. Summary fields only; the full typed detail stays on the incidents surface, keyed by incident_id. |
DEVICE.<device_name>.FAULTED / .FAULT_CLEARED | A device fault was latched or cleared. Carries a DeviceFaultContext. |
COMMAND.<device>.STARTED / .COMPLETED / .FAILED | Every device command, whoever sent it: a run or a person. The payload carries command_id, device_name, command, params, mode, execution_id, thread_id, thread_name, sim_speedup, nominal_seconds, and on the end event result, outcome, error, error_type and duration_ms. |
LABWARE.<labware_id>.SAVED / .MOVED / .CLEARED | The labware record changed, so anything that read it is out of date. |
GROUP.<group_id>.COMPLETED | A multi-group submission's group finishes. COMPLETED is the only GROUP status emitted. |
SLOT.<slot_key>.<status> | Receiver-slot lifecycle: OVERFLOW, REJECTED (a full REJECT slot paused the contributor), AWAITING_DECISION (the labware at a reuse site cannot serve, and the contributor paused), ORPHANED, ABANDONED. |
TIP_RACK.EMPTY / TIP_RACK.LOW | The co-labware coordinator detected tip exhaustion. |
EXECUTION.<execution_id>.SIM_SPEEDUP_CHANGED | A simulated run's speed-up was changed. Carries the new sim_speedup. |
OPERATOR.INSTRUCTION | An action called ctx.manual_step(...). |
CUSTOM.<name>.EMITTED | An action, method or thread called ctx.emit(...). See below. |
Incidents and device faults are the two an integration usually cares about first.
The RuntimeEvent shape
Stored events, the WebSocket feed and the webhook plugin all deliver RuntimeEvent records:
class RuntimeEvent(BaseModel):
model_config = ConfigDict(frozen=True, extra="forbid")
event_name: str # the full name
execution_id: str
timestamp: float
entity_type: str # parsed from event_name
entity_id: str # parsed from event_name (empty for a 2-part name)
status: str # parsed from event_name
context: ExecutionContext # type-specific payload
Events that belong to no execution (an incident with no execution, a device fault outside a run) carry the system id in execution_id.
event.context carries the per-event payload. The concrete type depends on the entity:
LocationActionExecutionContext/MoveActionExecutionContextfor action eventsMethodExecutionContextfor method eventsThreadExecutionContextfor thread events, andManualInterventionContextwhen the thread is awaiting a manual place or removeExecutionLifecycleContext,SubmissionExecutionContext,GroupLifecycleContextfor the lifecycle familiesIncidentContextforINCIDENT.*,DeviceFaultContextforDEVICE.*CustomEventContextforCUSTOM.*OperatorInstructionContextforOPERATOR.INSTRUCTION
model_dump(mode="json") gives the JSON shape, and that is what the WebSocket feed sends. Import the type with from orca.sdk.events import RuntimeEvent.
A terminal thread event keeps the why
ThreadExecutionContext carries pause_reason and last_error. The engine fills last_error on PAUSED, FAILED and ABORTED, so the last event of a thread says why it ended.
Subscribing
From inside a workflow
@orca.workflow(name="my_assay")
def my_assay(wf: WorkflowContext):
wf.start(plate_thread)
wf.on("ACTION.COMPLETED", AuditLogger())
wf.on(...) accepts:
- A callable:
def handler(event_name: str, context: ExecutionContext) -> None - A
SystemBoundEventHandlersubclass with ahandle(event_name, context)method, useful when the handler needs the boundSystemfor cross-entity lookups
Handler exceptions are caught and logged to the orca logger. One handler failing does not stop other handlers or the runtime. A persistent handler exception fires a PLUGIN_HANDLER_EXCEPTION or EVENT_HANDLER_EXCEPTION incident.
Reading events from the daemon
The daemon stores every event in <package>/.orca/state.db. They survive a restart.
| How | Use for |
|---|---|
orca events list [--since <cursor>] [--execution <id>] [--limit <n>] [--tail] | Looking from a terminal. |
GET /api/events?since=<cursor>&limit=<n>&tail=<bool>&execution_id=<id> | Polling. since is an integer cursor, not a timestamp. Each event comes with the cursor to resume after it. |
WebSocket /ws/events?execution_id=<id> | Live. One text frame per event. Leave execution_id out for every run. |
orca events list reads oldest first from --since. --tail returns the newest events instead.
A WebSocket frame is the JSON of one RuntimeEvent:
{"event_name": "THREAD.tid-2.STARTED", "execution_id": "...", "timestamp": 1731849600.0, "entity_type": "THREAD", "entity_id": "tid-2", "status": "STARTED", "context": {}}
The feed lasts for the life of the daemon, so a subscription stays open across orca topology mount, orca unload and orca runtime reload. It refuses a connection from a web page that is not served from the local computer.
Backpressure and ordering
- Events reach a subscriber in the order the runtime emitted them.
- Each WebSocket subscriber has its own queue of 1000 frames. When it is full the oldest frame is dropped, so a slow client cannot stall the runtime or other subscribers. A client that must not miss events reads
GET /api/eventswith its last cursor.
The webhook plugin
The daemon can POST every event to a URL. Set ORCA_PLUGINS to a JSON list before orca start:
ORCA_PLUGINS='[{"type": "webhook", "url": "https://example.org/orca-events"}]' orca start
A webhook config takes url, and optionally headers, event_filter, timeout (10 seconds), max_retries (3), backoff_base (0.5) and queue_size (256).
Waiting for a person
orca intervention next waits for the next event that needs someone: a manual place, a manual remove, a manual step, an incident or a device fault. It prints a cursor; pass it back with --after to get the one after that. The REST route is GET /api/interventions/next.
Writing a sink
IEventSink is a one-method protocol, on_event(event: RuntimeEvent) -> None, exported from orca.sdk.events. It is the interface the daemon's own event store and feed implement. A lab that runs packages on the daemon cannot register a sink of its own. Use the WebSocket, the stored events or the webhook plugin.
Custom events from actions
Inside an action, emit a custom event:
@orca.action(device=reader, inputs=[plate])
async def read_plate(ctx: ActionContext):
result = await ctx.device().read("absorbance.pro")
await ctx.emit("plate_reading", value="complete", data={"absorbance": result})
Other actions wait for it:
@orca.action(device=evaluator, inputs=[plate])
async def evaluate(ctx: ActionContext):
value, data = await ctx.wait_for("plate_reading")
...
Labware threads can wait too. ThreadContext.wait_for uses consumed semantics so looping sees each new publish.
Workflows can branch:
yield orca.branch("plate_reading", {
"complete": [evaluate_step],
"failed": [retry_step],
})
A custom emit also reaches the runtime event surface. The same call that unblocks a wait_for fires CUSTOM.<name>.EMITTED with a CustomEventContext, so the stored events and the WebSocket feed both carry it without any extra wiring. The name arrives as written. It may hold only letters, digits, _ and -, because the bus grammar owns the dot: qc.result is refused where it is written, and qc_result arrives as CUSTOM.qc_result.EMITTED.
Pitfalls
- 2-part subscribers see ALL 3-part fans of the same status. Subscribing to
ACTION.COMPLETEDfires for every action across every thread. If you only want one entity's events, subscribe to the 3-part form. wf.on(...)is per-workflow, not global. It fires only for events emitted by executions of THIS workflow template. For every run's events use the WebSocket feed orGET /api/events.- Handler exceptions are caught and logged; they do not bubble. If a handler is misbehaving, an
EVENT_HANDLER_EXCEPTIONincident fires. Acknowledging the incident does NOT disable the handler; fix the handler in code. - WebSocket subscriber queues are bounded. A subscriber that cannot keep up loses events (oldest dropped). For lossless capture, read
GET /api/eventswith a cursor. ctx.emitis async. Awaiting it is required; a missedawaitsilently fails to emit.OPERATOR.CONFIRM.<step_id>is not an event. It is an internal wait channel the manual-step confirmation resolves. Subscribing to it gets you nothing; watchOPERATOR.INSTRUCTIONand the thread's status instead.
See also
- Where state lives: the file events are stored in.
- Context API:
emitandwait_forsemantics on each context. - Recovery: the incident model behind
INCIDENT.*. - Runtime: the daemon and the ways to reach it.
- Glossary: every term on this page, in one place.