pub fn execute_agents_parallel(
items: &[Value],
parent_branch: &str,
max_parallel: usize,
) -> impl Effect<Output = Vec<AgentExecutionResult>, Error = Vec<MapReduceError>, Env = MapEnv>Expand description
Execute multiple agents in parallel with bounded concurrency
This is the KEY function demonstrating Effect::par_all_limit for parallel execution. It takes a list of work items and executes them in parallel with a maximum concurrency limit (respecting max_parallel from config).
§Benefits over manual tokio::spawn coordination:
- Automatic error collection and handling
- Respects concurrency limits
- Type-safe
- Composable with other effects
- Testable with mock environments
§Example
ⓘ
let items = vec![json!({"id": 1}), json!({"id": 2}), json!({"id": 3})];
let effect = execute_agents_parallel(&items, "main", 2);
let results = effect.run_async(&env).await?;
// Executes agents with max 2 concurrent at a time