Mastra Workflows

Orchestrate complex, multi-step processes

Mastra workflows let you define complex sequences of tasks using clear, structured steps rather than relying on the reasoning of a single agent. When a process needs to be repeatable, predictable and auditable, Mastra gives you full control over how tasks break down, how data moves between them and what gets executed when.

Precisely define your execution graph

When a single agent cannot reliably handle a multi-step process, Mastra workflows give you full control over execution. Define steps with input and output schemas, compose them into sequential, parallel, branching or looping execution graphs and handle errors at every stage. Mastra Studio visualizes the execution graph and runs it step by step.

Sequential

step.then(
  nextStep
)
sequential docs

Parallel

step.parallel([
 a,b            
])
parallel docs

Branch

step.branch([
  [cond1, step1],
  [cond2, step2]
])
branch docs

Loops

step.doWhile(cond)
loops docs

Compose with agentic primitives

Mastra workflows integrate directly with agents, tools, memory and MCP so every step can call the right primitive for the job. Nest workflows inside other workflows to reuse logic across processes. Persist state across steps so long-running workflows survive suspension and resumption.

Python trains,
TypeScript ships.