Execute multiple tasks in parallel. Spawns all tasks concurrently and waits for all to complete. Returns results in the same order as the input tasks. Routed through the [`AgentExecutor`](crate::orchestration::AgentExecutor) seam so the same fan-out works whether steps run locally (default) or are placed on remote nodes by a host.
(
self: &Arc<Self>,
tasks: Vec<TaskParams>,
event_tx: Option<broadcast::Sender<AgentEvent>>,
parent_session_id: Option<&str>,
)
| 503 | /// same fan-out works whether steps run locally (default) or are placed |
| 504 | /// on remote nodes by a host. |
| 505 | pub async fn execute_parallel( |
| 506 | self: &Arc<Self>, |
| 507 | tasks: Vec<TaskParams>, |
| 508 | event_tx: Option<broadcast::Sender<AgentEvent>>, |
| 509 | parent_session_id: Option<&str>, |
| 510 | ) -> Vec<TaskResult> { |
| 511 | let parent = parent_session_id.map(|s| s.to_string()); |
| 512 | let specs = tasks |
| 513 | .into_iter() |
| 514 | .map(|params| AgentStepSpec { |
| 515 | task_id: format!("task-{}", uuid::Uuid::new_v4()), |
| 516 | agent: params.agent, |
| 517 | description: params.description, |
| 518 | prompt: params.prompt, |
| 519 | max_steps: params.max_steps, |
| 520 | parent_session_id: parent.clone(), |
| 521 | output_schema: None, |
| 522 | }) |
| 523 | .collect(); |
| 524 | |
| 525 | let executor: Arc<dyn AgentExecutor> = Arc::<Self>::clone(self); |
| 526 | crate::orchestration::execute_steps_parallel(executor, specs, event_tx) |
| 527 | .await |
| 528 | .into_iter() |
| 529 | .map(TaskResult::from) |
| 530 | .collect() |
| 531 | } |
| 532 | } |
| 533 | |
| 534 | impl From<TaskResult> for StepOutcome { |