Skip to main content

Overview

Workflows enable complex multi-agent pipelines where tasks flow between agents in sequence or parallel. Each workflow consists of steps that route tasks to specific agents.

Workflow Concepts

Workflow Structure

string
Unique workflow ID (UUID)
string
Human-readable workflow name
string
Description of what the workflow does
array
Array of workflow steps (see below)
string
ISO 8601 creation timestamp

Step Structure

string
Step name for logging/display
object
Agent reference (by ID or name)
string
Prompt template. Use {{input}} for previous output, {{var_name}} for variables.
enum
Execution mode:
  • sequential (default)
  • fan_out - Run in parallel with subsequent fan-out steps
  • collect - Collect results from all preceding fan-out steps
  • conditional - Skip if condition not met
  • loop - Repeat until condition or max iterations
integer
Step timeout in seconds (default: 120)
enum
Error handling:
  • fail (default) - Abort workflow on error
  • skip - Skip step and continue
  • retry - Retry up to N times
string
Optional variable name to store step output

Create Workflow

Register a new workflow definition:
POST /api/workflows

List Workflows

Get all registered workflows:
GET /api/workflows

Run Workflow

Execute a workflow with input:
POST /api/workflows/{id}/run

List Workflow Runs

Get execution history for a workflow:
GET /api/workflows/{id}/runs

Workflow Patterns

Sequential Pipeline

Steps execute one after another:

Fan-Out / Collect

Run multiple agents in parallel, then collect results:

Conditional Steps

Skip steps based on conditions:
The deploy step only runs if test_result contains “passed” (case-insensitive).

Loop Steps

Repeat a step until a condition is met:
The step repeats until:
  1. Output contains “no more improvements”, or
  2. max_iterations (5) is reached

Error Handling

Fail (Default)

Abort the workflow on any error:

Skip

Skip failed steps and continue:

Retry

Retry failed steps up to N times:

Variable Substitution

Use variables in prompt templates:
  • {{input}} - Previous step’s output
  • {{var_name}} - Named output variable from any step

Workflow State

Workflow runs progress through states:
  • pending - Queued but not started
  • running - Currently executing
  • completed - Successfully finished
  • failed - Encountered an error

Step Results

Each completed step stores:
string
Name of the step
string
UUID of the agent that executed the step
string
Name of the agent
string
Step output text
integer
Input tokens consumed
integer
Output tokens generated
integer
Step duration in milliseconds

Run Retention

The workflow engine retains up to 200 workflow runs. When this limit is exceeded, the oldest completed/failed runs are evicted automatically.

Best Practices

Timeouts

Set realistic timeouts for each step (default: 120s)

Error Handling

Use retry for transient failures, skip for optional steps

Fan-Out

Parallelize independent tasks with fan-out/collect

Variables

Store intermediate results in variables for reuse

Example: CI/CD Pipeline

Next Steps

Agents API

Learn how to spawn workflow agents

Memory API

Store workflow state in memory