call method

Future<Object?> call(
  1. String tool,
  2. Map<String, Object?> arguments, {
  3. bool approved = false,
})

Calls the method behind tool with the agent's JSON arguments and returns its result as JSON.

The agent list is read again first, because an earlier call of the same run may have changed it. An argument of a class is a {"path": ...} to a value of this listing, and the method gets the value at that path now. Throws a ToolCallRefused for a tool that is not listed now, that needs approval when approved is false, for arguments of the wrong type or with a key the schema does not have, and for a path whose value changed since this listing was read. The method runs in none of these cases.

Implementation

Future<Object?> call(
  String tool,
  Map<String, Object?> arguments, {
  bool approved = false,
}) async =>
    (await run(tool, WrittenArguments(arguments), approved: approved)).result;