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 — APIHubToolset | ADK for TypeScript: API Reference - v2.5.0

  • APIHubToolset

Class APIHubToolset

Builds one tool per operation of an API registered in API Hub.

The toolset fetches an OpenAPI spec from API Hub, parses it as YAML or JSON, and hands it to an OpenAPIToolset, which produces a RestApiTool for each operation.

const toolset = new APIHubToolset({
apihubResourceName:
'projects/my-project/locations/us-central1/apis/my-api',
});
const agent = new LlmAgent({
name: 'api_agent',
model: 'gemini-flash-latest',
tools: [toolset],
});

By default the spec is fetched when the toolset is constructed. A constructor cannot wait for the request, so a failure is reported by the first call to getTools, and every later call reports the same failure.

With lazyLoadSpec, the spec is fetched on the first call to getTools. A successful result is kept, including a spec that produced no tools. A failed fetch is not kept, so the next call fetches again.

Hierarchy (View Summary)

  • BaseToolset
    • APIHubToolset
  • Defined in core/src/tools/apihub_tool/apihub_toolset.ts:101

Constructors

constructor

  • new APIHubToolset(options: APIHubToolsetOptions): APIHubToolset

    Parameters

    • options: APIHubToolsetOptions

    Returns APIHubToolset

    Overrides BaseToolset.constructor

    • Defined in core/src/tools/apihub_tool/apihub_toolset.ts:114

Properties

Readonly[BASE_TOOLSET_SIGNATURE_SYMBOL]

"[BASE_TOOLSET_SIGNATURE_SYMBOL]": true

Inherited from BaseToolset.[BASE_TOOLSET_SIGNATURE_SYMBOL]

  • Defined in core/src/tools/base_toolset.ts:42

description

description: string

The toolset description, filled in from the spec when empty.

  • Defined in core/src/tools/apihub_tool/apihub_toolset.ts:105

name

name: string

The toolset name, filled in from the spec when empty.

  • Defined in core/src/tools/apihub_tool/apihub_toolset.ts:103

Optional Readonlyprefix

prefix?: string

Inherited from BaseToolset.prefix

  • Defined in core/src/tools/base_toolset.ts:46

ReadonlytoolFilter

toolFilter:
    | string[]
    | ((tool: BaseTool, readonlyContext?: ReadonlyContext) => boolean) = []

Inherited from BaseToolset.toolFilter

  • Defined in core/src/tools/base_toolset.ts:45

Methods

close

  • close(): Promise<void>

    Closes the toolset.

    NOTE: This method is invoked, for example, at the end of an agent server's lifecycle or when the toolset is no longer needed. Implementations should ensure that any open connections, files, or other managed resources are properly released to prevent leaks.

    Returns Promise<void>

    A Promise that resolves when the toolset is closed.

    Overrides BaseToolset.close

    • Defined in core/src/tools/apihub_tool/apihub_toolset.ts:148

getTools

  • getTools(context?: ReadonlyContext): Promise<BaseTool[]>

    Returns one tool per operation in the spec, or an empty array when the spec is empty.

    Parameters

    • Optionalcontext: ReadonlyContext

    Returns Promise<BaseTool[]>

    Throws

    When the spec cannot be fetched or is not valid YAML or JSON.

    Overrides BaseToolset.getTools

    • Defined in core/src/tools/apihub_tool/apihub_toolset.ts:143

ProtectedisToolSelected

  • isToolSelected(tool: BaseTool, context?: ReadonlyContext): boolean

    Returns whether the tool should be exposed to LLM.

    Parameters

    • tool: BaseTool

      The tool to check.

    • Optionalcontext: ReadonlyContext

      Context used to filter tools available to the agent.

    Returns boolean

    Whether the tool should be exposed to LLM.

    Inherited from BaseToolset.isToolSelected

    • Defined in core/src/tools/base_toolset.ts:77

processLlmRequest

  • processLlmRequest(_toolContext: Context, _llmRequest: LlmRequest): Promise<void>

    Processes the outgoing LLM request for this toolset. This method will be called before each tool processes the llm request.

    Use cases:

    • Instead of let each tool process the llm request, we can let the toolset process the llm request. e.g. ComputerUseToolset can add computer use tool to the llm request.

    Parameters

    • _toolContext: Context

      The context of the tool.

    • _llmRequest: LlmRequest

      The outgoing LLM request, mutable this method.

    Returns Promise<void>

    Inherited from BaseToolset.processLlmRequest

    • Defined in core/src/tools/base_toolset.ts:109
Constructors
constructor
Properties
[BASE_TOOLSET_SIGNATURE_SYMBOL]descriptionnameprefixtoolFilter
Methods
closegetToolsisToolSelectedprocessLlmRequest
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.