← Back to Agentic AI map
Lesson 6.6 · CrewAI

Hierarchical Process

Instead of a fixed order, a manager agent decides who does what. We gave a manager a researcher and a writer. In the first run the workers never worked - the manager’s delegation failed and it wrote the answer itself. In the second run it delegated - to the wrong worker. Both results looked fine.

crewai

What you will be able to do

  • Build a hierarchical crew with manager_llm or a custom manager_agent
  • Explain how the manager hands out work (delegation tools)
  • Read the requests to see who really did the work
  • Know why a hierarchical crew can silently skip its workers
  • Choose between sequential, hierarchical and LangGraph

The idea, in plain English

In a sequential crew (Lesson 6.5) you decide the order. In a hierarchical crew, a manager agent decides. You give it the team and the tasks; it chooses which worker does what, checks the results, and may send more work.

The manager hands out work through two tools CrewAI gives it: delegate_work_to_coworker and ask_question_to_coworker. So the manager is an agent that uses tools - and with llama3, tools use the text format from Lesson 6.7.

We ran it twice and recorded every request to see who really worked. CrewAI 1.15.27, llama3 on Ollama.

Worked example: A manager with a Researcher and a Writer writes a beginner paragraph about LangGraph checkpoints from a source text - two runs, every request recorded.

workflowWho really did the work?step 1 / 3

1 - Run 1: manager_llm

The manager tried to delegate, but copied the tool’s schema into its input. Validation failed - and the manager wrote the answer itself. 3 requests, all by the manager.

worker requests
0
answer
36 words, the source copied
time
25.7 s

Two real runs. Requests recorded between CrewAI and Ollama.

Words you will see in this lesson

A few words about managed crews.

Small dictionary
Process.hierarchicalA manager agent decides which worker does each piece of work.
ManagerAn agent that plans, delegates and checks - it should not do the work itself.
manager_llmLet CrewAI create a standard manager that uses this model.
manager_agentYour own manager Agent, with your own role, goal and backstory.
DelegateHand a task to a coworker - here, with the tool delegate_work_to_coworker.
CoworkerCrewAI’s word for a worker agent in the crew.

An everyday example: a project manager

  • A project manager gets a job and a team. They decide who does what, then check the results. (A hierarchical crew.)
  • If the manager’s email to the team bounces, a busy manager may just do the job alone - and nobody notices. (Run 1.)
  • A manager may also give the whole job to one person, even when the plan said two. (Run 2.)
  • To know what really happened, you look at who actually worked - not only at the finished report.

Example 1 - a manager with two workers

What is different from a sequential crew:

  • The task has NO agent. The manager decides who does it.
  • process=Process.hierarchical.
  • manager_llm=new_llm(): CrewAI creates a standard "Crew Manager" agent that uses llama3.
  • The script takes the Ollama address as an argument, so we could record every request with the spy from Lesson 6.7.
