Skip to content

ToolDef

Configuration for a single function tool.

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}`,
}

description: string

Description the LLM uses to decide when to call this tool.


execute: (args, ctx) => Promise<unknown>

Execution function called when the LLM invokes this tool.

Record<string, unknown>

unknown

Promise<unknown>


name: string

Unique tool name sent to the LLM.


optional requireApproval?: boolean | ((args) => boolean | Promise<boolean>)

Whether this tool requires human approval before execution.


schema: ZodType

Zod schema for input validation and JSON Schema generation.


optional timeout?: number

Maximum execution time in ms. Default: 30000.