Introduction
The hierarchical process in CrewAI introduces a structured approach to task management, simulating traditional organizational hierarchies for efficient task delegation and execution. This systematic workflow enhances project outcomes by ensuring tasks are handled with optimal efficiency and accuracy.Hierarchical Process Overview
By default, tasks in CrewAI are managed through a sequential process. However, adopting a hierarchical approach allows for a clear hierarchy in task management, where a ‘manager’ agent coordinates the workflow, delegates tasks, and validates outcomes for streamlined and effective execution. This manager agent can now be either automatically created by CrewAI or explicitly set by the user.Key Features
- Task Delegation: A manager agent allocates tasks among crew members based on their roles and capabilities.
- Result Validation: The manager evaluates outcomes to ensure they meet the required standards.
- Efficient Workflow: Emulates corporate structures, providing an organized approach to task management.
- System Prompt Handling: Optionally specify whether the system should use predefined prompts.
- Stop Words Control: Optionally specify whether stop words should be used, supporting various models including the o1 models.
- Context Window Respect: Prioritize important context by enabling respect of the context window, which is now the default behavior.
- Delegation Control: Delegation is now disabled by default to give users explicit control.
- Max Requests Per Minute: Configurable option to set the maximum number of requests per minute.
- Max Iterations: Limit the maximum number of iterations for obtaining a final answer.
Implementing the Hierarchical Process
To utilize the hierarchical process, it’s essential to explicitly set the process attribute toProcess.hierarchical, as the default behavior is Process.sequential.
Define a crew with a designated manager and establish a clear chain of command.
Code
Using a Custom Manager Agent
Alternatively, you can create a custom manager agent with specific attributes tailored to your project’s management needs. This gives you more control over the manager’s behavior and capabilities.Workflow in Action
- Task Assignment: The manager assigns tasks strategically, considering each agent’s capabilities and available tools.
- Execution and Review: Agents complete their tasks with the option for asynchronous execution and callback functions for streamlined workflows.
- Sequential Task Progression: Despite being a hierarchical process, tasks follow a logical order for smooth progression, facilitated by the manager’s oversight.
