pub struct RunsApi { /* private fields */ }Expand description
Agent execution runs, SSE streaming, HITL, continuation
Implementations§
Source§impl RunsApi
impl RunsApi
Sourcepub async fn approve_run(
&self,
run_id: &str,
body: &RunApproveRequest,
) -> Result<ApproveRunResponse>
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.
Sourcepub async fn cancel(&self, run_id: &str) -> Result<CancelRunResponse>
pub async fn cancel(&self, run_id: &str) -> Result<CancelRunResponse>
Cancel a run
POST /api/v1/runs/{runId}/cancel
Required scopes: runs:create.
Sourcepub async fn continue_run(
&self,
run_id: &str,
body: &ContinueRunRequest,
) -> Result<ContinueRunResponse>
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.
Sourcepub async fn create(&self, body: &CreateRunRequest) -> Result<Run>
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.
Sourcepub async fn create_run_checkpoint(&self, run_id: &str) -> Result<RunCheckpoint>
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.
Sourcepub async fn estimate_run_cost(
&self,
body: &EstimateRunCostRequest,
) -> Result<RunCostEstimate>
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.
Sourcepub async fn export_run_events(&self, run_id: &str) -> Result<String>
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.
Sourcepub async fn get(
&self,
run_id: &str,
params: &GetRunParams,
) -> Result<GetRunResponse>
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.
Sourcepub async fn get_run_audit_log(
&self,
run_id: &str,
) -> Result<GetRunAuditLogResponse>
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.
Sourcepub async fn get_run_feedback(
&self,
run_id: &str,
params: &GetRunFeedbackParams,
) -> Result<Value>
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.
Sourcepub async fn get_run_queue_position(
&self,
run_id: &str,
) -> Result<GetRunQueuePositionResponse>
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.
Sourcepub async fn get_run_steps(&self, run_id: &str) -> Result<GetRunStepsResponse>
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.
Sourcepub async fn list(&self, params: &ListRunsParams) -> Result<ListRunsResponse>
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.
Sourcepub fn list_all<'a>(
&'a self,
params: &'a ListRunsParams,
) -> impl Stream<Item = Result<Run>> + 'a
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.
Sourcepub async fn list_run_artifacts(
&self,
run_id: &str,
) -> Result<ListRunArtifactsResponse>
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.
Sourcepub async fn list_run_checkpoints(
&self,
run_id: &str,
) -> Result<ListRunCheckpointsResponse>
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.
Sourcepub async fn pause_run(&self, run_id: &str) -> Result<PauseRunResponse>
pub async fn pause_run(&self, run_id: &str) -> Result<PauseRunResponse>
Pause a run
POST /api/v1/runs/{runId}/pause
Required scopes: runs:create.
Sourcepub async fn reject_run(
&self,
run_id: &str,
body: &RejectRunRequest,
) -> Result<RejectRunResponse>
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.
Sourcepub async fn replay_run(&self, run_id: &str) -> Result<Map<String, Value>>
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.
Sourcepub async fn respond_to_run(
&self,
run_id: &str,
body: &RespondToRunRequest,
) -> Result<RespondToRunResponse>
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.
Sourcepub async fn resume(&self, run_id: &str) -> Result<ResumeRunResponse>
pub async fn resume(&self, run_id: &str) -> Result<ResumeRunResponse>
Resume a run
POST /api/v1/runs/{runId}/resume
Required scopes: runs:create.
Sourcepub async fn set_run_feedback(
&self,
run_id: &str,
body: &SetRunFeedbackRequest,
) -> Result<RunFeedbackSet>
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.
Sourcepub fn stream_run_events(
&self,
run_id: &str,
params: &StreamRunEventsParams,
) -> EventStream
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.
Sourcepub async fn wait_run(
&self,
run_id: &str,
params: &WaitRunParams,
) -> Result<Run>
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.