Skip to content
Merged
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
13 changes: 13 additions & 0 deletions core/src/main/java/com/google/adk/tools/BaseTool.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import com.google.adk.agents.ConfigAgentUtils.ConfigurationException;
import com.google.adk.models.LlmRequest;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.errorprone.annotations.DoNotCall;
import com.google.genai.types.FunctionDeclaration;
Expand All @@ -44,6 +45,7 @@ public abstract class BaseTool {
private final String name;
private final String description;
private final boolean isLongRunning;
private final HashMap<String, Object> customMetadata;

protected BaseTool(@Nonnull String name, @Nonnull String description) {
this(name, description, /* isLongRunning= */ false);
Expand All @@ -53,6 +55,7 @@ protected BaseTool(@Nonnull String name, @Nonnull String description, boolean is
this.name = name;
this.description = description;
this.isLongRunning = isLongRunning;
customMetadata = new HashMap<>();
}

public String name() {
Expand All @@ -72,6 +75,16 @@ public Optional<FunctionDeclaration> declaration() {
return Optional.empty();
}

/** Returns a read-only view of the tool metadata. */
public ImmutableMap<String, Object> customMetadata() {
return ImmutableMap.copyOf(customMetadata);
}

/** Sets custom metadata to the tool associated with a key. */
public void setCustomMetadata(String key, Object value) {
customMetadata.put(key, value);
}

/** Calls a tool. */
public Single<Map<String, Object>> runAsync(Map<String, Object> args, ToolContext toolContext) {
throw new UnsupportedOperationException("This method is not implemented.");
Expand Down