tool definition

A structured description of an external function an agent can call. Includes name, description, and JSON Schema for parameters so the LLM knows when and how to use it.

Syntax

ai-agents
{ name, description, parameters: { type: "object", properties: {...}, required: [...] } }

Example

ai-agents
const searchTool = {
  name: "web_search",
  description: "Search the web for current information. Use when you need facts you might not know.",
  parameters: {
    type: "object",
    properties: {
      query: { type: "string", description: "The search query" },
      max_results: { type: "number", description: "Number of results (default 3)" }
    },
    required: ["query"]
  }
};