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
success_rate_calc.py
Faster Time-to-Success
Return as soon as any agent succeeds:time_to_success.py
Strategies
First Success
Return immediately when any agent succeeds:first_success_strategy.py
- Non-deterministic pages
- Tasks prone to failures
- Time-sensitive operations
- You only need one successful result
All Finished
Wait for all agents to complete:all_finished_strategy.py
- Comparing agent outputs
- Gathering multiple perspectives
- Testing different approaches
- Statistical analysis
Configuration
Session Parameters
Batch agents create multiple sessions with the same configuration:session_params.py
Number of Jobs
Control parallelism withn_jobs:
n_jobs.py
n_jobs=5 costs 5x a single agent.
Agent Parameters
Pass any agent parameter:agent_params.py
Use Cases
1. Unreliable Pages
Pages with random failures:unreliable_pages.py
2. Rate-Limited Sites
Avoid rate limit failures:rate_limited_sites.py
3. A/B Testing
Test which model works best:ab_testing.py
4. Consensus Results
Get multiple agent opinions:consensus_results.py
Performance
Execution Time
Withfirst_success strategy:
execution_time.py
Cost
Batch agents cost more:cost.py
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:start_with_parallel.py
2. Use for Critical Tasks
Worth the cost for important operations:critical_tasks.py
3. Monitor Success Rates
Track if batch execution is needed:monitor_success_rates.py
4. Use Appropriate Strategy
Choose based on your needs:appropriate_strategy.py
5. Set Reasonable Timeouts
Prevent hanging:timeout.py
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:concurrency_limits.py
Cost Scaling
Costs multiply withn_jobs:
cost_scaling.py
Async Only
Batch agents require async execution:async_only.py

