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 Task Definition Hierarchical

From Leeroopedia

Overview

A task specification pattern where tasks are defined without mandatory agent assignment, allowing a manager agent to dynamically route them to the most appropriate specialist at runtime.

Description

In hierarchical mode, tasks intentionally omit the agent field (or set it to None). The manager agent receives each task and decides which specialist to delegate it to based on the task's requirements and the specialists' roles. This enables dynamic routing where the manager can assess which agent is best suited, potentially splitting complex tasks or re-delegating on failure.

This stands in contrast to sequential crew task definition, where each task is typically pre-assigned to a specific agent at definition time. In hierarchical mode, the decoupling of tasks from agents is a deliberate design choice that enables several powerful capabilities:

Dynamic Routing

The manager evaluates each task's description and expected output, then matches it against the available specialists' roles and capabilities. This means the same set of tasks could be routed differently depending on which specialists are available in the crew.

Task Decomposition

When the manager receives a complex task, it can choose to delegate different aspects to different specialists. For example, a task requiring "research and write a report" might be split into a research delegation followed by a writing delegation, even though it was defined as a single task.

Adaptive Re-delegation

If a specialist's output is unsatisfactory, the manager can re-delegate the task to the same specialist with additional context, or to a different specialist entirely. This creates a feedback loop that is not possible with static agent assignment.

Information Gathering

Before delegating, the manager can use AskQuestionTool to query specialists for information, helping it make better delegation decisions. For instance, the manager might ask a research specialist what sources are available before deciding whether to delegate a full research task.

Theoretical Basis

This principle is based on Late Binding and Dynamic Dispatch from programming language theory. In static dispatch, the target function is determined at compile time. In dynamic dispatch, it is resolved at runtime based on the actual type or context.

Applied to multi-agent systems:

  • Static binding (sequential mode) -- The developer assigns tasks to agents at definition time. The mapping is fixed.
  • Late binding (hierarchical mode) -- The agent-task mapping is resolved at runtime by the manager, based on the task's requirements and available specialists.

Late binding provides greater flexibility at the cost of less predictability. The manager's LLM reasoning determines the routing, which may vary across runs. This trade-off is acceptable when:

  • The optimal agent for a task is not obvious at design time.
  • Tasks may benefit from multi-agent collaboration that cannot be predetermined.
  • The system needs to adapt to variable specialist availability or capabilities.

Constraints

  • Task descriptions must be clear and detailed -- Since the manager uses the task description to decide routing, vague descriptions lead to poor delegation decisions.
  • Expected output should be explicit -- This helps the manager evaluate whether a specialist's response adequately addresses the task.
  • Context dependencies still apply -- If task B depends on the output of task A, the tasks should be ordered accordingly in the task list, even though the manager controls execution. The context field can link tasks to establish data flow.
  • No guaranteed agent assignment -- The developer cannot guarantee which specialist will handle a given task. If deterministic routing is needed, sequential mode is more appropriate.

Related Principles

  • Specialist Agent Definition -- The agents that receive dynamically-routed tasks.
  • Manager Agent Configuration -- The coordinating agent that performs the dynamic routing.
  • Hierarchical Crew Assembly -- The crew-level composition that combines unassigned tasks with manager and specialists.

Implementation:CrewAIInc_CrewAI_Task_Constructor_For_Hierarchical

Page Connections

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