execute(). The model reads the tool’s name, description, and input schema to decide when and how to call it. You define the logic; the model decides when to use it.
Creating a tool
Create a file anywhere undersrc/:
input and output schemas use Zod. Use .describe() on each field so the model knows what to pass. The handler receives validated input and returns typed output.
Using tools in a conversation
Pass tools toexecute() via the tools array:
Inline tools
You can define tools directly inside a handler without creating a separate file:Writing good descriptions
Thedescription field is how the model decides when to use your tool. Be specific about what the tool does and when to use it:
.describe() on input fields for the same reason:
Signals
Tools can throw signals to influence the AI loop without returning a normal result.ThinkSignal
AThinkSignal throws context back into the model’s reasoning without producing a tool output. This is useful when a tool finds no results and you want the model to try a different approach:
Actions as tools
Actions are reusable functions that can be called from anywhere in your agent—conversations, workflows, other actions, or external API clients. Tools only work insideexecute(), where the AI model decides when to call them based on the conversation.
You can convert any action into a tool by calling its asTool() method and passing it into tools: