Run
Inspect execution traces and results.
Run
Proxy for inspecting a specific flow execution by ID. No network call is made at construction; methods are lazy.
Methods
async trace(opts?: { timeout?: number; signal?: AbortSignal }) -> Trace
Fetch the complete execution trace with the latest attempt per step.
Parameters:
timeout(number, optional): Request timeout in milliseconds. Default:undefinedsignal(AbortSignal, optional): Abort signal for cancellation. Default:undefined
Returns: Trace with flowRun (RunSummary) and steps (array of StepTrace)
Throws:
FlowNotFoundError: Execution ID not foundAPITimeoutError: Request timed outAPIConnectionError: Network error
Example:
async stepTrace(stepId, opts?: StepTraceOptions) -> StepTrace | StepAttempts
Fetch per-step trace, optionally across multiple attempts.
Parameters:
stepId(string): The step identifier to fetchattempt(string or number, optional):"latest"(default),"all", or attempt number N. Default:"latest"loopIndex(number, optional): Loop iteration index for steps inside a loop. Default:undefinedtimeout(number, optional): Request timeout in milliseconds. Default:undefinedsignal(AbortSignal, optional): Abort signal for cancellation. Default:undefined
Returns:
StepTracewhenattempt="latest"(default) orattempt=NStepAttemptswhenattempt="all"
Throws:
FlowNotFoundError: Execution or step not foundAPITimeoutError: Request timed out
Example:
liveTrace() -> AsyncIterable<StreamEvent>
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:
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 totalCostUsd or totalDurationMs field.
Attributes:
flowRun(RunSummary): Run-level metadatasteps(StepTrace[]): Array of step traces (latest attempt each)
Example:
RunSummary (Type)
High-level metadata about a flow execution.
Attributes:
id(string): Unique execution IDflowId(string): Flow ID this execution ran againststatus(string): Execution status (e.g.,"completed","failed")triggerType(string | undefined): How the flow was triggered (e.g.,"api","job")startedAt(string | undefined): ISO timestamp when execution startedcompletedAt(string | undefined): ISO timestamp when execution completeddurationMs(number | undefined): Total execution time in millisecondsstepCount(number | undefined): Number of steps in the flow
StepTrace (Type)
Execution metrics for a single step (one attempt).
Attributes:
stepId— Unique step identifier (no separatenamefield onStepTrace)attempt— Attempt number (1 = first try, >1 if server retried this step)loopIndex— Iteration index if the step is inside a loop (optional)status— One of:"running","completed","failed","skipped"startedAt— ISO timestamp when the step started (optional)completedAt— ISO timestamp when the step completed (optional)durationMs— Step execution time in milliseconds (optional)modelUsed— LLM model identifier if the step ran an LLM block (optional)tokens— Token usage object withprompt,completion,totalcounts (optional)costUsd— Estimated cost as a decimal string (e.g.,"0.001234"); parse withparseFloat()(optional)inputContext— Captured input snapshot (optional; only withtrace=trueor for failed steps)outputContext— Captured output snapshot (optional)errorContext— Error details if the step failed (optional)inputSizeBytes— Size of input snapshot (optional)outputSizeBytes— 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(number): Input tokens sent to the modelcompletion(number): Output tokens returned by the modeltotal(number): Sum of prompt and completion
Example:
StepAttempts (Type)
Collection of all attempts for a single step (returned when attempt="all").
Attributes:
stepId(string): The step being inspectedattempts(StepTrace[]): Array ofStepTraceobjects, one per attempt, ordered by attempt number
Example: