Skip to main content
The user authors YAML once; PraisonAI loads steps, routing, and parallel blocks at runtime. Define complex multi-agent workflows in YAML files with support for advanced patterns like routing, parallel execution, loops, and more.

Minimum Required Fields

The absolute minimum to run a workflow:
Practical minimum (recommended):
input vs topic: Use input (canonical) for clarity. topic still works for backward compatibility but input better conveys that this is the data going INTO your workflow.
Action templating — every action string supports three placeholders, processed in order:
  1. {{your_variable}} — replaced with values from variables: or earlier output_variable fields.
  2. {{previous_output}} — replaced in place or auto-appended as "Context from previous step: …" if the token is absent and a previous output exists.
  3. {{input}} — replaced with the top-level input: value, available in every step.
For the full substitution order, auto-append rules, and examples, see How Action Templating Works.

Workflow Input Resolution

The value that fills {{input}} is resolved with this precedence, highest first.
Before PraisonAI PR #2890 the CLI unconditionally called workflow.start(""), which silently dropped the YAML input: field and left every {{input}} step empty. The CLI now honors the YAML default and shows a preview of the resolved input on start-up.

CLI input examples

Programmatic input examples

Field Names Reference (A-I-G-S)

PraisonAI accepts both old (agents.yaml) and new (workflow.yaml) field names. Use the canonical names for new projects: A-I-G-S Mnemonic - Easy to remember:
  • Agents - Who does the work
  • Instructions - How they behave
  • Goal - What they achieve
  • Steps - What they do
The parser accepts both old and new names. Run praisonai workflow validate <file.yaml> to see suggestions for canonical names.

Feature Parity

Both agents.yaml and workflow.yaml now support the same features:
Task names must be unique across agents (roles). With the CrewAI framework, two agents defining a task with the same name (e.g. both agents.alice.tasks.write_report and agents.bob.tasks.write_report) raise:
Rename one of the tasks (e.g. write_report_bob). Before PraisonAI #2471 the duplicate silently overwrote the earlier task and context=[...] lookups resolved to the wrong task — the new error catches this fast.

Quick Start

1

Run and validate a workflow

Programmatic Routing: The AgentsGenerator wrapper auto-detects workflow YAML and routes to the appropriate engine:This means calling AgentsGenerator(agent_file="release.yaml").generate_crew_and_kickoff() with a job/hybrid YAML now routes correctly to the workflow runner instead of falling through to the framework adapter.
Async parity (extended in PR #2738): agenerate_crew_and_kickoff() now initializes observability and adapter setup the same way generate_crew_and_kickoff() does — Langfuse / AgentOps traces are wired on both paths. Both paths also share a single _build_yaml_workflow builder, so config validation, merge, and dump logic live in exactly one place — sync and async behavior is guaranteed identical.
Workflow YAML framework: is validated. Workflow dispatch requires an adapter whose SUPPORTS_WORKFLOW = True (the built-in praisonai adapter has it). Declaring a framework without that flag (e.g. framework: crewai) raises ValueError:
For non-praisonai execution, use an agents.yaml-style file via AgentsGenerator. See Workflow YAML Framework Field for details.

Complete workflow.yaml Reference

Agent Fields Reference

Step Fields Reference

Models Fields Reference

Context Management (Token Overflow Prevention)

For tool-heavy workflows (search, crawl, etc.): Always enable context: true to prevent token overflow errors.
Enable automatic context optimization to prevent “context length exceeded” errors:

What Context Management Does

When context: true is enabled:
  1. Auto-compaction: Automatically compresses history when approaching token limits
  2. Tool Output Truncation: Limits large tool results (e.g., full web page content)
  3. Smart Strategy: Prioritizes recent/important messages, prunes tool outputs first
  4. Overflow Prevention: Prevents “context_length_exceeded” errors

Best Practices

Without context: true: Tool outputs (especially search with full page content) can easily exceed 128K tokens, causing API errors.

Context Strategies

For more details, see Context Management.

Workflow Patterns

Sequential (Default)

Agents execute one after another, passing context.

Parallel

Multiple agents work concurrently.

Routing

Classifier routes to specialized agents.

Loop

Iterate over a list of items.

Multi-Step Loop

Execute multiple steps sequentially for each item in the loop. This is perfect for pipelines where each item needs to go through several processing stages (e.g., research → write → publish).
Context Isolation: Each loop iteration is isolated - context doesn’t leak between iterations. Within an iteration, {{previous_output}} chains between steps.

Multi-Step Loop Features

Within vs Between Iterations:
  • Within iteration: Steps run sequentially (step1 → step2 → step3)
  • Between iterations: Can run in parallel with parallel: true

Structured Output

Get structured JSON responses from agents using output_json (inline schema) or output_pydantic (reference to Pydantic model in tools.py).
How it works: When output_json or output_pydantic is specified, PraisonAI automatically uses the LLM’s native structured output feature (response_format) for supported models.Supported Models: GPT-4o, GPT-4o-mini, Claude 3.5 Sonnet, Gemini 2.0 FlashFlow:
  1. Agent checks if model supports native structured output
  2. If supported → uses response_format with JSON schema (clean output)
  3. If not supported → falls back to prompt injection (schema in prompt)
Force Native Mode: In Python, use native_structured_output=True on the Agent to force native mode:

Repeat (Evaluator-Optimizer)

Repeat until a condition is met.

Include (Modular Recipes)

Include reusable recipe files in your workflow.
Variable Passing: When you include a recipe, the parent’s topic, variables, and other fields are automatically passed to the child recipe. The child can use {{topic}} in its actions.

Variables

Define reusable variables for use throughout your workflow.
Topic Propagation: The topic: field at the root of your YAML is automatically added to the variables dict. This means:
  • Use topic: for the main subject
  • Use variables: for additional reusable values
  • Both are available as {{topic}} and {{variable_name}} in actions
Variable Substitution Examples:

Extended agents.yaml

Use workflow patterns in agents.yaml with process: workflow:
Run with:

Auto-Generate Workflows

Generate workflows automatically from a topic description:

CLI Commands

CLI Options

Progress Indicators

When running workflows, you’ll see clear progress indicators:
When no input is resolved (no YAML input:, no --var input, no argument), the CLI prints a warning instead of the preview line:

Debug Mode

Enable debug logging to see detailed execution:
This shows:
  • Agent parameters (prompt, temperature, tools)
  • Messages sent to LLM
  • HTTP requests to API
  • Full agent/role/goal context

Best Practices

Run workflows locally with LOGLEVEL=debug to catch missing agents or tools early.
Reference env vars in YAML instead of hard-coding API keys in workflow files.
Split large YAML files into modular recipes rather than one monolithic definition.
Treat YAML workflows like code — review changes and test in CI before production.

Workflow Patterns

Sequential, parallel, routing, and loop patterns

Variable Substitution

Template variables in workflow actions