Workflows
Workflows orchestrate multi-step pipelines with shared state. Define steps (agents, functions, conditions, parallel execution), pass state between them, and handle retries and errors—all in a declarative, state-machine style.Stateful Step-Based Execution
Shared State
Each step reads from and writes to a typed
TState object passed through the workflow.Step Types
AgentStep, FunctionStep, ConditionStep, ParallelStep.
Retry & Error Handling
Configurable retry policy and step result status (done, error, skipped).
Event-Driven
Optional EventBus for workflow lifecycle events.
WorkflowConfig
Display name for the workflow.
Initial state object. Steps read from and merge updates into this state.
Ordered array of steps. See Workflow Steps.
Storage for workflow persistence (e.g., resuming, audit).
{ maxRetries, backoffMs } for failed steps. See Retry & Error Handling.Custom event bus for workflow events.
State Machine Concept
Workflows behave like state machines:- Initial state —
initialStateis the starting point. - Steps — Each step receives the current state and can return a partial update.
- State merge — Updates are merged into the state before the next step.
- Result —
WorkflowResultcontains final state andstepResults.
Basic Example
WorkflowResult
Final state after all steps (including any updates from steps).
Per-step results:
stepName, status (done | error | skipped), error?, durationMs.