Agent.Run when you want a final result without live token deltas. It returns an AgentRun handle immediately; the work continues in the background until you wait with Get or Done.
AgentRun methods
Wait for the result
CallGet right after Run — it waits until the agent finishes:
Non-blocking Run
Wait onDone() (or multiplex with other work), poll Status, optionally Cancel, then Get:
Get context only unblocks the waiter — use AgentRun.Cancel to cancel the agent run itself.
Full example with approvals: Non-blocking Run.
Reconnect with GetAgentRun
On a durable runtime (Temporal or Restate), persistagentRun.ID() before waiting. After a process crash, reconnect and wait again — the run keeps executing server-side:
GetAgentRun or Get context does not cancel the durable run — use AgentRun.Cancel for that. After reconnect, WithTimeout (if set) starts fresh — it is not the remaining time from the original Run. Full cancel/timeout rules: Timeouts & Modes.
LocalRuntime cannot reconnect after a crash (ErrRunNotFound). Full protocol: Durable Execution.
Approvals on Run
UseWithApprovalHandler for interactive tool approval during Run (same as a blocking Run + Get). Stream-based approval uses CUSTOM events on AgentStream — see Approvals.
Examples
Simple Agent
Blocking Run + Get
Non-blocking Run
Status, Cancel, Done, Get, and approvals
Streaming
AgentStream, Events, and live tokens