MCPcopy Create free account
hub / github.com/AI45Lab/Code / execute_parallel

Method execute_parallel

core/src/tools/task.rs:505–531  ·  view source on GitHub ↗

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>,
    )

Source from the content-addressed store, hash-verified

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
534impl From<TaskResult> for StepOutcome {

Calls 2

execute_steps_parallelFunction · 0.85
cloneMethod · 0.45