ToolDef
Configuration for a single function tool.
Example
Section titled “Example”const weatherTool: ToolDef = { name: "get_weather", description: "Get current weather for a city", schema: z.object({ city: z.string() }), execute: async ({ city }) => `Sunny in ${city}`,}Properties
Section titled “Properties”description
Section titled “description”description:
string
Description the LLM uses to decide when to call this tool.
execute
Section titled “execute”execute: (
args,ctx) =>Promise<unknown>
Execution function called when the LLM invokes this tool.
Parameters
Section titled “Parameters”Record<string, unknown>
unknown
Returns
Section titled “Returns”Promise<unknown>
name:
string
Unique tool name sent to the LLM.
requireApproval?
Section titled “requireApproval?”
optionalrequireApproval?:boolean| ((args) =>boolean|Promise<boolean>)
Whether this tool requires human approval before execution.
schema
Section titled “schema”schema:
ZodType
Zod schema for input validation and JSON Schema generation.
timeout?
Section titled “timeout?”
optionaltimeout?:number
Maximum execution time in ms. Default: 30000.