Understand the Agent Run lifecycle
Await
.
created
state. This initial state indicates that the run request has been accepted but processing hasn’t begun yet. As soon as an agent picks up the work, it immediately transitions to the in-progress
state.
The run can then result in a several outcomes:
completed
state with its final output.
failed
state with error details.
run/{run_id}/cancel
endpoint, which transitions the run to the cancelling
state. Once the agent confirms the cancellation, the run moves to the terminal cancelled
state. This two-step process ensures graceful termination of agent execution.
awaiting
state to request additional information or actions from the client.
in-progress
and continues execution.awaiting
state for too long without receiving a response, it will transition to the failed
state with a timeout error.created
- The run has been initiated but not yet started processingin-progress
- The agent is actively processing the requestawaiting
- The agent has paused execution and is waiting for additional inputcompleted
- The agent has successfully finished processingcancelling
- A cancellation request has been received and is being processedcancelled
- The run has been successfully cancelledfailed
- The run encountered an error and cannot continueMethod | Endpoint | Description |
---|---|---|
POST | /runs | Initiates a new agent run. Requires agent_name , input . Optional: session_id , mode (sync , async , stream ). Returns the initial Run object or stream. |
GET | /runs/{run_id} | Retrieves the current state and details of a specific agent run. |
POST | /runs/{run_id} | Resumes an agent run in the awaiting state. Requires await_resume data. Optional: mode for the response. |
POST | /runs/{run_id}/cancel | Requests cancellation of an ongoing agent run. Returns 202 Accepted if cancellation is initiated. |
run_sync
method executes an agent and waits for the complete response:
POST
request to /runs
responds with a run_id
, which can then be queried via /runs/{run_id}
to obtain the current state of the run. It is the client’s responsibility to poll for the terminal state and the result of the run.
run_stream
method delivers incremental updates as the agent processes: