execute method

  1. @override
Future<ToolResult> execute(
  1. ToolCall call,
  2. ToolContext context
)
override

Runs call. A model's mistake is a ToolFailure; an exception follows AssistantConfig.toolErrors. The call must start synchronously (before the first await): the assistant reads ToolContext.annotations in the same step.

Implementation

@override
Future<ToolResult> execute(ToolCall call, ToolContext context) async {
  calls.add(call);
  sources.add(context.source);
  annotations.add(context.annotations);
  final result = inner.execute(call, context)..ignore();
  if (call.name == gatedTool) await gate?.future;
  return result;
}