executeToolsParallel method

Future<List<ToolResult>> executeToolsParallel(
  1. List<ToolCall> toolCalls, {
  2. ParallelToolConfig? config,
})

Execute multiple tools in parallel and return results

toolCalls - List of tool calls to execute config - Optional parallel execution configuration

Returns a list of tool results

Implementation

Future<List<ToolResult>> executeToolsParallel(
  List<ToolCall> toolCalls, {
  ParallelToolConfig? config,
}) async {
  // Default implementation executes sequentially
  final results = <ToolResult>[];
  final effectiveConfig = config ?? const ParallelToolConfig();

  for (final toolCall in toolCalls) {
    try {
      final result = await executeTool(toolCall);
      results.add(result);
    } catch (e) {
      results.add(ToolResult.error(
        toolCallId: toolCall.id,
        errorMessage: 'Tool execution failed: $e',
      ));
      if (!effectiveConfig.continueOnError) break;
    }
  }
  return results;
}