.then(action); the workflow records the result so a retry can skip work that already succeeded. This is the most common way to compose actions, since an action can never call another action directly.
Use an action as a step
Chain the action ontodefineWorkflow() with .then(). Each step receives the previous step’s output as its input (the first step gets the workflow input). The input is validated against the action’s input schema, and the result is validated against its output. Use .map() to reshape data between steps, and finish with .commit().
src/workflows/signup-pipeline.ts
.then() rejects an action whose input does not accept the previous output, and .commit() is a type error when the last step’s output does not match the workflow’s output. Branches, loops, and parallel steps use .branch(), .foreach(), .dowhile()/.dountil(), and .parallel(); see build workflows.
The step id defaults to the action’s slug. To use the same action twice in one workflow, give the second use its own id with .as():
Durability
As each step completes, its result is saved with the run. If a later step fails and the run is retried, it resumes from the failed step: completed steps are not run again. Two practical consequences:- Put side effects inside steps. Keep network calls and writes inside actions (or other steps) so their results are recorded and not repeated.
.map()is for pure reshaping, not side effects. - Make steps idempotent where you can. A step can be retried after a transient failure, so design actions to tolerate being called more than once with the same input.
Scope credentials per step
When a step’s action declarescredentials that could resolve at more than one scope, pin the scope with .scope():
step:<id>), so for .scope("user"), assign a user credential to that step — user scope is not inferred from the run.
Actions, agents, and LLM steps
A workflow can mix deterministic action steps with agent steps (agentStep(agent, { prompt })) and one-shot LLM steps (llmStep(id, { prompt })). A common shape is to run actions to gather data, prompt an agent to make a decision or draft text, then run more actions to act on the result.
Next steps
Build workflows
Steps, durability, durable waits, and the run context.
Actions as agent tools
Attach the same actions to an agent as tools.
Test workflows
Run a workflow and assert its output.
Workflow runs
Inspect each step’s input, output, and errors.