Class BaseTool
java.lang.Object
com.google.adk.tools.BaseTool
- Direct Known Subclasses:
AbstractMcpTool, AgentTool, BaseRetrievalTool, BuiltInCodeExecutionTool, ExampleTool, FunctionTool, GoogleMapsTool, GoogleSearchTool, IntegrationConnectorTool, LoadArtifactsTool, UrlContextTool, VertexAiSearchTool
The base class for all ADK tools.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classConfiguration class for tool arguments that allows arbitrary key-value pairs.static classConfiguration class for a tool definition in YAML/JSON. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionReturns a read-only view of the tool metadata.Optional<com.google.genai.types.FunctionDeclaration> Gets theFunctionDeclarationrepresentation of this tool.static BaseToolfromConfig(BaseTool.ToolConfig config, String configAbsPath) Creates a tool instance from a config.booleanname()io.reactivex.rxjava3.core.CompletableprocessLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext) Processes the outgoingLlmRequest.Builder.runAsync(Map<String, Object> args, ToolContext toolContext) Calls a tool.voidsetCustomMetadata(String key, Object value) Sets custom metadata to the tool associated with a key.
-
Constructor Details
-
BaseTool
-
BaseTool
-
-
Method Details
-
name
-
description
-
longRunning
public boolean longRunning() -
declaration
Gets theFunctionDeclarationrepresentation of this tool. -
customMetadata
-
setCustomMetadata
-
runAsync
-
processLlmRequest
@CanIgnoreReturnValue public io.reactivex.rxjava3.core.Completable processLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext) Processes the outgoingLlmRequest.Builder.This implementation adds the current tool's
declaration()to theGenerateContentConfigwithin the builder. If a tool with function declarations already exists, the current tool's declaration is merged into it. Otherwise, a new tool definition with the current tool's declaration is created. The current tool itself is also added to the builder's internal list of tools. Override this method for processing the outgoing request. -
fromConfig
public static BaseTool fromConfig(BaseTool.ToolConfig config, String configAbsPath) throws ConfigAgentUtils.ConfigurationException Creates a tool instance from a config.Subclasses should override and implement this method to do custom initialization from a config.
- Parameters:
config- The config for the tool.configAbsPath- The absolute path to the config file that contains the tool config.- Returns:
- The tool instance.
- Throws:
ConfigAgentUtils.ConfigurationException- if the tool cannot be created from the config.
-