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
1 change: 0 additions & 1 deletion core/src/main/java/com/google/adk/events/EventActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.google.adk.tools.ToolConfirmation;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import com.google.genai.types.Part;
import java.util.Objects;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.adk.tools;
package com.google.adk.events;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@
import com.google.adk.agents.RunConfig.ToolExecutionMode;
import com.google.adk.events.Event;
import com.google.adk.events.EventActions;
import com.google.adk.events.ToolConfirmation;
import com.google.adk.tools.BaseTool;
import com.google.adk.tools.FunctionTool;
import com.google.adk.tools.ToolConfirmation;
import com.google.adk.tools.ToolContext;
import com.google.common.base.VerifyException;
import com.google.common.collect.ImmutableList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,9 @@
import com.google.adk.agents.InvocationContext;
import com.google.adk.agents.LlmAgent;
import com.google.adk.events.Event;
import com.google.adk.events.ToolConfirmation;
import com.google.adk.models.LlmRequest;
import com.google.adk.tools.BaseTool;
import com.google.adk.tools.ToolConfirmation;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
import com.google.common.collect.ImmutableSet;
Expand Down
1 change: 1 addition & 0 deletions core/src/main/java/com/google/adk/tools/ToolContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import com.google.adk.agents.CallbackContext;
import com.google.adk.agents.InvocationContext;
import com.google.adk.events.EventActions;
import com.google.adk.events.ToolConfirmation;
import com.google.adk.memory.SearchMemoryResponse;
import com.google.errorprone.annotations.CanIgnoreReturnValue;
import io.reactivex.rxjava3.core.Single;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import static com.google.common.truth.Truth.assertThat;

import com.google.adk.tools.ToolConfirmation;
import com.google.common.collect.ImmutableMap;
import com.google.genai.types.Content;
import com.google.genai.types.Part;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.google.adk.tools;
package com.google.adk.events;

import static com.google.common.truth.Truth.assertThat;

Expand Down
96 changes: 11 additions & 85 deletions core/src/test/java/com/google/adk/tools/FunctionToolTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@

import com.google.adk.agents.InvocationContext;
import com.google.adk.agents.RunConfig;
import com.google.adk.events.ToolConfirmation;
import com.google.adk.sessions.Session;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
Expand All @@ -34,7 +35,6 @@
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand Down Expand Up @@ -236,18 +236,10 @@ public void call_withAllSupportedParameterTypes() throws Exception {
FunctionTool tool = FunctionTool.create(Functions.class, "returnAllSupportedParametersAsMap");
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ RunConfig.builder().build(),
/* endInvocation= */ false))
InvocationContext.builder()
.session(Session.builder("123").build())
.runConfig(RunConfig.builder().build())
.build())
.functionCallId("functionCallId")
.build();

Expand Down Expand Up @@ -593,18 +585,7 @@ public void call_nonStaticWithAllSupportedParameterTypes() throws Exception {
FunctionTool.create(functions, "nonStaticReturnAllSupportedParametersAsMap");
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ null,
/* endInvocation= */ false))
InvocationContext.builder().session(Session.builder("123").build()).build())
.functionCallId("functionCallId")
.build();

Expand Down Expand Up @@ -655,18 +636,7 @@ public void runAsync_withRequireConfirmation() throws Exception {
new FunctionTool(null, method, /* isLongRunning= */ false, /* requireConfirmation= */ true);
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ null,
/* endInvocation= */ false))
InvocationContext.builder().session(Session.builder("123").build()).build())
.functionCallId("functionCallId")
.build();

Expand Down Expand Up @@ -699,18 +669,7 @@ public void create_instanceMethodWithConfirmation_requestsConfirmation() throws
FunctionTool tool = FunctionTool.create(functions, method, /* requireConfirmation= */ true);
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ null,
/* endInvocation= */ false))
InvocationContext.builder().session(Session.builder("123").build()).build())
.functionCallId("functionCallId")
.build();

Expand All @@ -727,18 +686,7 @@ public void create_staticMethodWithConfirmation_requestsConfirmation() throws Ex
FunctionTool tool = FunctionTool.create(method, /* requireConfirmation= */ true);
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ null,
/* endInvocation= */ false))
InvocationContext.builder().session(Session.builder("123").build()).build())
.functionCallId("functionCallId")
.build();

Expand All @@ -756,18 +704,7 @@ public void create_classMethodNameWithConfirmation_requestsConfirmation() throws
Functions.class, "voidReturnWithoutSchema", /* requireConfirmation= */ true);
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ null,
/* endInvocation= */ false))
InvocationContext.builder().session(Session.builder("123").build()).build())
.functionCallId("functionCallId")
.build();

Expand All @@ -786,18 +723,7 @@ public void create_instanceMethodNameWithConfirmation_requestsConfirmation() thr
functions, "nonStaticVoidReturnWithoutSchema", /* requireConfirmation= */ true);
ToolContext toolContext =
ToolContext.builder(
new InvocationContext(
/* sessionService= */ null,
/* artifactService= */ null,
/* memoryService= */ null,
/* liveRequestQueue= */ Optional.empty(),
/* branch= */ Optional.empty(),
/* invocationId= */ null,
/* agent= */ null,
/* session= */ Session.builder("123").build(),
/* userContent= */ Optional.empty(),
/* runConfig= */ null,
/* endInvocation= */ false))
InvocationContext.builder().session(Session.builder("123").build()).build())
.functionCallId("functionCallId")
.build();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.google.adk.agents.LlmAgent;
import com.google.adk.artifacts.BaseArtifactService;
import com.google.adk.artifacts.ListArtifactsResponse;
import com.google.adk.events.ToolConfirmation;
import com.google.adk.sessions.Session;
import com.google.common.collect.ImmutableList;
import io.reactivex.rxjava3.core.Single;
Expand Down