pub async fn dispatch_tools(
state: Arc<AgentToolState>,
calls: Vec<ToolCall>,
) -> Vec<(String, String)>Expand description
Resolve policy, handle approvals / dynamic interactions, and execute a batch
of tool calls, returning (tool_call_id, result) pairs in call order.
Two passes so tool calls within one batch run in parallel where it is safe:
- Sequential resolution - dynamic interactions (
ask_user_*), sub-agent tools, andaskapproval prompts are inherently interactive and are resolved one at a time, in order (a user answers one prompt at a time, and aSession-scope approval must be visible to later calls in the batch). Each call ends up either fully resolved or queued for execution. - Parallel execution - every queued call runs concurrently (
join_all), then results are stitched back into the original call order.