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
11 changes: 6 additions & 5 deletions core/src/main/java/com/google/adk/runner/Runner.java
Original file line number Diff line number Diff line change
Expand Up @@ -591,9 +591,9 @@ private void copySessionStates(Session source, Session target) {
* @return invocation context configured for a live run.
*/
private InvocationContext newInvocationContextForLive(
Session session, Optional<LiveRequestQueue> liveRequestQueue, RunConfig runConfig) {
Session session, @Nullable LiveRequestQueue liveRequestQueue, RunConfig runConfig) {
RunConfig.Builder runConfigBuilder = RunConfig.builder(runConfig);
if (liveRequestQueue.isPresent()) {
if (liveRequestQueue != null) {
// Default to AUDIO modality if not specified.
if (CollectionUtils.isNullOrEmpty(runConfig.responseModalities())) {
runConfigBuilder.setResponseModalities(
Expand All @@ -614,8 +614,9 @@ private InvocationContext newInvocationContextForLive(
InvocationContext.Builder builder =
newInvocationContextBuilder(session)
.runConfig(runConfigBuilder.build())
.userContent(Content.fromParts());
liveRequestQueue.ifPresent(builder::liveRequestQueue);
.userContent(Content.fromParts())
.liveRequestQueue(liveRequestQueue);

return builder.build();
}

Expand Down Expand Up @@ -643,7 +644,7 @@ public Flowable<Event> runLive(
return Flowable.defer(
() -> {
InvocationContext invocationContext =
newInvocationContextForLive(session, Optional.of(liveRequestQueue), runConfig);
newInvocationContextForLive(session, liveRequestQueue, runConfig);

Single<InvocationContext> invocationContextSingle;
if (invocationContext.agent() instanceof LlmAgent agent) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.genai.types.Modality;
import com.google.genai.types.Part;
import java.lang.reflect.Method;
import java.util.Optional;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
Expand All @@ -50,10 +49,9 @@ private InvocationContext invokeNewInvocationContextForLive(
throws Exception {
Method method =
Runner.class.getDeclaredMethod(
"newInvocationContextForLive", Session.class, Optional.class, RunConfig.class);
"newInvocationContextForLive", Session.class, LiveRequestQueue.class, RunConfig.class);
method.setAccessible(true);
return (InvocationContext)
method.invoke(runner, session, Optional.of(liveRequestQueue), runConfig);
return (InvocationContext) method.invoke(runner, session, liveRequestQueue, runConfig);
}

@Test
Expand Down
Loading