mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +00:00
- Move Task Execution Flow section from tasks.mdx to processes.mdx - Rename Sequential to Static/Assigned for clarity - Rename Hierarchical to Dynamic/Unassigned - Add backward compatibility notes for enum values - Clarify that tasks are always executed in order Co-Authored-By: Joe Moura <joao@crewai.com>
77 lines
4.5 KiB
Plaintext
77 lines
4.5 KiB
Plaintext
---
|
|
title: Processes
|
|
description: Detailed guide on workflow management through processes in CrewAI, with updated implementation details.
|
|
icon: bars-staggered
|
|
---
|
|
|
|
## Understanding Processes
|
|
<Tip>
|
|
Processes orchestrate the execution of tasks by agents, akin to project management in human teams.
|
|
These processes ensure tasks are distributed and executed efficiently, in alignment with a predefined strategy.
|
|
</Tip>
|
|
|
|
## Process Types
|
|
|
|
CrewAI supports two process types that determine how tasks are assigned to agents:
|
|
|
|
- **Static/Assigned Process** (formerly "Sequential"): In this process, each task must be pre-assigned to a specific agent. While the name "Sequential" was previously used, it's important to note that tasks are always executed in the order they are defined, regardless of the process type chosen. The key characteristic of this process is that it requires explicit agent assignments for each task.
|
|
|
|
- **Dynamic/Unassigned Process** (formerly "Hierarchical"): In this process, you do not have to assign agents to tasks explicitly. Instead, the crew will assess available agents and automatically select the most suitable one for each task based on their roles and expertise. This requires specifying either a manager language model (`manager_llm`) or a custom manager agent (`manager_agent`) to handle the agent selection and task delegation.
|
|
|
|
- **Consensual Process** (Planned): Aiming for collaborative decision-making among agents on task execution, this process type introduces a democratic approach to task management within CrewAI. It is planned for future development and is not currently implemented in the codebase.
|
|
|
|
## The Role of Processes in Teamwork
|
|
Processes enable individual agents to operate as a cohesive unit, streamlining their efforts to achieve common objectives with efficiency and coherence.
|
|
|
|
## Assigning Processes to a Crew
|
|
To assign a process to a crew, specify the process type upon crew creation to set the execution strategy. For a hierarchical process, ensure to define `manager_llm` or `manager_agent` for the manager agent.
|
|
|
|
```python
|
|
from crewai import Crew
|
|
from crewai.process import Process
|
|
from langchain_openai import ChatOpenAI
|
|
|
|
# Example: Creating a crew with a Static/Assigned process
|
|
# Each task must have an agent pre-assigned
|
|
crew = Crew(
|
|
agents=my_agents,
|
|
tasks=my_tasks,
|
|
process=Process.sequential # Note: The enum value remains 'sequential' for backward compatibility
|
|
)
|
|
|
|
# Example: Creating a crew with a Dynamic/Unassigned process
|
|
# Tasks will be automatically assigned to suitable agents
|
|
crew = Crew(
|
|
agents=my_agents,
|
|
tasks=my_tasks,
|
|
process=Process.hierarchical, # Note: The enum value remains 'hierarchical' for backward compatibility
|
|
manager_llm=ChatOpenAI(model="gpt-4")
|
|
# or
|
|
# manager_agent=my_manager_agent
|
|
)
|
|
```
|
|
**Note:** Ensure `my_agents` and `my_tasks` are defined prior to creating a `Crew` object, and for the hierarchical process, either `manager_llm` or `manager_agent` is also required.
|
|
|
|
## Static/Assigned Process
|
|
|
|
This process type requires explicit agent assignments for each task. Tasks are executed in their defined order, with the output of one task serving as context for the next. This approach provides direct control over which agent handles each specific task.
|
|
|
|
To customize task context, utilize the `context` parameter in the `Task` class to specify outputs that should be used as context for subsequent tasks.
|
|
|
|
## Dynamic/Unassigned Process
|
|
|
|
This process type enables automatic agent selection through a manager component. You must specify either a custom manager agent or a manager language model (`manager_llm`). The manager oversees task execution by:
|
|
- Analyzing task requirements
|
|
- Selecting the most suitable agent based on roles and expertise
|
|
- Delegating tasks automatically
|
|
- Reviewing outputs and assessing task completion
|
|
|
|
## Process Class: Detailed Overview
|
|
|
|
The `Process` class is implemented as an enumeration (`Enum`), ensuring type safety and restricting process values to the defined types (`sequential`, `hierarchical`). The consensual process is planned for future inclusion, emphasizing our commitment to continuous development and innovation.
|
|
|
|
## Conclusion
|
|
|
|
The structured collaboration facilitated by processes within CrewAI is crucial for enabling systematic teamwork among agents.
|
|
This documentation has been updated to reflect the latest features, enhancements, and the planned integration of the Consensual Process, ensuring users have access to the most current and comprehensive information.
|