Stream and read results

Subscribe to live Service session and thread SSE streams, correlate inbox entries with runs, and reconstruct conversation state after reconnecting.

Use this guide after submitting work from your application. Retain the session, thread and inbox entry IDs from the receipt. Read saved run output for a final result; add the session stream when your interface needs progress. A disconnected observer does not cancel execution.

Results

Read GET /runs/{run_id} and choose the next action from status:

StatusWhat to do
accepted, runningKeep observing this run.
completedRead output, text or JSON matching output_spec.
waitingRead pending and submit a complete resume response.
failedInspect failure.code and failure.message.
cancelledInspect saved history before choosing a follow-up or fork.

For submitted messages, confirm which run consumed the inbox entry (assigned_run_id + consumed), since an assigned entry can return to pending if not incorporated and subsequent runs may also execute on the same thread.

Use /runs/{run_id}/items for ordered display history. It returns recent items and complete; page backward with the first item's ordinal as before, or forward with after. Fields exceeding 32 KiB use content_refs; read saved content at /runs/{run_id}/contents/{content_id}. Each field retains at most 16 MiB, with truncated marking a saved prefix. Console's full/saved-content actions read these references.

For diagnosis, /runs/{run_id}/agent returns executed configuration, /lineage returns ancestors, and /attempts explains initial execution, recovery or worker handoff. /threads/{thread_id}/runs lists newest first. current_run_id identifies active work; last_run_id identifies the ended history from which continuation starts.

Follow a session stream

Use GET /sessions/{session_id}/stream for live display across the session. It is an SSE stream that starts each connection from current state, without a reconnect cursor.

EventClient action
threadReplace the thread and named current/last runs.
itemsReplace that run's items from ordinal first onward; keep earlier final items. Continue live display from continuation.
deltaApply provisional output to the run's display.
gapMark missing output and wait for the next items frame to repair it.
app_readyEnable the identified MCP Apps.

An items frame with complete: true is the run's final display. Use the run's status for its outcome. On reconnect, discard unfinished displays and rebuild active runs from the new snapshot. Read /runs/{run_id}/items for runs that ended while disconnected. Ignore unknown event names.

Reconnect with randomized backoff capped at 30 seconds, respecting Retry-After for 429 or 503; inspect and fix the request or payload before retrying other 4xx refusals or invalid frames. The stream delivers provisional updates while saved items hold the durable display record. The frame schemas are exported in proto/a13n-service/session-stream.schema.json.

On this page