IAgentTool

Interfaces · AiDotNet.Agentic.Tools

An executable tool the model can call: a name, a description, a JSON-schema for its arguments, and an asynchronous invocation entry point.

Known implementations: AgentToolBase, GuardedAgentTool, MiddlewareAgentTool

For Beginners

Think of this as one gadget in the assistant’s toolbox. It knows its own name, what it does, and what inputs it expects (the schema). When the model says “use this gadget with these inputs”, InvokeAsync is the code that runs.

How It Works

This is the runnable counterpart to AiToolDefinition. The definition is what the model is told about; an IAgentTool is what actually runs when the model requests a call. The orchestration loop matches a model-emitted ToolCallContent to a tool by Name, passes the parsed arguments to InvokeAsync, and feeds the ToolInvocationResult back as a tool message.

Properties

Property Summary
JObject ParametersSchema { get; } Gets the JSON Schema object describing this tool’s parameters.
string Description { get; } Gets the natural-language description that helps the model decide when to call the tool.
string Name { get; } Gets the unique name the model references when requesting this tool.

Methods

Method Summary
AiToolDefinition ToDefinition() Produces the provider-facing AiToolDefinition for this tool.
Task<ToolInvocationResult> InvokeAsync(JObject arguments, CancellationToken cancellationToken) Executes the tool with the supplied arguments.