Skip to main content

RunsApi

Struct RunsApi 

Source
pub struct RunsApi { /* private fields */ }
Expand description

Agent execution runs, SSE streaming, HITL, continuation

Implementations§

Source§

impl RunsApi

Source

pub async fn approve_run( &self, run_id: &str, body: &RunApproveRequest, ) -> Result<ApproveRunResponse>

Approve a pending tool call (HITL)

The body is optional; sending none approves without a message. reject has always taken a body, and the asymmetry was an omission rather than a design.

POST /api/v1/runs/{runId}/approve

Required scopes: runs:create.

Source

pub async fn cancel(&self, run_id: &str) -> Result<CancelRunResponse>

Cancel a run

POST /api/v1/runs/{runId}/cancel

Required scopes: runs:create.

Source

pub async fn continue_run( &self, run_id: &str, body: &ContinueRunRequest, ) -> Result<ContinueRunResponse>

Continue a run from a continuation token

Decodes the token, loads the checkpoint, and re-schedules the run.

POST /api/v1/runs/{runId}/continue

Required scopes: runs:create.

Source

pub async fn create(&self, body: &CreateRunRequest) -> Result<Run>

Create and schedule a run

Creates a run and schedules it for execution. Recommended: send Idempotency-Key header to avoid duplicate runs on retries; a repeated request with the same key returns the cached 202 response (same run_id). Pin a specific agent version with version to bypass the head pointer.

POST /api/v1/runs

Required scopes: runs:create.

Source

pub async fn create_run_checkpoint(&self, run_id: &str) -> Result<RunCheckpoint>

Create checkpoint for a run

POST /api/v1/runs/{runId}/checkpoint

Required scopes: runs:create.

Source

pub async fn estimate_run_cost( &self, body: &EstimateRunCostRequest, ) -> Result<RunCostEstimate>

What will this run cost

Prices a run before it happens, from the agent’s own recent runs. Read-only: it dispatches nothing and stores nothing, and it needs only runs:read.

When the model has no known rate the answer is still 200 with estimated_cost_usd: 0 and pricing: "unknown" — read basis.pricing before showing the figure, or a client will present “free” for “we have no idea”.

POST /api/v1/runs/estimate

Required scopes: runs:read.

Source

pub async fn export_run_events(&self, run_id: &str) -> Result<String>

Export run events as JSONL

GET /api/v1/runs/{runId}/events/export

Required scopes: runs:read.

Source

pub async fn get( &self, run_id: &str, params: &GetRunParams, ) -> Result<GetRunResponse>

Get run status and result

GET /api/v1/runs/{runId}

Required scopes: runs:read.

Source

pub async fn get_run_audit_log( &self, run_id: &str, ) -> Result<GetRunAuditLogResponse>

Get audit trail for a run

GET /api/v1/runs/{runId}/audit-log

Required scopes: runs:read.

Source

pub async fn get_run_feedback( &self, run_id: &str, params: &GetRunFeedbackParams, ) -> Result<Value>

Get user feedback for a run

GET /api/v1/runs/{runId}/feedback

Required scopes: runs:read.

Source

pub async fn get_run_queue_position( &self, run_id: &str, ) -> Result<GetRunQueuePositionResponse>

Get run queue position

GET /api/v1/runs/{runId}/queue-position

Required scopes: runs:read.

Source

pub async fn get_run_steps(&self, run_id: &str) -> Result<GetRunStepsResponse>

List steps for a run

Returns the ordered list of steps executed during a run, with per-step metrics including tokens, cost, and tool calls.

GET /api/v1/runs/{runId}/steps

Required scopes: runs:read.

Source

pub async fn list(&self, params: &ListRunsParams) -> Result<ListRunsResponse>

List all runs for tenant

