ADK for TypeScript: API Reference
    Preparing search index...

    Class FunctionTool<TParameters>

    A tool that wraps a user-defined function, making it callable by an LLM.

    The tool's name, description, and parameter schema are exposed to the model as a function declaration. When the model requests a call, the framework invokes the user-provided execute callback with the arguments the model produced.

    Those arguments are checked only when parameters is a Zod object schema: it is applied with parse(), so a call that does not match is rejected and execute receives the parsed value. Keys the schema does not declare are handled however that schema says: a plain z.object() drops them, .passthrough() forwards them, .strict() rejects the call. A plain genai Schema, or no parameters at all, is shown to the model but is not a runtime guard — the arguments reach execute exactly as the model produced them, wrong types and extra keys included. Validate them inside execute on that path.

    Type Parameters

    Hierarchy (View Summary)

    Constructors

    Properties

    "[BASE_TOOL_SIGNATURE_SYMBOL]": true

    A unique symbol to identify ADK base tool class.

    "[FUNCTION_TOOL_SIGNATURE_SYMBOL]": true

    A unique symbol to identify ADK function tool class.

    description: string
    isLongRunning: boolean
    name: string

    Accessors

    Methods

    • Whether this call is gated on human approval — the static flag, or the predicate evaluated against the validated arguments.

      Parameters

      • args: Record<string, unknown>

        The arguments the tool would run with.

      • OptionaltoolContext: Context

        The context of the call, when there is one.

      Returns Promise<boolean>

      Whether the call requires confirmation.

    • Invokes the user-defined execute function with the model-provided arguments, after parsing them when parameters is a Zod object schema. Any other parameters value is passed through unchecked.

      Parameters

      Returns Promise<unknown>

      A promise resolving to the function's return value.

      Wrapped as Error in tool '<name>': … when a Zod parameters schema rejects the arguments or execute throws.