Overview
Run multiple agents concurrently with different strategies:batch_agent.py
Why Use Batch Agents?
Improved Success Rate
Agents can fail due to:- Timing issues
- Random page behavior
- Rate limiting
- Network issues
Faster Time-to-Success
Return as soon as any agent succeeds:Strategies
First Success
Return immediately when any agent succeeds:- Non-deterministic pages
- Tasks prone to failures
- Time-sensitive operations
- You only need one successful result
All Finished
Wait for all agents to complete:- Comparing agent outputs
- Gathering multiple perspectives
- Testing different approaches
- Statistical analysis
Configuration
Session Parameters
Batch agents create multiple sessions with the same configuration:Number of Jobs
Control parallelism withn_jobs:
n_jobs=5 costs 5x a single agent.
Agent Parameters
Pass any agent parameter:Use Cases
1. Unreliable Pages
Pages with random failures:2. Rate-Limited Sites
Avoid rate limit failures:3. A/B Testing
Test which model works best:4. Consensus Results
Get multiple agent opinions:Performance
Execution Time
Withfirst_success strategy:
Cost
Batch agents cost more:Success Rate
Probability of at least one success:| Single Agent Success | 2 Parallel | 3 Parallel | 5 Parallel |
|---|---|---|---|
| 50% | 75% | 87.5% | 96.9% |
| 70% | 91% | 97.3% | 99.8% |
| 80% | 96% | 99.2% | 99.97% |
Best Practices
1. Start with 2-3 Parallel Agents
Balance cost and reliability:2. Use for Critical Tasks
Worth the cost for important operations:3. Monitor Success Rates
Track if batch execution is needed:4. Use Appropriate Strategy
Choose based on your needs:5. Set Reasonable Timeouts
Prevent hanging:Limitations
Resource Usage
Batch agents consume more resources:- Sessions: Creates n separate sessions
- Browsers: Opens n browser instances
- Memory: n times single agent memory
- API calls: n times single agent calls
Concurrency Limits
Account for rate limits:Cost Scaling
Costs multiply withn_jobs:

