Concepts
Watch and steer live
Follow a run as it works, send it the next instruction, stop it, or take over its desktop. Every surface reads the same event stream.
A run is not a black box you wait on. While it works you can read its events as they happen, send it follow-ups, cancel it, and in the console watch or drive the computer it is using. The API, the console and the CLI read the same stream and write the same session.
The event stream
GET /o/{org}/sessions/{session}/events is a server-sent event
stream. Each frame is an event: line, an id: and a JSON data: line.
| Event | When |
|---|---|
status |
Before the sandbox starts, and on every status change. Data: {status}. |
message, thinking |
The agent's own text and reasoning. |
tool_use, tool_result |
A tool call and its outcome, linked by call_id. |
result |
The turn's final answer. |
error |
A harness error. An error with no type ({code, message}, code NOT_FOUND or STREAM_ERROR) ends the stream early. |
done |
The last frame. Data: {status, output, result}. |
The stream closes after done. If your connection drops, reconnect with the Last-Event-ID
header (or ?cursor=) set to the last id you saw, and the stream resumes after it. Comment lines
(: keepalive) hold idle connections open.
A session that has already finished sends only status and done, never its history. Read past
events from GET …/messages.
curl -N https://api.phoenix.so/o/$RUSH_ORG/sessions/$SESSION_ID/events \
-H "Authorization: Bearer $RUSH_API_KEY" -H "Last-Event-ID: $LAST_ID"Follow-ups
A follow-up is the next instruction in the same session:
POST …/messages with {"input": "…"}, the same text or
file blocks a run takes. It answers 202 with the session and the turn the message opened, and
wakes a parked sandbox where it left off.
A follow-up sent mid-turn, by an API key or from the console, waits in line: its turn is queued
and runs when the turn before it ends, in the order they were sent. Wait on that turn
(GET …/p/_/sessions/{session}/turns/{turn}), not on the session, until it leaves queued and
running: it ends completed with this message's answer, needs_review if the proof is missing
or incomplete, or failed, with an error_code if it never ran. Up to 20 follow-ups wait at once;
one more answers 429 QUEUE_FULL.
A follow-up to a closed session is 409 TASK_TERMINAL.
Cancel
POST …/cancel, with no body, ends the run and releases its sandbox.
It answers 202 with the session: status cancelled, or cancelling while the sandbox is still
being released. On a finished session whose sandbox is still kept (parked for follow-ups, or still
up), it releases that sandbox and the session keeps its status, answer and error; messages waiting
in line for it fail, and a follow-up to it is then 409 TASK_TERMINAL. A finished session whose sandbox is already gone answers
409 RUN_STATE_CONFLICT.
Browser and computer
A run's sandbox has a desktop and a browser the agent uses. From the run's page in the console, the run's owner or an org admin can:
- Watch the display, read-only. Any number of people can watch at once.
- Take control of mouse and keyboard.
- Open a terminal in the sandbox.
For anyone else in the org, a run's live surfaces answer 404, as if the run did not exist. A run
with no desktop to show answers 409 VISUAL_UNAVAILABLE.
The control lease
Only one person drives a desktop at a time. Taking control grants a control lease for 5
minutes, which the holder can renew while they work, up to 15 minutes ahead. While someone holds
it, another request to take control answers 409 CONTROL_HELD with the holder's name and when
their lease expires.
The holder releases it when done, and a run owner or org admin can release anyone's lease. When
the run ends (completed, failed or cancelled) the lease ends with it.
Steer a run as a team walks through handing a run between people.