What is a Run?
A Run is a single task submitted to an agent. Each run:- Targets a named Profile (the agent’s definition)
- Carries a SubTask (the work to do)
- Produces a stream of RunEvents (progress, tool calls, responses)
- Is assigned a unique
runIdand asessionId
Submitting a Run
202 Accepted:
SubTask Schema
Streaming Events (SSE)
Once you have arunId, open an SSE stream:
RunEvent objects as Server-Sent Events. Events are replayed for late subscribers (the conductor buffers the run’s event log).
RunEvent Types
Every event in the stream is a JSON object with atype field:
progress
Lifecycle milestones emitted by the runner and conductor.
session_init
Runtime-native conversation handle emitted once per run when the sidecar reports it.
The conductor preserves it as runtimeSessionId; UIs can ignore this event unless they need to correlate an Orca session with a Claude SDK session_id or Codex thread_id.
assistant
A text response from the LLM.
tool_call
The agent is invoking a tool.
tool_result
The result of a tool invocation.
usage
Token usage reported by the LLM provider.
result
The final answer produced by the agent. Signals that the run is complete.
error
An unrecoverable error during the run.
Complete Event Sequence
A typical run produces events in this order:Consuming Events in TypeScript
Run Persistence
Runs are stored in an append-only JSONL log whenAGENT_ORC_RUNS_DIR is set on the conductor:
<runId>.jsonl file containing a header, event lines, and a finish line. Conductor replays these files on restart to reconstruct the in-memory run registry.
Without AGENT_ORC_RUNS_DIR, runs are in-memory only and lost on conductor restart.
Listing & Inspecting Runs
GET /api/runs/{id} response includes the full event log for completed runs.
Run Status
Stopping a Run
UseDELETE /api/runs/{runId} for normal, cooperative cancellation. It cancels the run context, aborts the runner stream and sidecar turn, and returns 204 No Content.
If the run remains stuck, use POST /api/runs/{runId}/terminate as a last resort. Termination independently attempts to cancel any in-process run, waits up to two seconds for the session’s run claim to drain normally, then steals the claim only if it remains held. It also marks the durable run row as cancelled; a late completion cannot overwrite that status. The response reports which steps succeeded:
claimStolen: true identifies a claim that did not drain and had to be forcibly taken. Any warnings are stable codes rather than internal error details.