Skip to main content
A graph goes through two phases: compilation validates the structure and prepares it for execution, and execution runs the compiled graph against an Input.

Invoke vs. compile-and-execute

Invoke does both in one call — convenient for one-off runs:
For a graph you run repeatedly, compile once and reuse the *Compiled — validation and preparation happen a single time:
Both Invoke and Execute accept the same options.

The Input

Input is the run object you pass in and get back. The fields you care about going in:
RunContext is the seed state every node reads from and merges into. The same *Input is returned, populated with results.

Options

Pass InvokeOptions to Invoke or Execute:

The runtime

The default InProcessRuntime runs the graph in-process, dispatching each wave of ready nodes to its own goroutine. Within a wave, dispatch order is sorted so that deterministic runtimes replay identically. The first node to fail cancels its in-flight siblings via a shared context and the run returns that error. Runtime is an interface, so a host can supply its own executor (for example, a durable runtime that records each node as an activity) via WithRuntime:

Inspecting results

The returned *Input carries the full picture of the run — it is returned even on error, so you can inspect partial state.
Status records one marker per node: out.Ports records the output port each completed node emitted, which the engine uses to follow edges (and to replay completed nodes on resume).

Compilation and validation

Compile returns a single joined error describing everything wrong with the graph — missing nodes, dangling edges, reserved-id clashes, conditional/static conflicts, and cycles:
Builder-time mistakes (an empty node id, a duplicate AddNode, a nil router) are also collected and surfaced here, so a single Compile check catches both structural and wiring problems.