invokeAgentTool method

Future<({bool isError, DVJsonValue value})> invokeAgentTool(
  1. DVAIToolDefinition tool,
  2. DVJsonObject input
)

Runs one registered tool, converting a thrown handler error into a value the model can read and recover from.

Implementation

Future<({DVJsonValue value, bool isError})> invokeAgentTool(
  DVAIToolDefinition tool,
  DVJsonObject input,
) async {
  try {
    return (value: await tool.handler(input), isError: false);
  } on Object catch (error) {
    return (value: DVJsonString('$error'), isError: true);
  }
}