Class BaseTool

java.lang.Object
com.google.adk.tools.BaseTool
Direct Known Subclasses:
AgentTool, BaseRetrievalTool, BuiltInCodeExecutionTool, FunctionTool, GoogleSearchTool, LoadArtifactsTool, McpTool

public abstract class BaseTool extends Object
The base class for all ADK tools.
  • Constructor Details

    • BaseTool

      protected BaseTool(@Nonnull String name, @Nonnull String description)
    • BaseTool

      protected BaseTool(@Nonnull String name, @Nonnull String description, boolean isLongRunning)
  • Method Details

    • name

      public String name()
    • description

      public String description()
    • longRunning

      public boolean longRunning()
    • declaration

      public Optional<com.google.genai.types.FunctionDeclaration> declaration()
      Gets the FunctionDeclaration representation of this tool.
    • runAsync

      public io.reactivex.rxjava3.core.Single<Map<String,Object>> runAsync(Map<String,Object> args, ToolContext toolContext)
      Calls a tool.
    • processLlmRequest

      @CanIgnoreReturnValue public io.reactivex.rxjava3.core.Completable processLlmRequest(LlmRequest.Builder llmRequestBuilder, ToolContext toolContext)
      Processes the outgoing LlmRequest.Builder.

      This implementation adds the current tool's declaration() to the GenerateContentConfig within 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.