Hierarchical process and delegation

CrewAI · Advanced · 12 min

Some problems can't be split into a fixed task order in advance; a manager can adapt the plan at run time.

In the hierarchical process a manager agent runs the crew. Tasks are not tied to agents in advance. The manager reads each task, picks the best agent based on their roles and goals, delegates the work, reviews the result and decides whether it is complete.

You must give the crew a manager in one of two ways:

  • manager_llm="openai/gpt-4o": CrewAI creates a generic manager agent using that model.
  • manager_agent=my_manager: your own Agent with a role, goal and backstory written for managing. Don't list it in agents.
crew = Crew(agents=[researcher, writer], tasks=[report],
            process=Process.hierarchical, manager_llm="openai/gpt-4o")

Delegation also exists outside this process: an agent with allow_delegation=True gets built-in tools to ask a coworker a question or hand over part of a task.

Costs and risks:

  • Every delegation and review is extra model calls, so runs are slower and more expensive.
  • Behaviour is less predictable: the manager may pick an unexpected agent or loop on reviews.
  • Debugging is harder, because the path is decided at run time.

Use it when the work really needs dynamic planning, such as open research where the next step depends on findings. Give agents clearly different roles so the manager can choose well, and use a strong model for the manager. For known orders of work, the sequential process or a flow is better.

planning=True on a crew is a lighter option: a planning step writes a step-by-step plan that is added to each task before execution.

Example

from crewai import Agent, Crew, Process, Task

researcher = Agent(role="Researcher", goal="Find facts with sources",
                   backstory="You only report what you can verify.")
analyst = Agent(role="Data analyst", goal="Compute and compare numbers",
                backstory="You show your calculations.")
writer = Agent(role="Writer", goal="Write clear executive summaries",
               backstory="You write for busy managers.")
manager = Agent(role="Project manager",
                goal="Deliver an accurate report by delegating to the right specialist",
                backstory="You split work, check quality and send work back when needed.",
                allow_delegation=True)

report = Task(description="Compare the EV market share of 3 European countries in 2025.",
              expected_output="A 200-word summary with a small table and sources.")

crew = Crew(agents=[researcher, analyst, writer], tasks=[report],
            process=Process.hierarchical, manager_agent=manager)
print(crew.kickoff().raw)

Remember

  • Hierarchical crews need manager_llm or manager_agent
  • The manager assigns tasks, delegates and reviews results
  • More flexible but slower, costlier and harder to debug than sequential

Watch out for

  • Adding the manager agent to the agents list as well, which makes it a worker that can be delegated to.

Check yourself

  1. What is required to run a crew with process=Process.hierarchical?

Sign in to answer, see the explanations, and get this lesson back as a quick review later.

Official docs: docs.crewai.com/en/learn/hierarchical-process