pub async fn dispatch_tools(
state: Arc<AgentToolState>,
calls: Vec<ToolCall>,
progress: ToolProgress,
) -> 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.
Every resolution - a pass-1 interaction answer or denial, a pass-2 execution -
is reported through progress the moment it lands, not at batch end, so the
run journal keeps each completed call’s result even if the daemon dies before
the batch finishes (issue #96).