Skip to main content

Workflow Steps

Workflows are built from four step types. Each step receives the current state and can update it for the next step.

Step Types Overview


AgentStep

Runs an agent. Use inputFrom to derive the agent’s input from state.
string
required
Step identifier. Used in stepResults and logs.
Agent
required
The agent to run.
(state) => string
Maps state to the agent’s input string. If omitted, the full state is JSON-stringified. Agent output is stored as state[stepName + “_output”].

Example


FunctionStep

Runs custom logic. Return a partial state object to merge into the workflow state.
string
required
Step identifier.
(state, ctx) => Promise<Partial<TState>>
required
Async function. Receives current state and RunContext. Return partial state to merge.

Example


ConditionStep

Branches based on a condition. Runs nested steps only when condition(state) is true.
string
required
Step identifier.
(state) => boolean
required
Predicate. If true, nested steps run; otherwise they are skipped.
StepDef<TState>[]
required
Nested steps to run when condition is true.

Example


ParallelStep

Runs multiple steps concurrently. Results are merged into state.
string
required
Step identifier.
StepDef<TState>[]
required
Steps to run in parallel. All must complete before the workflow continues.

Example


Full Example