Purpose: Linear and parallel execution chains for complex AI tasks.
Last Updated: 2026-01-09
Workflows in Mastra are directed graphs of steps that process data sequentially or in parallel. They provide a structured way to handle multi-stage LLM operations with built-in state management and human-in-the-loop (HITL) support.
createStep, requiring inputSchema, outputSchema, and an execute function..then() for sequential and .parallel() for concurrent execution.suspend execution to wait for human input and resume when data is provided.state and the inputData from the previous step.const workflow = createWorkflow({ id: 'my-workflow', inputSchema, outputSchema })
.then(step1)
.parallel([step2a, step2b])
.then(mergeStep)
.commit();
const { runId, start } = workflow.createRun();
const result = await start({ inputData: { ... } });
Reference: src/mastra/workflows/
Related: