Run
Inspect execution traces and results.
Run (Sync)
Proxy for inspecting a specific flow execution by ID. No network call is made at construction; methods are lazy.
Methods
trace(*, timeout=None) -> Trace
Fetch the complete execution trace with the latest attempt per step.
Parameters:
timeout(float, optional): Request timeout in seconds. Default:None
Returns: Trace with flow_run (RunSummary) and steps (list of StepTrace)
Raises:
FlowNotFoundError: Execution ID not foundAPITimeoutError: Request timed outAPIConnectionError: Network error
Example:
step_trace(step_id, *, attempt="latest", loop_index=None, timeout=None) -> StepTrace | StepAttempts
Fetch per-step trace, optionally across multiple attempts.
Parameters:
step_id(str): The step identifier to fetchattempt(str or int, optional):"latest"(default),"all", or attempt number N. Default:"latest"loop_index(int, optional): Loop iteration index for steps inside a loop. Default:Nonetimeout(float, optional): Request timeout in seconds. Default:None
Returns:
StepTracewhenattempt="latest"(default) orattempt=NStepAttemptswhenattempt="all"
Raises:
FlowNotFoundError: Execution or step not foundAPITimeoutError: Request timed out
Example:
live_trace() -> Generator[StreamEvent, None, None]
Stream live trace events, replaying from database then live-tailing until the run terminates.
Yields: StreamEvent union — typed events like RunStarted, StepStarted, StepCompleted, FlowCompleted, etc. (not full Trace snapshots)
Example:
AsyncRun
Async equivalent of Run. All methods are awaitable/async-iterable.
Methods
async trace(*, timeout=None) -> Trace
Async version of Run.trace().
Example:
async step_trace(step_id, *, attempt="latest", loop_index=None, timeout=None) -> StepTrace | StepAttempts
Async version of Run.step_trace().
Example:
async for event in live_trace()
Stream live events asynchronously.
Yields: StreamEvent objects
Example:
Trace (Type)
Complete execution trace with run summary and per-step details. Cost/duration totals are aggregated client-side from steps — the Trace object itself has no total_cost_usd or total_duration_ms field.
Attributes:
flow_run(RunSummary): Run-level metadatasteps(list[StepTrace]): List of step traces (latest attempt each)
Example:
RunSummary (Type)
High-level metadata about a flow execution.
Attributes:
id(str): Unique execution IDflow_id(str): Flow ID this execution ran againststatus(str): Execution status (e.g.,"completed","failed")trigger_type(str or None): How the flow was triggered (e.g.,"api","job")started_at(str or None): ISO timestamp when execution startedcompleted_at(str or None): ISO timestamp when execution completedduration_ms(int or None): Total execution time in millisecondsstep_count(int or None): Number of steps in the flow
StepTrace (Type)
Execution metrics for a single step (one attempt).
Attributes:
step_id— Unique step identifier (no separatenamefield onStepTrace)attempt— Attempt number (1 = first try, >1 if server retried this step)loop_index— Iteration index if the step is inside a loop (optional)status— One of:"running","completed","failed","skipped"started_at— ISO timestamp when the step started (optional)completed_at— ISO timestamp when the step completed (optional)duration_ms— Step execution time in milliseconds (optional)model_used— LLM model identifier if the step ran an LLM block (optional)tokens— Token usage object withprompt,completion,totalcounts (optional)cost_usd— Estimated cost as a decimal string (e.g.,"0.001234"); parse withfloat()(optional)input_context— Captured input snapshot (optional; only withtrace=Trueor for failed steps)output_context— Captured output snapshot (optional)error_context— Error details if the step failed (optional)input_size_bytes— Size of input snapshot (optional)output_size_bytes— Size of output snapshot (optional)truncated— Whether the snapshot was truncated due to size
Example:
TokenBreakdown (Type)
Token usage for a single LLM call. Flat three-field model — no cache fields at the SDK level (cache accounting is rolled into prompt server-side).
Attributes:
prompt(int): Input tokens sent to the modelcompletion(int): Output tokens returned by the modeltotal(int): Sum of prompt and completion
Example:
StepAttempts (Type)
Collection of all attempts for a single step (returned when attempt="all").
Attributes:
step_id(str): The step being inspectedattempts(list[StepTrace]): List ofStepTraceobjects, one per attempt, ordered by attempt number
Example: