Step Execution Modes

What you'll accomplish: Use Sequential, FanOut, Collect, Conditional, and Loop modes to build sophisticated multi-agent workflows.

Sequential (default)

Steps execute one after another. Each step receives the previous step's output as {{input}}.

{
  "name": "analysis",
  "agent": {"ByName": "analyst"},
  "prompt_template": "Analyze: {{input}}"
}

FanOut

Consecutive FanOut steps execute in parallel. All start with the same input (the last sequential step's output).

{
  "name": "review-legal",
  "mode": "FanOut",
  "agent": {"ByName": "legal-agent"},
  "prompt_template": "Review legal aspects: {{input}}"
}

If any FanOut step fails, the entire workflow fails (no partial completion).

Collect

Aggregates all preceding FanOut step outputs into a single input. Outputs are joined with \n\n---\n\n separators.

{
  "name": "aggregate",
  "mode": "Collect",
  "agent": {"ByName": "summary-agent"},
  "prompt_template": "Synthesize these reviews: {{input}}"
}

Conditional

A step that only executes if the previous step's output contains a specific string (case-insensitive):

{
  "name": "escalation",
  "mode": {"Conditional": {"condition": "needs_review"}},
  "agent": {"ByName": "supervisor"},
  "prompt_template": "Review this escalation: {{input}}"
}

If the condition is not met, the step is skipped and execution continues.

Loop

Repeats a step until the output contains a termination string or max iterations are reached:

{
  "name": "refine",
  "mode": {"Loop": {"max_iterations": 5, "until": "DONE"}},
  "agent": {"ByName": "editor"},
  "prompt_template": "Refine this draft: {{input}}"
}

Each iteration's output becomes the next iteration's input. The loop exits when:

  • The output contains the until string (case-insensitive), OR
  • max_iterations is reached

Combining modes

A typical workflow might combine all modes:

{
  "steps": [
    {"name": "extract", "agent": {"ByName": "extractor"}, "prompt_template": "Extract from: {{input}}", "output_var": "data"},
    {"name": "legal-review", "mode": "FanOut", "agent": {"ByName": "legal"}, "prompt_template": "Legal review: {{data}}"},
    {"name": "compliance-review", "mode": "FanOut", "agent": {"ByName": "compliance"}, "prompt_template": "Compliance review: {{data}}"},
    {"name": "synthesize", "mode": "Collect", "agent": {"ByName": "synthesizer"}, "prompt_template": "Combine reviews: {{input}}"},
    {"name": "escalate", "mode": {"Conditional": {"condition": "high_risk"}}, "agent": {"ByName": "supervisor"}, "prompt_template": "Escalate: {{input}}"},
    {"name": "finalize", "mode": {"Loop": {"max_iterations": 3, "until": "APPROVED"}}, "agent": {"ByName": "finalizer"}, "prompt_template": "Finalize: {{input}}"}
  ]
}

Next steps


Related: