Skip to main content
The pkg/workflow package is a code-first engine for orchestrating multi-step logic as a directed acyclic graph (DAG). You define nodes, wire them together with edges, and the engine runs them: independent branches execute in parallel, conditional edges route at runtime, and a node can suspend the whole run for an external decision and resume later exactly where it left off. Unlike durable agents, a workflow is deterministic — you control every node and every transition — which makes it a good fit for pipelines, approval flows, fan-out/fan-in processing, and any orchestration you want to be replayable and inspectable.

Core concepts

START and END are reserved, implicit node ids (workflow.StartNode / workflow.EndNode) that bookend a graph. You never register them — you just wire edges to and from them.

Quickstart

A minimal one-node workflow that reads a name from the run context and writes a greeting:
Invoke compiles the graph and runs it in one call. For graphs you run repeatedly, compile once and reuse the *Compiled.

Where to go next

  • Defining Nodes — implement the Node interface, read and write state, and use typed inputs/outputs.
  • Edges & Branching — static edges, parallel fan-out/fan-in, and conditional routing.
  • Running Workflows — compilation, runtimes, options, and inspecting results.
  • Pausing & Resuming — suspend a run for an external decision and resume it durably.