Skip to main content
Tools are functions that can be called by the AI model during conversations. They allow your agent to perform actions, retrieve information, or interact with external systems based on user requests.

Creating a tool

Create a tool in src/tools/:

Tool input and output

Define input and output schemas using Zod schemas. The AI model uses these schemas to understand when and how to call your tool:

Using tools in conversations

Provide an array of tools to your agent in a conversation handler:

Converting actions to tools

You can convert actions to tools using the asTool() method:

Converting workflows to tools

You can convert workflows to tools using the asTool() method:

Tool handler

The handler function receives the input parameters and executes the tool’s logic. It can also call custom actions.

Multiple tools

You can provide multiple tools to your agent:

Tool descriptions

The description field is crucial—it helps the AI model understand when to use your tool. Write clear, concise descriptions:

Signals

Tools can throw special signals to influence the AI’s behavior:

ThinkSignal

Throw a ThinkSignal to provide additional context to the AI without returning a result:

Best practices

  • Write clear, descriptive tool names and descriptions
  • Use Zod schemas with .describe() to provide context for each input parameter
  • Keep tool handlers focused on a single responsibility
  • Use tools for operations that require external data or actions
  • Test tools independently before using them in conversations
Tools are ideal for operations that the AI model needs to perform dynamically based on user requests. They enable your agent to go beyond just generating text and actually interact with systems, retrieve data, and perform actions.

Reference

Tool props

Handler parameters

The handler function receives validated input and execution context: