GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • ADK for TypeScript: API Reference

This view

  • Original page
  • New address

GeezerVison is showing adk.dev — FunctionTool | ADK for TypeScript: API Reference - v2.5.0

  • FunctionTool

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

  • TParameters extends ToolInputParameters = undefined

Hierarchy (View Summary)

  • BaseTool
    • FunctionTool
      • ComputerUseTool
      • LongRunningFunctionTool
  • Defined in core/src/tools/function_tool.ts:216

Constructors

constructor

  • new FunctionTool<TParameters extends ToolInputParameters = undefined>(
        options: ToolOptions<TParameters>,
    ): FunctionTool<TParameters>

    The constructor acts as the user-friendly factory.

    Type Parameters

    • TParameters extends ToolInputParameters = undefined

    Parameters

    • options: ToolOptions<TParameters>

      The configuration for the tool.

    Returns FunctionTool<TParameters>

    Overrides BaseTool.constructor

    • Defined in core/src/tools/function_tool.ts:235

Properties

Readonly[BASE_TOOL_SIGNATURE_SYMBOL]

"[BASE_TOOL_SIGNATURE_SYMBOL]": true

A unique symbol to identify ADK base tool class.

Inherited from BaseTool.[BASE_TOOL_SIGNATURE_SYMBOL]

  • Defined in core/src/tools/base_tool.ts:83

Readonly[FUNCTION_TOOL_SIGNATURE_SYMBOL]

"[FUNCTION_TOOL_SIGNATURE_SYMBOL]": true

A unique symbol to identify ADK function tool class.

  • Defined in core/src/tools/function_tool.ts:220

Readonlydescription

description: string

Inherited from BaseTool.description

  • Defined in core/src/tools/base_tool.ts:86

ReadonlyisLongRunning

isLongRunning: boolean

Inherited from BaseTool.isLongRunning

  • Defined in core/src/tools/base_tool.ts:87

Readonlyname

name: string

Inherited from BaseTool.name

  • Defined in core/src/tools/base_tool.ts:85

Accessors

apiVariant

  • get apiVariant(): GoogleLLMVariant

    The Google API LLM variant to use.

    Returns GoogleLLMVariant

    Inherited from BaseTool.apiVariant

    • Defined in core/src/tools/base_tool.ts:198

Methods

_callLive

  • _callLive(req: CallLiveToolRequest): AsyncGenerator<unknown, void, void>

    Invokes the tool in live streaming mode, injecting any active input stream from the invocation context and yielding items from the returned stream.

    Parameters

    • req: CallLiveToolRequest

      The live tool invocation request.

    Returns AsyncGenerator<unknown, void, void>

    • Defined in core/src/tools/function_tool.ts:309

_getDeclaration

  • _getDeclaration(): FunctionDeclaration

    Returns the function declaration derived from the tool's name, description, and parameter schema.

    Returns FunctionDeclaration

    Overrides BaseTool._getDeclaration

    • Defined in core/src/tools/function_tool.ts:257

checkRequireConfirmation

  • checkRequireConfirmation(
        args: Record<string, unknown>,
        toolContext?: Context,
    ): Promise<boolean>

    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.

    Overrides BaseTool.checkRequireConfirmation

    • Defined in core/src/tools/function_tool.ts:350

processLlmRequest

  • processLlmRequest(request: ToolProcessLlmRequest): Promise<void>

    Processes the outgoing LLM request for this tool.

    Use cases:

    • Most common use case is adding this tool to the LLM request.
    • Some tools may just preprocess the LLM request before it's sent out.

    Parameters

    • request: ToolProcessLlmRequest

      The request to process the LLM request.

    Returns Promise<void>

    Inherited from BaseTool.processLlmRequest

    • Defined in core/src/tools/base_tool.ts:160

runAsync

  • runAsync(req: RunAsyncToolRequest): Promise<unknown>

    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

    • req: RunAsyncToolRequest

      The tool request containing arguments and tool context.

    Returns Promise<unknown>

    A promise resolving to the function's return value.

    Throws

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

    Overrides BaseTool.runAsync

    • Defined in core/src/tools/function_tool.ts:283
Constructors
constructor
Properties
[BASE_TOOL_SIGNATURE_SYMBOL][FUNCTION_TOOL_SIGNATURE_SYMBOL]descriptionisLongRunningname
Accessors
apiVariant
Methods
_callLive_getDeclarationcheckRequireConfirmationprocessLlmRequestrunAsync
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.