Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 7 additions & 8 deletions core/src/main/java/com/google/adk/agents/LlmAgent.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -85,7 +84,7 @@ public enum IncludeContents {
private final Optional<Model> model;
private final Instruction instruction;
private final Instruction globalInstruction;
private final List<ToolMarker> toolsUnion;
private final List<Object> toolsUnion;
private final ImmutableList<BaseToolset> toolsets;
private final Optional<GenerateContentConfig> generateContentConfig;
// TODO: Remove exampleProvider field - examples should only be provided via ExampleTool
Expand Down Expand Up @@ -153,7 +152,7 @@ public static Builder builder() {
}

/** Extracts BaseToolset instances from the toolsUnion list. */
private static ImmutableList<BaseToolset> extractToolsets(List<ToolMarker> toolsUnion) {
private static ImmutableList<BaseToolset> extractToolsets(List<Object> toolsUnion) {
return toolsUnion.stream()
.filter(obj -> obj instanceof BaseToolset)
.map(obj -> (BaseToolset) obj)
Expand All @@ -166,7 +165,7 @@ public static class Builder extends BaseAgent.Builder<Builder> {

private Instruction instruction;
private Instruction globalInstruction;
private ImmutableList<ToolMarker> toolsUnion;
private ImmutableList<Object> toolsUnion;
private GenerateContentConfig generateContentConfig;
private BaseExampleProvider exampleProvider;
private IncludeContents includeContents;
Expand Down Expand Up @@ -222,13 +221,13 @@ public Builder globalInstruction(String globalInstruction) {
}

@CanIgnoreReturnValue
public Builder tools(List<? extends ToolMarker> 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;
}
Expand Down Expand Up @@ -680,7 +679,7 @@ public Single<Map.Entry<String, Boolean>> canonicalGlobalInstruction(ReadonlyCon
*/
public Flowable<BaseTool> canonicalTools(Optional<ReadonlyContext> context) {
List<Flowable<BaseTool>> 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) {
Expand Down Expand Up @@ -741,7 +740,7 @@ public Single<List<BaseTool>> tools() {
return canonicalTools().toList();
}

public List<ToolMarker> toolsUnion() {
public List<Object> toolsUnion() {
return toolsUnion;
}

Expand Down
5 changes: 2 additions & 3 deletions core/src/main/java/com/google/adk/agents/ToolResolver.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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<ToolMarker> resolveToolsAndToolsets(
static ImmutableList<Object> resolveToolsAndToolsets(
List<ToolConfig> toolConfigs, String configAbsPath) throws ConfigurationException {

if (toolConfigs == null || toolConfigs.isEmpty()) {
return ImmutableList.of();
}

ImmutableList.Builder<ToolMarker> resolvedItems = ImmutableList.builder();
ImmutableList.Builder<Object> resolvedItems = ImmutableList.builder();

for (ToolConfig toolConfig : toolConfigs) {
try {
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/com/google/adk/models/LlmResponse.java
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,7 @@ public final Builder response(GenerateContentResponse response) {
Optional<List<Candidate>> 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());
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/google/adk/tools/BaseTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion core/src/main/java/com/google/adk/tools/BaseToolset.java
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
19 changes: 0 additions & 19 deletions core/src/main/java/com/google/adk/tools/ToolMarker.java

This file was deleted.