Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Principle:CrewAIInc CrewAI Hierarchical Crew Assembly

From Leeroopedia

Overview

A crew composition pattern that organizes agents into a manager-worker hierarchy with centralized task coordination and tool-based delegation.

Description

Hierarchical Crew Assembly creates a crew where a manager agent coordinates all task execution through delegation tools. Unlike sequential assembly where task order determines execution, hierarchical assembly lets the manager decide execution order and agent assignment. The assembly requires either a manager_agent or manager_llm to be specified, and validates this requirement at initialization time.

The hierarchical crew is composed of three distinct elements:

Specialist Agents

The agents list contains only the specialist worker agents. These agents are the pool of available workers that the manager can delegate to. Each specialist is identified by its role name and carries domain-specific tools and expertise. The agents list does not include the manager -- the manager is specified separately.

Manager Agent

The manager is configured either implicitly (via manager_llm) or explicitly (via manager_agent). It sits above the specialists in the hierarchy and is responsible for all task coordination. The manager is automatically equipped with delegation tools and cannot be disabled from delegating.

Unassigned Tasks

The tasks list contains tasks without mandatory agent assignment. In hierarchical mode, tasks flow through the manager, which routes them to specialists. The order of tasks in the list suggests a natural sequence, but the manager has discretion over actual execution order.

Assembly Validation

At initialization time, the Crew validates that:

  • The process is set to Process.hierarchical.
  • Either manager_agent or manager_llm is provided (but not required to be both).
  • If neither is provided, a validation error is raised immediately, preventing runtime failures.

This validation ensures that a hierarchical crew is always properly configured before any execution begins.

Theoretical Basis

This principle draws from Hierarchical Task Network (HTN) planning in artificial intelligence. In HTN planning:

  • A high-level planner receives abstract tasks and decomposes them into subtasks.
  • Primitive executors carry out the decomposed subtasks.
  • The planner decides the decomposition strategy based on the current state and available methods.

In the hierarchical crew:

  • The manager agent acts as the high-level planner, receiving tasks and deciding how to decompose and delegate them.
  • The specialist agents act as primitive executors, carrying out the delegated work.
  • The delegation tools (DelegateWorkTool, AskQuestionTool) are the methods the planner uses to interact with executors.

This structure enables emergent planning behavior -- the manager can dynamically adjust its strategy based on intermediate results, which is not possible in a fixed sequential pipeline.

Constraints

  • One manager per crew -- The hierarchy has a single coordinating authority. Multiple managers would create conflicting delegation decisions.
  • Manager must be provided -- Either manager_agent or manager_llm is required. The framework raises a validation error if neither is specified.
  • Specialists in agents list only -- The manager is not included in the agents list. The agents list represents the available worker pool.
  • Process must be hierarchical -- The process=Process.hierarchical flag activates hierarchical execution. Without it, even if a manager is configured, the crew runs sequentially.
  • Less predictable than sequential -- Because the manager uses LLM reasoning for delegation, the exact execution path may vary between runs. This is a trade-off for greater flexibility.

Related Principles

  • Specialist Agent Definition -- How individual specialist agents are configured.
  • Manager Agent Configuration -- How the coordinating manager is configured.
  • Task Definition Hierarchical -- How tasks are specified without agent assignment.
  • Managed Execution -- The runtime behavior of the assembled crew.

Implementation:CrewAIInc_CrewAI_Crew_Hierarchical_Constructor

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment