client.runs in Python and client.Runs in Go.
Why a run pauses
A run reads statuspaused when it waits on a person. Three things pause a
run:
- The agent asks, for example for a one-time code (
requested_by: "agent"). - A script calls
run.ask, or a step fails underon_failure: "ask"(requested_by: "code"). - You call
POST /runs/{run_id}:pause(requested_by: "caller").
input_request says what it needs:
expires_at is the earliest of the run’s pause timeout
(pause_timeout_seconds, 600 by default), its time limit, and the end of its
session. If nobody answers by then, the run fails with input_timeout. A
run.paused webhook fires when the run pauses. It carries the reason, never
the message.
Pause a run
POST /runs/{run_id}:pause asks a running run to pause, with reason
caller_requested. An agent-mode run pauses at its next model step: a step
already running finishes first. A code run pauses at its script’s next phone
action. The call returns the run as it is, and the run reads paused once the
pause lands. A run that is not running returns 409.
- Dashboard
- REST API
Open the run and click Pause the run next to the message box. Click
Resume the run to go on.
Answer a paused run
POST /runs/{run_id}:resume names the input_request_id it answers and an
action:
- Dashboard
- REST API
Open the run. The question shows in the chat. Type the answer and send it.
For a failed script step, you can take control of the phone in the live
view first, then retry the script or complete the run with your own
result.
422. A run that
is not paused, a different input_request_id, or an expired request returns
409. With answer or retry, the run reads running again once its phone
has the answer, and run.resumed fires.
Message an agent while it works
POST /runs/{run_id}:sendMessage sends a message to an agent-mode run that is
running or paused. The model reads it before its next step, as a message from
the person running the task. Use it to steer the run, for example “Use the
work account”. A message never resumes a paused run: answer the pause with
:resume.
- A run holds at most 20 unread messages. A message past that, or one that arrives as the run finishes, may never be read.
- A message is required and can be up to 64 KiB. An empty or larger message
returns
400. - The run’s stream carries each message the run receives as a
user_messageevent. - A code run, or a run that is queued or scheduled, returns
409.
Follow up after a turn
A task and its follow-ups are one run. When an agent-mode run’s turn ends (completed, failed or cancelled), the run holds its phone untilkeep_alive_expires_at, set from the run’s keep_alive_seconds (120 seconds
by default on POST /runs). A :sendMessage in that time starts the run’s
next turn on the same phone, with the same screen and the same Python
state. The run goes back to queued, then running.
turnis the current turn’s number, from 1.turnslists every turn, oldest first, each with its openingmessage,status,result_text,output,error,modelandusage. Turn 1 has no message: it runs the task.- The run’s top-level
status,result_text,output,error,started_atandcompleted_atare the latest turn’s.usageis the sum of every turn. - Each turn gets the run’s full limits:
max_steps,max_cost_microdollarsandtimeout_seconds. A follow-up can setmodelfor its turn and nothing else. - After the hold ends,
:sendMessagereturns409and the chat is over. Start a new run, which may get a different phone. - The model sees a summary of the earlier turns and continues from the screen as the last turn left it.
- Dashboard
- REST API
Open the run. While the phone is held, the phone stays live and the message
box stays open, so you can type a follow-up. After the hold, the page
reads “This chat has ended. Run again to start a new run.”
run.started and then run.completed, run.failed or
run.cancelled again, with turn in the payload. See
Webhook events.
Release the phone early
A held phone stays yours until the hold ends. A shared phone bills for that time. To release it sooner, end the run’s session. The run’ssession_id is
its run ID.
- CLI
- REST API
keep_alive_seconds: 0. On a
dedicated phone, a session you start on the phone, or another run pinned to
it, also ends the hold.
Cancel and the hold
Cancelling a running or paused agent-mode run stops it and then holds the phone forkeep_alive_seconds, as when a turn ends, so you can still follow up
with :sendMessage. A shared phone bills for that hold. Release the phone as
above, or set keep_alive_seconds: 0, if you don’t want it. A code run
releases its phone when cancelled. See
Cancel a run.
Next steps
Monitor runs
Stream a run’s steps and read its script.
Webhook events
Get run.paused, run.resumed and each turn’s events.