Sequential Processes
A comprehensive guide to utilizing the sequential processes for task execution in CrewAI projects.
Introduction
CrewAI offers a flexible framework for executing tasks in a structured manner, supporting both sequential and hierarchical processes. This guide outlines how to effectively implement these processes to ensure efficient task execution and project completion.
Sequential Process Overview
The sequential process ensures tasks are executed one after the other, following a linear progression. This approach is ideal for projects requiring tasks to be completed in a specific order.
Key Features
- Linear Task Flow: Ensures orderly progression by handling tasks in a predetermined sequence.
- Simplicity: Best suited for projects with clear, step-by-step tasks.
- Easy Monitoring: Facilitates easy tracking of task completion and project progress.
Implementing the Sequential Process
To use the sequential process, assemble your crew and define tasks in the order they need to be executed.
Note:
Each task in a sequential process must have an agent assigned. Ensure that every Task
includes an agent
parameter.
Workflow in Action
- Initial Task: In a sequential process, the first agent completes their task and signals completion.
- Subsequent Tasks: Agents pick up their tasks based on the process type, with outcomes of preceding tasks or directives guiding their execution.
- Completion: The process concludes once the final task is executed, leading to project completion.
Advanced Features
Task Delegation
In sequential processes, if an agent has allow_delegation
set to True
, they can delegate tasks to other agents in the crew.
This feature is automatically set up when there are multiple agents in the crew.
Asynchronous Execution
Tasks can be executed asynchronously, allowing for parallel processing when appropriate.
To create an asynchronous task, set async_execution=True
when defining the task.
Memory and Caching
CrewAI supports both memory and caching features:
- Memory: Enable by setting
memory=True
when creating the Crew. This allows agents to retain information across tasks. - Caching: By default, caching is enabled. Set
cache=False
to disable it.
Callbacks
You can set callbacks at both the task and step level:
task_callback
: Executed after each task completion.step_callback
: Executed after each step in an agent’s execution.
Usage Metrics
CrewAI tracks token usage across all tasks and agents. You can access these metrics after execution.
Best Practices for Sequential Processes
- Order Matters: Arrange tasks in a logical sequence where each task builds upon the previous one.
- Clear Task Descriptions: Provide detailed descriptions for each task to guide the agents effectively.
- Appropriate Agent Selection: Match agents’ skills and roles to the requirements of each task.
- Use Context: Leverage the context from previous tasks to inform subsequent ones.
This updated documentation ensures that details accurately reflect the latest changes in the codebase and clearly describes how to leverage new features and configurations. The content is kept simple and direct to ensure easy understanding.
Was this page helpful?