Tools are functions that can be used to extend the capabilities of your agents. There are two core use-cases for tools:

  1. Function Calling: Tools are functions that can be used to call other agents, connect to external APIs, or interact with your database. In the context of a blockchain system, tools can be used to manage private keys, sign transactions and relay them to the blockchain.

  2. Structured Output: Tools are functions that can be used to generate structured output. This is useful for generating JSON, CSV, or other structured data.

Tools are optional and can be added to an Agent to extend its capabilities. Tools are included in the calls to the language model through the tools property.

Creating a Tool

Tools are created using the Tool class and can be sent to the agent using the tools property during initialization.

const tool = new Tool({
    provider: "openai",
    name: "get weather",
    description: "This tool is used to get the current weather in a location",
    parameters: z.object({
        location: z.string(),
    }),
    execute: async ({ location }) => {
        return "The current weather in " + location + " is sunny";
    },
});

Default Tools