Documentation Index
Fetch the complete documentation index at: https://docs.swarms.world/llms.txt
Use this file to discover all available pages before exploring further.
Overview
TheBatchedGridWorkflow is a multi-agent orchestration pattern that executes tasks in a batched grid format, where each agent processes a different task simultaneously. This workflow is particularly useful for parallel processing scenarios where you have multiple agents and multiple tasks that can be distributed across them.
The BatchedGridWorkflow provides a structured approach to:
- Execute multiple tasks across multiple agents in parallel
- Manage conversation state across execution loops
- Handle error scenarios gracefully
- Control the number of execution iterations
Architecture
Installation
Key Features
| Feature | Description |
|---|---|
| Parallel Execution | Multiple agents work on different tasks simultaneously |
| Conversation Management | Maintains conversation state across execution loops |
| Error Handling | Comprehensive error logging and exception handling |
| Configurable Loops | Control the number of execution iterations |
| Agent Flexibility | Supports any agent type that implements the AgentType interface |
Attributes
Unique identifier for the workflow.
Name of the workflow.
Description of what the workflow does.
List of agents to execute tasks.
Arguments for the conversation.
Maximum number of execution loops to run (must be >= 1).
Methods
step()
Execute one step of the batched grid workflow.tasks(List[str]): List of tasks to execute
run()
Run the batched grid workflow with the given tasks. This is the main entry point that includes error handling.tasks(List[str]): List of tasks to execute
str - The final conversation string after all loops
run_()
Internal method that runs the workflow without error handling.tasks(List[str]): List of tasks to execute
str - The final conversation string after all loops
Usage Examples
Basic Usage
Multi-Loop Execution
Error Handling
The workflow includes comprehensive error handling:- Validation: Ensures
max_loopsis a positive integer - Execution Errors: Catches and logs exceptions during execution
- Detailed Logging: Provides detailed error information including traceback
Best Practices
| Best Practice | Description |
|---|---|
| Agent Selection | Choose agents with complementary capabilities for diverse task processing |
| Task Distribution | Ensure tasks are well-distributed and can be processed independently |
| Loop Configuration | Use multiple loops when iterative refinement is needed |
| Error Monitoring | Monitor logs for execution errors and adjust agent configurations accordingly |
| Resource Management | Consider computational resources when setting up multiple agents |
Use Cases
| Use Case | Description |
|---|---|
| Content Generation | Multiple writers working on different topics |
| Data Analysis | Different analysts processing various datasets |
| Research Tasks | Multiple researchers investigating different aspects of a problem |
| Parallel Processing | Any scenario requiring simultaneous task execution across multiple agents |