Skip to main content
Version: 3.0.0

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 list or GET /api/events, or subscribe to the /ws/events WebSocket. See Reading events from the daemon.
  • Feed an external system. Subscribe to the WebSocket, poll GET /api/events with 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​

LayerWhat it carriesWhere you meet it
EventBus (per workflow)event_name + ExecutionContextwf.on(event_name, handler) inside @orca.workflow. Events from this workflow's runs only.
RuntimeEvent (whole system)One JSON-serializable record per eventStored 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​

EntityStatus enumStatuses
ACTIONActionStatusCREATED, RESOLVED, AWAITING_LOCATION_RESERVATION, AWAITING_CO_THREADS, EXECUTING_ACTION, AWAITING_MOVE_RESERVATION, PREPARING_TO_MOVE, PICKING, PLACING, COMPLETED, ERRORED, SKIPPED, ABORTED
METHODMethodStatusCREATED, IN_PROGRESS, COMPLETED, SKIPPED, PARTIAL_COMPLETE
THREADLabwareThreadStatusCREATED, 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)
WORKFLOWWorkflowStatusCREATED, IN_PROGRESS, COMPLETED, ERRORED
EXECUTIONruntime-levelCOMPLETED, PARTIAL_COMPLETED, FAILED, ABORTED (terminal only), and FAILED_INTERRUPTED for a run the last daemon process left running
SUBMISSIONSubmissionStatusACCEPTED, 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​

EventWhen
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_CLEAREDA device fault was latched or cleared. Carries a DeviceFaultContext.
COMMAND.<device>.STARTED / .COMPLETED / .FAILEDEvery 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 / .CLEAREDThe labware record changed, so anything that read it is out of date.
GROUP.<group_id>.COMPLETEDA 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.LOWThe co-labware coordinator detected tip exhaustion.
EXECUTION.<execution_id>.SIM_SPEEDUP_CHANGEDA simulated run's speed-up was changed. Carries the new sim_speedup.
OPERATOR.INSTRUCTIONAn action called ctx.manual_step(...).
CUSTOM.<name>.EMITTEDAn 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 / MoveActionExecutionContext for action events
  • MethodExecutionContext for method events
  • ThreadExecutionContext for thread events, and ManualInterventionContext when the thread is awaiting a manual place or remove
  • ExecutionLifecycleContext, SubmissionExecutionContext, GroupLifecycleContext for the lifecycle families
  • IncidentContext for INCIDENT.*, DeviceFaultContext for DEVICE.*
  • CustomEventContext for CUSTOM.*
  • OperatorInstructionContext for OPERATOR.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 SystemBoundEventHandler subclass with a handle(event_name, context) method, useful when the handler needs the bound System for 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.

HowUse 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/events with 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.COMPLETED fires 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 or GET /api/events.
  • Handler exceptions are caught and logged; they do not bubble. If a handler is misbehaving, an EVENT_HANDLER_EXCEPTION incident 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/events with a cursor.
  • ctx.emit is async. Awaiting it is required; a missed await silently 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; watch OPERATOR.INSTRUCTION and the thread's status instead.

See also​