The Tool class defines a tool that can be attached to an Agent.
import { Tool } from '@ardent-ai/sdk';

const reverse = new Tool({
  name: 'reverse',
  description: 'Reverse a string of text',
  parameters: {
    text: z.string()
  },
  result: z.string(),
  async execute({ text }) {
    return text.split('').reverse().join('');
  }
});

Constructor

The Tool constructor accepts a configuration object with the following properties:
name
string
required
The name of the tool. Must be alphanumeric.
description
string
required
A plain-text description of what the tool does. This should be as expressive as possible, to help explain to your agent what the tool can be used for.
parameters
{string: ZodSchema}
An optional hash of parameters, each of which should be a Zod schema describing the parameter’s type. Your agent will use these schemas to determine the right format in which to pass arguments to the tool. If you omit this, your tool will receive no arguments.
result
ZodSchema
An optional Zod schema describing the type of the value returned by the tool’s execute() function. If you omit this, your tool can return a value of any type.
execute
({string: any}, Context) -> any
The function which will be called when your agent decides to use the tool. The function receives two arguments:
  • A hash of arguments matching the shape specified in parameters.
  • A Context which provides access to platform functionality.
This function should return a value of the shape described by the result schema.