Function tool

  • @tool decorator to mark a method as a tool with a description and schema. Supports explicit ZodSchema, class-based schema derivation, and primitive types.

    Usage with ZodSchema: @tool("Description", z.object({ ... }))

    Usage with class-based schema: @tool("Description") async method(params: ClassBasedParams): Promise { ... }

    Usage with primitive types (String, Number, Boolean): @tool("Description") async method(query: string): Promise { ... }

    When using primitive types, the parameter is automatically wrapped in an object with a 'value' property for the LLM, and unwrapped when calling your method.

    Parameters

    • description: string

      Description of the tool's functionality.

    • OptionalschemaOrClass: ZodType<any, ZodTypeDef, any> | SchemaConstructor

      Optional Zod schema or class constructor.

    Returns MethodDecorator

    A method decorator function.