Skip to main content

Agent Workflows

AgentFlow is now the primary class name (v1.5.5+). Workflow and Pipeline are silent aliases. See AgentFlow for the latest documentation.
Workflows let you orchestrate multiple Agents in complex pipelines. Chain Agents sequentially, run them in parallel, or route to different Agents based on conditions.

Quick Start

1

Simple Usage

2

With Configuration

See the sections below for advanced options.

Sequential Agent Pipeline

Parallel Agent Execution

Run multiple Agents simultaneously:

Agent Router Workflow

Route to different Agents based on conditions:

Agent Loop (Iterative Refinement)

Have an Agent iterate until satisfied:

Multi-Agent Workflow with Context

Share context between Agents in a workflow:

Conditional Agent Steps

Skip Agents based on conditions:

Agent Workflow with Error Handling

Handle Agent failures gracefully:

Workflow Patterns

Control-Flow Patterns

The control-flow patterns from the Python SDK (when, if_, include, Route, Parallel) are real classes in TypeScript. Import the friendly helpers top-level from praisonai — never from a deep dist/ path — and drop them straight into an AgentFlow step list.
when(condition, thenSteps, elseSteps?) is the preferred spelling; if_ and ifStep are aliases that build the same If step. Conditions are strings evaluated against the flow variables — numeric comparisons ({{score}} > 80), string equality ({{status}} == approved), in/contains membership, and truthy checks ({{flag}}). An unparseable condition fails safe to false.
include(recipe?, workflow?, input?) runs another recipe (resolved via setRecipeResolver) or a nested workflow inline. Either recipe or workflow must be provided. The optional input supports {{var}}, {{previous_output}} and {{input}} substitution.
new Parallel(steps, maxWorkers?, onFailure?) accepts 'partial_ok' (default — failed branches contribute null), 'fail_fast' (throw on first failure), or 'fail_all' (wait, then throw if any failed). Patterns may nest up to MAX_NESTING_DEPTH (5); deeper nesting raises NestingDepthError.
YAMLWorkflowParser (and the parseYAMLWorkflow / loadWorkflowFromFile helpers) build a workflow from a YAML definition, including handoff shapes, so you can keep pipelines in config rather than code.

Workflow Patterns

Multi-Agent

Multi-Agent

Guardrails

Guardrails