Creating a tool
Create a tool insrc/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 theasTool() method:
Converting workflows to tools
You can convert workflows to tools using theasTool() 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
Thedescription 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 aThinkSignal 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