Interface GraphState<TInput, TScratch, TArtifacts>

The mutable execution state threaded through every node of a graph run.

Generic parameters allow authors to provide precise types for their specific graph. All fields except scratch and artifacts are managed exclusively by the runtime.

interface GraphState<TInput, TScratch, TArtifacts> {
    input: Readonly<TInput>;
    scratch: TScratch;
    memory: MemoryView;
    artifacts: TArtifacts;
    diagnostics: DiagnosticsView;
    currentNodeId: string;
    visitedNodes: string[];
    iteration: number;
    checkpointId?: string;
}

Type Parameters

  • TInput = unknown

    Shape of the initial user-provided input.

  • TScratch = unknown

    Shape of intermediate computation results passed between nodes.

  • TArtifacts = unknown

    Shape of outputs produced for external consumption.

Properties

input: Readonly<TInput>

The original user-provided input; frozen after graph start.

scratch: TScratch

Node-to-node communication bag; merged via StateReducers after each node.

memory: MemoryView

Read-only memory snapshot populated before each node executes.

artifacts: TArtifacts

Accumulated outputs intended for the caller; merged via StateReducers after each node.

diagnostics: DiagnosticsView

Append-only telemetry record updated after each node completes.

currentNodeId: string

Id of the node currently executing (or most recently completed).

visitedNodes: string[]

Ordered list of node ids that have completed execution in this run.

iteration: number

Number of times the graph has looped back to a previously visited node.

checkpointId?: string

Id of the most recently persisted checkpoint snapshot, if any.