Ordered NEWEST FIRST, and that is a guarantee, not an accident of storage: page one is the most recent runs. Do not page toward the end to find recent activity — a client that walks has_more looking for the newest page now walks away from it. This was previously true only of the handler, so clients hedged by paging or by re-sorting, and one shipped a twelve-hop walk that reversed meaning the day the order changed. Note the sibling /api/v1/teams/{teamId}/runs is deliberately the other way round — oldest first — because a team transcript reads forward.

GET /api/v1/runs

Required scopes: runs:read.

Source

pub fn list_all<'a>( &'a self, params: &'a ListRunsParams, ) -> impl Stream<Item = Result<Run>> + 'a

Stream every item returned by listRuns, following the cursor cursor until the server reports no further pages.

Source

pub async fn list_run_artifacts( &self, run_id: &str, ) -> Result<ListRunArtifactsResponse>

List run artifacts

GET /api/v1/runs/{runId}/artifacts

Required scopes: runs:read.

Source

pub async fn list_run_checkpoints( &self, run_id: &str, ) -> Result<ListRunCheckpointsResponse>

List checkpoints for a run

GET /api/v1/runs/{runId}/checkpoints

Required scopes: runs:read.

Source

pub async fn pause_run(&self, run_id: &str) -> Result<PauseRunResponse>

Pause a run

POST /api/v1/runs/{runId}/pause

Required scopes: runs:create.

Source

pub async fn reject_run( &self, run_id: &str, body: &RejectRunRequest, ) -> Result<RejectRunResponse>

Reject a pending tool call (HITL)

POST /api/v1/runs/{runId}/reject

Required scopes: runs:create.

Source

pub async fn replay_run(&self, run_id: &str) -> Result<Map<String, Value>>

Replay a run for determinism check

POST /api/v1/runs/{runId}/replay

Required scopes: runs:read.

Source

pub async fn respond_to_run( &self, run_id: &str, body: &RespondToRunRequest, ) -> Result<RespondToRunResponse>

Send user input response to a paused run

POST /api/v1/runs/{runId}/respond

Required scopes: runs:create.

Source

pub async fn resume(&self, run_id: &str) -> Result<ResumeRunResponse>

Resume a run

POST /api/v1/runs/{runId}/resume

Required scopes: runs:create.

Source

pub async fn set_run_feedback( &self, run_id: &str, body: &SetRunFeedbackRequest, ) -> Result<RunFeedbackSet>

Save user feedback/reaction for a run

One reaction per (message, caller); a second PUT for the same message_id replaces the first. message_id is whatever string the client attaches to a message — the platform stores it verbatim (max 256 chars) and does not check it against the transcript, which today carries no message identifier (see getSessionMessages). Unknown body fields are dropped. There is no way to remove a reaction: null and "" are rejected with 422 and DELETE is 405 (measured 2026-09-10).

PUT /api/v1/runs/{runId}/feedback

Required scopes: runs:create.

Source

pub fn stream_run_events( &self, run_id: &str, params: &StreamRunEventsParams, ) -> EventStream

Stream run events via SSE

Real-time event stream for a run. Supports Last-Event-ID header (or ?last_event_id=) for reconnection. Stream closes when run reaches terminal status. Each event payload includes stream_type: lifecycle (run.), assistant (llm.chunk), tool (tool.), or other — use it to filter client-side. Browsers using EventSource (which cannot set Authorization headers) should mint a 60-s SSE token via POST /api/v1/auth/sse-tokens and pass it as ?token=.

GET /api/v1/runs/{runId}/events

Required scopes: events:read.

Returns a server-sent event stream.

Source

pub async fn wait_run( &self, run_id: &str, params: &WaitRunParams, ) -> Result<Run>

Wait for run to reach terminal status

If the run is already completed, failed, cancelled, timeout, or guardrail_blocked, returns 200 with the run immediately. Otherwise polls until terminal status or timeout_sec. On timeout returns 202 with status still_running.

GET /api/v1/runs/{runId}/wait

Required scopes: runs:read.

Trait Implementations§

Source§

impl Clone for RunsApi

Source§

fn clone(&self) -> RunsApi

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for RunsApi

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more