Tools
Tool Structure
// Example: Tool with input and optional output schemas
interface Tool<
Input extends z.ZodSchema,
Memory = any,
Output extends z.ZodSchema = z.ZodTypeAny
> {
name: string; // Unique tool identifier
description: string; // What the tool does (used by LLM)
input: Input; // Zod schema for input validation
output?: Output; // Optional: Zod schema for output validation (e.g., outputSchema)
isGlobal?: boolean; // Optional: available across all LLM calls
execute: ({ input, state, agent }) => Promise<{ result? }>;
}Execute Function Signature
Parameters
Return Value
State Object Structure
Basic Tool Example
Input Schema Configuration
Parameter Descriptions
Optional Parameters
Combining Descriptions and Optional Parameters
Output Schema Configuration
Defining Output Schema
Benefits of Output Schema
Output Schema vs Result
Tool Registration
Global Tools
Global vs Non-Global Tools
Feature
Non-Global Tools
Global Tool
State Management
Error Handling
Flow Control with goto
Basic goto Usage
Dynamic Routing Example
Best Practices
Tool Nodes
Configuration
Overriding Tool Input Parameters
Available Placeholders
Example
See Also
Last updated