diff --git a/core/src/main/java/com/google/adk/agents/InvocationContext.java b/core/src/main/java/com/google/adk/agents/InvocationContext.java index 89c90b9fe..7602ca9f2 100644 --- a/core/src/main/java/com/google/adk/agents/InvocationContext.java +++ b/core/src/main/java/com/google/adk/agents/InvocationContext.java @@ -78,70 +78,6 @@ protected InvocationContext(Builder builder) { this.callbackContextData = new ConcurrentHashMap<>(builder.callbackContextData); } - /** - * @deprecated Use {@link #builder()} instead. - */ - @Deprecated(forRemoval = true) - public InvocationContext( - BaseSessionService sessionService, - BaseArtifactService artifactService, - BaseMemoryService memoryService, - Plugin pluginManager, - Optional liveRequestQueue, - Optional branch, - String invocationId, - BaseAgent agent, - Session session, - Optional userContent, - RunConfig runConfig, - boolean endInvocation) { - this( - builder() - .sessionService(sessionService) - .artifactService(artifactService) - .memoryService(memoryService) - .pluginManager(pluginManager) - .liveRequestQueue(liveRequestQueue) - .branch(branch) - .invocationId(invocationId) - .agent(agent) - .session(session) - .userContent(userContent) - .runConfig(runConfig) - .endInvocation(endInvocation)); - } - - /** - * @deprecated Use {@link #builder()} instead. - */ - @Deprecated(forRemoval = true) - public InvocationContext( - BaseSessionService sessionService, - BaseArtifactService artifactService, - BaseMemoryService memoryService, - Optional liveRequestQueue, - Optional branch, - String invocationId, - BaseAgent agent, - Session session, - Optional userContent, - RunConfig runConfig, - boolean endInvocation) { - this( - builder() - .sessionService(sessionService) - .artifactService(artifactService) - .memoryService(memoryService) - .liveRequestQueue(liveRequestQueue) - .branch(branch) - .invocationId(invocationId) - .agent(agent) - .session(session) - .userContent(userContent) - .runConfig(runConfig) - .endInvocation(endInvocation)); - } - /** * @deprecated Use {@link #builder()} instead. */ @@ -478,21 +414,6 @@ public Builder pluginManager(Plugin pluginManager) { return this; } - /** - * Sets the queue for managing live requests. - * - * @param liveRequestQueue the queue for managing live requests. - * @return this builder instance for chaining. - * @deprecated Use {@link #liveRequestQueue(LiveRequestQueue)} instead. - */ - // TODO: b/462140921 - Builders should not accept Optional parameters. - @Deprecated(forRemoval = true) - @CanIgnoreReturnValue - public Builder liveRequestQueue(Optional liveRequestQueue) { - this.liveRequestQueue = liveRequestQueue.orElse(null); - return this; - } - /** * Sets the queue for managing live requests. * @@ -505,21 +426,6 @@ public Builder liveRequestQueue(@Nullable LiveRequestQueue liveRequestQueue) { return this; } - /** - * Sets the branch ID for the invocation. - * - * @param branch the branch ID for the invocation. - * @return this builder instance for chaining. - * @deprecated Use {@link #branch(String)} instead. - */ - // TODO: b/462140921 - Builders should not accept Optional parameters. - @Deprecated(forRemoval = true) - @CanIgnoreReturnValue - public Builder branch(Optional branch) { - this.branch = branch.orElse(null); - return this; - } - /** * Sets the branch ID for the invocation. * @@ -568,16 +474,6 @@ public Builder session(Session session) { return this; } - /** - * @deprecated Use {@link #userContent(Content)} instead. - */ - @CanIgnoreReturnValue - @Deprecated - public Builder userContent(Optional userContent) { - this.userContent = userContent.orElse(null); - return this; - } - /** * Sets the user content that triggered this invocation. * diff --git a/core/src/test/java/com/google/adk/agents/InvocationContextTest.java b/core/src/test/java/com/google/adk/agents/InvocationContextTest.java index 0237261c5..e588a38ca 100644 --- a/core/src/test/java/com/google/adk/agents/InvocationContextTest.java +++ b/core/src/test/java/com/google/adk/agents/InvocationContextTest.java @@ -31,7 +31,6 @@ import com.google.genai.types.Content; import java.util.HashMap; import java.util.Map; -import java.util.Optional; import java.util.concurrent.ConcurrentHashMap; import org.junit.Assert; import org.junit.Before; @@ -607,45 +606,6 @@ public void testBranch() { assertThat(context.branch()).isEmpty(); } - @Test - // Testing deprecated methods. - public void testDeprecatedCreateMethods() { - InvocationContext context1 = - InvocationContext.builder() - .sessionService(mockSessionService) - .artifactService(mockArtifactService) - .invocationId(testInvocationId) - .agent(mockAgent) - .session(session) - .userContent(Optional.ofNullable(userContent)) - .runConfig(runConfig) - .build(); - - assertThat(context1.sessionService()).isEqualTo(mockSessionService); - assertThat(context1.artifactService()).isEqualTo(mockArtifactService); - assertThat(context1.invocationId()).isEqualTo(testInvocationId); - assertThat(context1.agent()).isEqualTo(mockAgent); - assertThat(context1.session()).isEqualTo(session); - assertThat(context1.userContent()).hasValue(userContent); - assertThat(context1.runConfig()).isEqualTo(runConfig); - - InvocationContext context2 = - InvocationContext.create( - mockSessionService, - mockArtifactService, - mockAgent, - session, - liveRequestQueue, - runConfig); - - assertThat(context2.sessionService()).isEqualTo(mockSessionService); - assertThat(context2.artifactService()).isEqualTo(mockArtifactService); - assertThat(context2.agent()).isEqualTo(mockAgent); - assertThat(context2.session()).isEqualTo(session); - assertThat(context2.liveRequestQueue()).hasValue(liveRequestQueue); - assertThat(context2.runConfig()).isEqualTo(runConfig); - } - @Test public void testActiveStreamingTools() { InvocationContext context = @@ -686,9 +646,9 @@ public void testBuilderOptionalParameters() { .artifactService(mockArtifactService) .agent(mockAgent) .session(session) - .liveRequestQueue(Optional.of(liveRequestQueue)) - .branch(Optional.of("test-branch")) - .userContent(Optional.of(userContent)) + .liveRequestQueue(liveRequestQueue) + .branch("test-branch") + .userContent(userContent) .build(); assertThat(context.liveRequestQueue()).hasValue(liveRequestQueue); @@ -696,68 +656,6 @@ public void testBuilderOptionalParameters() { assertThat(context.userContent()).hasValue(userContent); } - @Test - // Testing deprecated methods. - public void testDeprecatedConstructor() { - InvocationContext context = - new InvocationContext( - mockSessionService, - mockArtifactService, - mockMemoryService, - pluginManager, - Optional.of(liveRequestQueue), - Optional.of("test-branch"), - testInvocationId, - mockAgent, - session, - Optional.of(userContent), - runConfig, - true); - - assertThat(context.sessionService()).isEqualTo(mockSessionService); - assertThat(context.artifactService()).isEqualTo(mockArtifactService); - assertThat(context.memoryService()).isEqualTo(mockMemoryService); - assertThat(context.pluginManager()).isEqualTo(pluginManager); - assertThat(context.liveRequestQueue()).hasValue(liveRequestQueue); - assertThat(context.branch()).hasValue("test-branch"); - assertThat(context.invocationId()).isEqualTo(testInvocationId); - assertThat(context.agent()).isEqualTo(mockAgent); - assertThat(context.session()).isEqualTo(session); - assertThat(context.userContent()).hasValue(userContent); - assertThat(context.runConfig()).isEqualTo(runConfig); - assertThat(context.endInvocation()).isTrue(); - } - - @Test - // Testing deprecated methods. - public void testDeprecatedConstructor_11params() { - InvocationContext context = - new InvocationContext( - mockSessionService, - mockArtifactService, - mockMemoryService, - Optional.of(liveRequestQueue), - Optional.of("test-branch"), - testInvocationId, - mockAgent, - session, - Optional.of(userContent), - runConfig, - true); - - assertThat(context.sessionService()).isEqualTo(mockSessionService); - assertThat(context.artifactService()).isEqualTo(mockArtifactService); - assertThat(context.memoryService()).isEqualTo(mockMemoryService); - assertThat(context.liveRequestQueue()).hasValue(liveRequestQueue); - assertThat(context.branch()).hasValue("test-branch"); - assertThat(context.invocationId()).isEqualTo(testInvocationId); - assertThat(context.agent()).isEqualTo(mockAgent); - assertThat(context.session()).isEqualTo(session); - assertThat(context.userContent()).hasValue(userContent); - assertThat(context.runConfig()).isEqualTo(runConfig); - assertThat(context.endInvocation()).isTrue(); - } - @Test public void build_missingInvocationId_null_throwsException() { InvocationContext.Builder builder =