Skip to main content
Hierarchical workflows add a manager agent that validates each step’s output before the next step runs, stopping gracefully with a clear reason if a step fails.
This page covers AgentFlow(process="hierarchical") — where a manager validates each step’s output before the next step runs. If you want a manager that delegates tasks to agents by name (the classic PraisonAIAgents(agents=[...], tasks=[...], process="hierarchical") flow), see Hierarchical Process.
Steps inside hierarchical mode inherit the same max_retries, guardrails, and output_file policies as top-level steps. See Nested workflows → Retry, guardrails, and output_file.
The user submits a multi-step brief; the manager validates each agent output before the workflow continues.

How It Works

Sequential (Default)

Steps run one after another without validation

Hierarchical

Manager validates each step before proceeding

Quick Start

1

Simple Usage

2

With Configuration

Define the same workflow in YAML with process: hierarchical and a manager_llm — see the YAML tab.

Parameters

string
default:"sequential"
Workflow execution mode:
  • sequential - Steps run without validation (default)
  • hierarchical - Manager validates each step
string
default:"null"
LLM model for the manager agent. If not specified, uses the workflow’s default_llm.

Manager Validation

The manager agent evaluates each step’s output based on:
1

Task Completion

Does the output address the task?
2

Quality Check

Is the output meaningful (not an error)?
3

Expected Output

Does it meet the step’s expected output criteria?

Handling Failures

Result Structure

When to Use

When each step must meet quality standards before proceeding.
When agents depend on validated output from previous agents.
When you need graceful failure handling with clear reasons.

Forcing Tool Usage

When agents have tools assigned, the LLM may skip calling them even with explicit instructions. Use tool_choice: required to force the LLM to call a tool before responding.
string
default:"auto"
Controls when the LLM calls tools:
  • auto - LLM decides whether to call tools (default)
  • required - LLM must call a tool before responding
  • none - LLM cannot call tools
Always use tool_choice: required for agents with tools in hierarchical workflows. This ensures the manager can validate that tools were actually used.

Comparison

Use hierarchical mode when you need guaranteed quality at each step. Use sequential mode for faster execution when validation isn’t critical.

Real-World Examples

Best Practices

The manager only validates output, so a smaller manager_llm like gpt-4o-mini keeps cost low without hurting quality.
Set tool_choice="required" so the manager can confirm tools actually ran before approving a step.
Inspect result["status"] and result["failure_reason"] before using the output — hierarchical workflows fail gracefully rather than raising.
Narrow, well-scoped steps make manager validation more reliable than broad, multi-goal steps.

AgentFlow

Deterministic multi-step pipelines

Conditional Execution

Branch workflows on runtime conditions

AgentTeam

Multi-agent task orchestration

Handoffs

Transfer control between agents