manager.py
import sys, time from crewai import LLM, Agent, Crew, Process, Task base = sys.argv[1] if len(sys.argv) > 1 else "http://localhost:11434" def new_llm(): return LLM(model="ollama/llama3", base_url=base, temperature=0) SOURCE = """A checkpointer saves the graph state after every step. Each conversation or run has a thread_id; the saved state is stored under it. With the same thread_id, a run can continue later, even after a restart.""" researcher = Agent(role="Researcher", goal="Pick the facts a beginner needs from a source text", backstory="You only use the source text you are given. You write short bullet points.", llm=new_llm()) writer = Agent(role="Writer", goal="Turn facts into one clear paragraph for beginners", backstory="You write short, simple paragraphs for new developers. You never add facts.", llm=new_llm()) task = Task( description="Write one paragraph (at most 60 words) for beginners about LangGraph checkpoints, " "based only on this source:\n{source}", expected_output="One paragraph, at most 60 words, using only facts from the source.", ) # no agent: the manager decides who does it crew = Crew(agents=[researcher, writer], tasks=[task], process=Process.hierarchical, manager_llm=new_llm()) start = time.perf_counter() result = crew.kickoff(inputs={"source": SOURCE}) print("--- final:\n" + result.raw) print(f"--- {len(result.raw.split())} words, {time.perf_counter() - start:.1f} s")
Output - the result, and the recorded requests
--- final: A checkpointer saves the graph state after every step. Each conversation or run has a thread_id; the saved state is stored under it. With the same thread_id, a run can continue later, even after a restart. --- 36 words, 25.7 s requests: 3 [400, 200, 200] 1. [400] You are Crew Manager -> {"error":{"message":"registry.ollama.ai/library/llama3:latest does not support t 2. [200] You are Crew Manager -> ``` / Thought: I need to explain LangGraph checkpoints to beginners / Action: delegate_work_to_coworker / Action Input: { / "properties": { / "task": { / "description": "Explain LangGraph checkpoints to beginners", / 3. [200] You are Crew Manager -> Thought: I need to provide the final answer / Final Answer: A checkpointer saves the graph state after every step. Each conversation or run has a thread_id; the saved state is stored under it. With the same thread_id, a ru

Reading run 1: the workers never worked

The answer looks correct. But look at who sent the requests - all three are the Crew Manager:

  • Request 1: native tool calling, refused by llama3 (400) - the same fallback as Lesson 6.7.
  • Request 2: the manager called delegate_work_to_coworker, but copied the tool’s schema ("properties", "title", "type") into its input - the Lesson 4.4 mistake.
  • CrewAI answered with "Arguments validation failed: 3 validation errors", then told it: "If requirements are met, provide the Final Answer."
  • Request 3: the manager wrote the final answer itself - the source text, copied.
  • CrewAI’s standard manager prompt even says "you don’t perform tasks by yourself". It did anyway. Nothing in the result tells you.
What CrewAI sent back after the failed delegation (shortened)
Observation: I encountered an error while trying to use the tool. This was the error: Arguments validation failed: 3 validation errors for DelegateWorkToolSchema task Field required [type=missing, input_value={'properties': {'task': {...ionalProperties': False}, input_type=dict] context Field required ... coworker Field required ... Analyze the tool result. If requirements are met, provide the Final Answer. Otherwise, call the next tool. Deliver only the answer without meta-commentary.

Example 2 - your own manager

Instead of manager_llm, give the crew your own manager_agent. We wrote a backstory with an exact example of the input:

  • role, goal: "Get the task done by your team: first the Researcher, then the Writer".
  • backstory: "You never do the work yourself" - plus an example of the Action Input with plain text values.
  • allow_delegation=True: the manager may hand out work.
  • Crew(..., manager_agent=manager) instead of manager_llm.
The change in manager.py
manager = Agent( role="Team manager", goal="Get the task done by your team: first the Researcher, then the Writer", backstory=("You never do the work yourself. You delegate. To delegate, write the Action Input exactly like this " 'example, with plain text values: {"task": "List the key facts", "context": "the full source text", ' '"coworker": "Researcher"}'), llm=new_llm(), allow_delegation=True, ) crew = Crew(agents=[researcher, writer], tasks=[task], process=Process.hierarchical, manager_agent=manager)
Output - run 2
--- final: LangGraph checkpoints are saved graph states after every step. Each conversation or run has a unique thread_id, which allows the saved state to be stored under it. This means that if a run is interrupted and needs to be restarted, it can continue from where it left off as long as it has the same thread_id. --- 56 words, 21.8 s requests: 4 [400, 200, 200, 200] 1. [400] You are Team manager -> {"error":{"message":"registry.ollama.ai/library/llama3:lates 2. [200] You are Team manager -> ``` / Thought: I need to delegate the task to a coworker / Action: delegate_work_to_coworker / Action Input: {"task": "Write one paragraph (at most 60 words) for beginners about LangGraph checkpoints, based only on this source:", "context": "A checkpointer saves the 3. [200] You are Researcher -> Here's a paragraph for beginners about LangGraph checkpoints: / / LangGraph checkpoints are saved graph states after every step. Each conversation or run has a unique thread_id, which allows the saved state to be stored under it. This means that if a run is inter 4. [200] You are Team manager -> Thought: I now know the final answer / Final Answer: LangGraph checkpoints are saved graph states after every step. Each conversation or run has a unique thread_id, which allows the saved state to be stored under it. This means that if a run is interrupted and n

Reading run 2: it delegated - to the wrong worker

  • The example in the backstory worked: the Action Input had plain values, and delegation succeeded.
  • But the manager gave the WHOLE job - writing the paragraph - to the Researcher. Its goal said "first the Researcher, then the Writer". The Writer never worked.
  • The paragraph is good (56 words), so again the result hides what happened.
  • The manager removed the Researcher’s "Here’s a paragraph..." line in its final answer.

Watch out: A hierarchical crew can skip its workers or choose the wrong one, and still return a good-looking answer. Use verbose=True or a trace (Lesson 5.2) and check who did each piece of work.

Sequential, hierarchical or LangGraph?

On the same job, compare what we measured:

  • Use hierarchical when the work really needs to be planned during the run, and with a strong, tool-calling model as the manager.
  • With a small local model like llama3, prefer sequential - or route in code with LangGraph.
Three ways to run a team
Sequential (Lesson 6.5)11.7 s. You set the order; every agent worked. Predictable.
Hierarchical, manager_llm25.7 s. The manager did the job itself; no worker ran.
Hierarchical, manager_agent21.8 s. Delegated once, to the wrong worker.
LangGraph supervisor (Lesson 3.8)You write the routing rules in code; a wrong choice is impossible by design.

The recipe

  • 1. Tasks without an agent; process=Process.hierarchical.
  • 2. manager_llm for a standard manager, or manager_agent with allow_delegation=True for your own.
  • 3. In your manager’s backstory, show the exact input format with an example.
  • 4. Always check who did the work: verbose=True, a trace, or recorded requests.
  • 5. If the order is known in advance, use sequential instead.

Hierarchical crews at a glance

Standard manager

CrewAI makes it.

Crew(..., process=Process.hierarchical, manager_llm=llm)
Your own manager

Full control of the prompt.

Crew(..., process=Process.hierarchical, manager_agent=manager)
Manager settings

Must delegate.

Agent(..., allow_delegation=True)
Tasks

No agent.

Task(description="...", expected_output="...")
Manager tools

Given by CrewAI.

delegate_work_to_coworker, ask_question_to_coworker

Try it yourself

The code does not change. Swap the content string and the program does something else entirely.

Watch it

“Run Example 2 with verbose=True on the manager. Can you see which coworker got the task?”

Two tasks

“Split the job into two tasks (facts, then paragraph). Does the manager use both workers now?”

Count calls

“Compare the number of model calls with the sequential crew from Lesson 6.5.”

Stronger manager

“If you have a model with native tool calling, use it as manager_llm and compare.”

What usually goes wrong

Trusting the final answer

Both runs looked fine; in one, no worker ran. Check who did the work.

Giving tasks an agent

In a hierarchical crew the manager decides; leave agent out of the tasks.

A small model as manager

llama3 copied the tool schema and then did the work itself.

Hierarchical when the order is fixed

It was twice as slow as sequential and less predictable.

Key points

  • A hierarchical crew lets a manager agent decide who does each task, using delegation tools.
  • Run 1 (manager_llm): delegation failed on a copied schema, and the manager wrote the answer itself - no worker ran.
  • Run 2 (manager_agent with an example): delegation worked, but to the Researcher only; the Writer never ran.
  • Both answers looked good - always check who did the work.
  • Hierarchical took 21.8-25.7 s vs 11.7 s sequential; with a small model, prefer sequential or LangGraph routing.

Quick check before you move on

What two settings make a crew hierarchical?
process=Process.hierarchical, plus manager_llm or manager_agent.
How does the manager hand out work?
With the tool delegate_work_to_coworker (and ask_question_to_coworker).
Who sent all requests in run 1?
The Crew Manager - the workers never ran.
What fixed the delegation input in run 2?
An exact example of the Action Input in the manager’s backstory.

Quiz

  1. 1.

    Why did the manager in run 1 write the answer itself?

  2. 2.

    Run 2 delegated successfully. What was still wrong?

  3. 3.

    How did we find out who did the work?

  4. 4.

    When would you choose hierarchical?

Interview questions

What is the difference between sequential and hierarchical processes in CrewAI?

Sequential runs tasks in a fixed order with assigned agents. Hierarchical adds a manager agent that delegates tasks to coworkers via tools, validates results and can re-delegate - more flexible, but slower, costlier and dependent on the manager model’s judgement.

What can go wrong with an LLM manager?

Failed tool calls, the manager doing work itself, delegating to the wrong agent, or looping. Mitigate with a capable tool-calling model, explicit instructions, observability of delegations, and deterministic routing when the flow is known.

Comments

Sign in to leave a comment. Your name and photo come from Google; nothing else is shared.

Loading comments...