diff --git a/core/src/main/java/com/google/adk/agents/LlmAgent.java b/core/src/main/java/com/google/adk/agents/LlmAgent.java index c89eb99a6..ab3ee7edb 100644 --- a/core/src/main/java/com/google/adk/agents/LlmAgent.java +++ b/core/src/main/java/com/google/adk/agents/LlmAgent.java @@ -48,7 +48,6 @@ import com.google.adk.models.Model; import com.google.adk.tools.BaseTool; import com.google.adk.tools.BaseToolset; -import com.google.adk.tools.ToolMarker; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; import com.google.errorprone.annotations.CanIgnoreReturnValue; @@ -85,7 +84,7 @@ public enum IncludeContents { private final Optional model; private final Instruction instruction; private final Instruction globalInstruction; - private final List toolsUnion; + private final List toolsUnion; private final ImmutableList toolsets; private final Optional generateContentConfig; // TODO: Remove exampleProvider field - examples should only be provided via ExampleTool @@ -153,7 +152,7 @@ public static Builder builder() { } /** Extracts BaseToolset instances from the toolsUnion list. */ - private static ImmutableList extractToolsets(List toolsUnion) { + private static ImmutableList extractToolsets(List toolsUnion) { return toolsUnion.stream() .filter(obj -> obj instanceof BaseToolset) .map(obj -> (BaseToolset) obj) @@ -166,7 +165,7 @@ public static class Builder extends BaseAgent.Builder { private Instruction instruction; private Instruction globalInstruction; - private ImmutableList toolsUnion; + private ImmutableList toolsUnion; private GenerateContentConfig generateContentConfig; private BaseExampleProvider exampleProvider; private IncludeContents includeContents; @@ -222,13 +221,13 @@ public Builder globalInstruction(String globalInstruction) { } @CanIgnoreReturnValue - public Builder tools(List tools) { + public Builder tools(List tools) { this.toolsUnion = ImmutableList.copyOf(tools); return this; } @CanIgnoreReturnValue - public Builder tools(ToolMarker... tools) { + public Builder tools(Object... tools) { this.toolsUnion = ImmutableList.copyOf(tools); return this; } @@ -680,7 +679,7 @@ public Single> canonicalGlobalInstruction(ReadonlyCon */ public Flowable canonicalTools(Optional context) { List> toolFlowables = new ArrayList<>(); - for (ToolMarker toolOrToolset : toolsUnion) { + for (Object toolOrToolset : toolsUnion) { if (toolOrToolset instanceof BaseTool baseTool) { toolFlowables.add(Flowable.just(baseTool)); } else if (toolOrToolset instanceof BaseToolset baseToolset) { @@ -741,7 +740,7 @@ public Single> tools() { return canonicalTools().toList(); } - public List toolsUnion() { + public List toolsUnion() { return toolsUnion; } diff --git a/core/src/main/java/com/google/adk/agents/ToolResolver.java b/core/src/main/java/com/google/adk/agents/ToolResolver.java index d11ebf457..4d3670fe4 100644 --- a/core/src/main/java/com/google/adk/agents/ToolResolver.java +++ b/core/src/main/java/com/google/adk/agents/ToolResolver.java @@ -23,7 +23,6 @@ import com.google.adk.tools.BaseTool.ToolArgsConfig; import com.google.adk.tools.BaseTool.ToolConfig; import com.google.adk.tools.BaseToolset; -import com.google.adk.tools.ToolMarker; import com.google.adk.utils.ComponentRegistry; import com.google.common.collect.ImmutableList; import java.lang.reflect.Constructor; @@ -57,14 +56,14 @@ private ToolResolver() {} * @throws ConfigurationException if any tool configuration is invalid (e.g., missing name), if a * tool cannot be found by its name or class, or if tool instantiation fails. */ - static ImmutableList resolveToolsAndToolsets( + static ImmutableList resolveToolsAndToolsets( List toolConfigs, String configAbsPath) throws ConfigurationException { if (toolConfigs == null || toolConfigs.isEmpty()) { return ImmutableList.of(); } - ImmutableList.Builder resolvedItems = ImmutableList.builder(); + ImmutableList.Builder resolvedItems = ImmutableList.builder(); for (ToolConfig toolConfig : toolConfigs) { try { diff --git a/core/src/main/java/com/google/adk/models/LlmResponse.java b/core/src/main/java/com/google/adk/models/LlmResponse.java index 01a563b48..6f8f3d785 100644 --- a/core/src/main/java/com/google/adk/models/LlmResponse.java +++ b/core/src/main/java/com/google/adk/models/LlmResponse.java @@ -180,6 +180,7 @@ public final Builder response(GenerateContentResponse response) { Optional> candidatesOpt = response.candidates(); if (candidatesOpt.isPresent() && !candidatesOpt.get().isEmpty()) { Candidate candidate = candidatesOpt.get().get(0); + this.finishReason(candidate.finishReason()); if (candidate.content().isPresent()) { this.content(candidate.content().get()); this.groundingMetadata(candidate.groundingMetadata()); diff --git a/core/src/main/java/com/google/adk/tools/BaseTool.java b/core/src/main/java/com/google/adk/tools/BaseTool.java index 3659fd3fe..eda6fac3e 100644 --- a/core/src/main/java/com/google/adk/tools/BaseTool.java +++ b/core/src/main/java/com/google/adk/tools/BaseTool.java @@ -44,7 +44,7 @@ import org.slf4j.LoggerFactory; /** The base class for all ADK tools. */ -public abstract class BaseTool implements ToolMarker { +public abstract class BaseTool { private final String name; private final String description; private final boolean isLongRunning; diff --git a/core/src/main/java/com/google/adk/tools/BaseToolset.java b/core/src/main/java/com/google/adk/tools/BaseToolset.java index 03176fb81..c7620f913 100644 --- a/core/src/main/java/com/google/adk/tools/BaseToolset.java +++ b/core/src/main/java/com/google/adk/tools/BaseToolset.java @@ -6,7 +6,7 @@ import java.util.Optional; /** Base interface for toolsets. */ -public interface BaseToolset extends AutoCloseable, ToolMarker { +public interface BaseToolset extends AutoCloseable { /** * Return all tools in the toolset based on the provided context. diff --git a/core/src/main/java/com/google/adk/tools/ToolMarker.java b/core/src/main/java/com/google/adk/tools/ToolMarker.java deleted file mode 100644 index 9cb2c18a7..000000000 --- a/core/src/main/java/com/google/adk/tools/ToolMarker.java +++ /dev/null @@ -1,19 +0,0 @@ -/* - * Copyright 2025 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.google.adk.tools; - -/** Marker interface for BaseTool and BaseToolset. */ -public interface ToolMarker {}