Function: executeOrderedToolCalls()
@providerprotocol/agents / index / executeOrderedToolCalls
Function: executeOrderedToolCalls()
Section titled “Function: executeOrderedToolCalls()”executeOrderedToolCalls(
toolCalls,tools,executor):Promise<ToolExecutionResult[]>
Defined in: src/execution/tool-ordering.ts:363
Executes tool calls respecting dependency ordering.
This is a high-level function that combines orderToolCalls with execution logic. It orders the tool calls, then executes them in groups while respecting barriers and dependencies.
Per UAP-1.0 Sections 8.5 and 8.6:
- Tools with
sequential: trueexecute alone (as barriers) - Tools with
dependsOnwait for named tools to complete - Tool calls with
afterwait for specific call IDs to complete
Parameters
Section titled “Parameters”toolCalls
Section titled “toolCalls”ToolCall[]
Tool calls from the model response
Tool<unknown, unknown>[]
Tool definitions with potential dependencies
executor
Section titled “executor”Function to execute a single tool call
Returns
Section titled “Returns”Promise<ToolExecutionResult[]>
Array of execution results in completion order
Example
Section titled “Example”import { executeOrderedToolCalls, ToolWithDependencies,} from '@providerprotocol/agents/execution';
// Define tools with dependenciesconst readTool: ToolWithDependencies = { name: 'read_file', description: 'Read a file', parameters: { type: 'object', properties: { path: { type: 'string' } } }, sequential: true, // Must complete before others run: async (params) => readFile(params.path as string),};
const processTool: ToolWithDependencies = { name: 'process', description: 'Process data', parameters: { type: 'object', properties: { data: { type: 'string' } } }, dependsOn: ['read_file'], // Wait for read_file run: async (params) => process(params.data as string),};
// Execute with automatic orderingconst results = await executeOrderedToolCalls( turn.response.toolCalls, [readTool, processTool], async (call, tool) => tool.run(call.arguments),);
// Check resultsfor (const result of results) { if (result.isError) { console.error(`${result.call.toolName} failed: ${result.error}`); } else { console.log(`${result.call.toolName} took ${result.duration}ms`); }}- orderToolCalls for just the ordering logic
- UAP-1.0 Spec Sections 8.5 and 8.6