MCPcopy Index your code
hub / github.com/AI45Lab/Code / execute_parallel_write_batch

Method execute_parallel_write_batch

core/src/agent/parallel_tool_runtime.rs:11–83  ·  view source on GitHub ↗
(
        &self,
        tool_calls: &[ToolCall],
        state: &mut ExecutionLoopState,
        event_tx: &Option<mpsc::Sender<AgentEvent>>,
    )

Source from the content-addressed store, hash-verified

9
10impl AgentLoop {
11 pub(super) async fn execute_parallel_write_batch(
12 &self,
13 tool_calls: &[ToolCall],
14 state: &mut ExecutionLoopState,
15 event_tx: &Option<mpsc::Sender<AgentEvent>>,
16 ) {
17 tracing::info!(
18 count = tool_calls.len(),
19 "Parallel write batch: executing {} independent file writes concurrently",
20 tool_calls.len()
21 );
22
23 let tool_calls = tool_calls.to_vec();
24 let tool_context = self.tool_context.clone();
25 let tool_executor = Arc::clone(&self.tool_executor);
26 let results = crate::ordered_parallel::run_ordered_parallel_with_limit(
27 tool_calls.clone(),
28 self.config.max_parallel_tasks,
29 {
30 let tool_context = tool_context.clone();
31 let tool_executor = Arc::clone(&tool_executor);
32 move |_index, tc| {
33 let ctx = tool_context.clone();
34 let executor = Arc::clone(&tool_executor);
35 let name = tc.name.clone();
36 let args = tc.args.clone();
37 async move { executor.execute_with_context(&name, &args, &ctx).await }
38 }
39 },
40 )
41 .await;
42
43 for (tc, result) in tool_calls.iter().zip(results) {
44 state.record_tool_call();
45 let execution_result = match result.output {
46 Ok(result) => result,
47 Err(error) => Err(anyhow::anyhow!("parallel tool execution failed: {}", error)),
48 };
49 let normalized = NormalizedToolResult::from_execution(execution_result);
50 Self::collect_verification_report(
51 &mut state.verification_reports,
52 &normalized.metadata,
53 );
54 self.track_tool_result(&tc.name, &tc.args, normalized.exit_code);
55
56 let output = if let Some(ref sp) = self.config.security_provider {
57 sp.sanitize_output(&normalized.output)
58 } else {
59 normalized.output.clone()
60 };
61
62 if let Some(tx) = event_tx {
63 tx.send(AgentEvent::ToolEnd {
64 id: tc.id.clone(),
65 name: tc.name.clone(),
66 output: output.clone(),
67 exit_code: normalized.exit_code,
68 metadata: normalized.metadata.clone(),

Callers 1

execute_tool_turnMethod · 0.80

Calls 8

push_tool_result_messageFunction · 0.85
record_tool_callMethod · 0.80
track_tool_resultMethod · 0.80
cloneMethod · 0.45
execute_with_contextMethod · 0.45
sanitize_outputMethod · 0.45
sendMethod · 0.45

Tested by

no test coverage detected