AgentFlow(model="gpt-4o") is now accepted (canonical) as the default model for steps that did not name one. llm= still works as a deprecated alias — see Model Parameter.Quick Start
1
Sequential pipeline
2
Parallel research
3
Conditional routing
How It Works
Each step receives the previous step’s output as context. Context passing is automatic — no extra code required.Which Pattern to Use?
Pattern Helpers
parallel() and max_workers
max_workers caps concurrent steps in parallel() and loop(parallel=True).
Workflow Hooks
WorkflowHooksConfig options:
Planning & Reasoning
planning=True to enable it, or a dict to tune the planner:
Advanced: WorkflowPlanningConfig class
Advanced: WorkflowPlanningConfig class
Prefer the
bool or dict form above. Use WorkflowPlanningConfig when you want typed, IDE-friendly configuration.Memory Integration
memory=True for the default file backend, or a dict to pick a backend:
Advanced: WorkflowMemoryConfig class
Advanced: WorkflowMemoryConfig class
Prefer the
bool or dict form above. Use WorkflowMemoryConfig when you want typed, IDE-friendly configuration.Guardrails & Validation
Output Modes
Async Execution
Status Tracking
Variable Substitution
Everyaction string processes placeholders in this order:
For YAML workflows loaded via
YAMLWorkflowParser, the top-level input: field is stored as workflow.default_input and used automatically when start() / run() is called with no argument. See Workflow Input Resolution for the full precedence ladder.{{today}}, {{now}}, and {{uuid}} are provided by the separate Dynamic Variables mechanism, not the workflow template engine.WorkflowManager
WorkflowManager discovers and executes markdown-defined workflows from .praisonai/workflows/.
AgentFlow is the primary workflow surface. WorkflowManager is a secondary API for running markdown-defined workflows.Checkpoints
Save progress withcheckpoint= (saved after each step), continue an
interrupted run with resume=, and — only when a real edit happened —
override a fingerprint mismatch with rebase_checkpoint=True.
rebase_checkpoint=True to continue at the same step index against the
edited workflow (a warning is logged naming both fingerprints):
For a full walkthrough — CLI flags, the
workflow checkpoints command, the
checkpoint-file schema, and a decision diagram — see
Workflow Checkpoint & Resume.Async
aexecute() accepts the same checkpoint, resume, and rebase_checkpoint parameters (and returns the same resumed_from_step field) and supports loop_over and branch_condition routing with full parity to execute().
Loop Steps: Error Handling & Checkpoints
Aloop_over step runs its step once per item. Two behaviors apply on both execute() and aexecute():
- Stop-on-error aborts the workflow. When a
loop_overstep fails on any iteration and itson_error="stop"(theTaskdefault), the entire workflow aborts — not just the loop.result["success"]becomesFalseand no later steps run. - Completed loop steps checkpoint once. With
checkpoint=set, aloop_overstep persists a checkpoint after the whole loop completes (matching single-step behavior). Onresume=, the loop is not re-run — execution continues from the next step.
Error Handling Across Patterns
As of PraisonAI #4194, the same failure rules now apply inside every nested pattern (loop, parallel, when/if_, route, repeat), not just loop_over:
on_error="stop"(theTaskdefault) inside any nested pattern halts the whole workflow — the stop signal propagates out of the pattern to the top level.on_error="continue"keeps the workflow running, but the finalresult["status"]is"failed"if any step failed.- Downstream steps never receive the exception text as input; the error is recorded on the step, not folded into its output.
parallel(on_failure=...) modes.
Workflow File Format
Markdown files with YAML frontmatter define multi-step workflows forWorkflowManager:
Best Practices
Use specialized agents per step
Use specialized agents per step
Give each step a distinct agent with a focused role — Researcher, Analyst, Writer. Agents with clear instructions outperform generalist ones.
Set max_workers for parallel steps
Set max_workers for parallel steps
LLM-backed parallel steps hit rate limits fast. Start with
max_workers=3 and increase only after testing.Name your steps for debugging
Name your steps for debugging
Use
Task(name="...") for every step. Named steps appear in workflow.step_statuses and execution history.Guardrails over hope
Guardrails over hope
Add
guardrails= to steps that produce structured output (reports, JSON, code). Short feedback loops via max_retries cost less than prompt engineering.Prefer when() over complex routing
Prefer when() over complex routing
Use
when(condition="{{score}} > 80", ...) for simple thresholds. Reserve route() for multi-branch decisions.Keep steps atomic
Keep steps atomic
One step → one responsibility. Easier to debug, retry, and replace.
Related
YAML Workflows
Define complex workflows in YAML files
Nested Workflows
Combine loops, parallel, and routing patterns
Hybrid Workflows
Mix deterministic shell steps with agent steps
Job Workflows
Ordered pipelines of shell commands and agent steps

