Skip to content

Commit b8eef9e

Browse files
tilgalascopybara-github
authored andcommitted
refactor: convert Optional<LiveRequestQueue> to @nullable param in Runner
PiperOrigin-RevId: 879517819
1 parent c7d2a41 commit b8eef9e

2 files changed

Lines changed: 8 additions & 9 deletions

File tree

core/src/main/java/com/google/adk/runner/Runner.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -591,9 +591,9 @@ private void copySessionStates(Session source, Session target) {
591591
* @return invocation context configured for a live run.
592592
*/
593593
private InvocationContext newInvocationContextForLive(
594-
Session session, Optional<LiveRequestQueue> liveRequestQueue, RunConfig runConfig) {
594+
Session session, @Nullable LiveRequestQueue liveRequestQueue, RunConfig runConfig) {
595595
RunConfig.Builder runConfigBuilder = RunConfig.builder(runConfig);
596-
if (liveRequestQueue.isPresent()) {
596+
if (liveRequestQueue != null) {
597597
// Default to AUDIO modality if not specified.
598598
if (CollectionUtils.isNullOrEmpty(runConfig.responseModalities())) {
599599
runConfigBuilder.setResponseModalities(
@@ -614,8 +614,9 @@ private InvocationContext newInvocationContextForLive(
614614
InvocationContext.Builder builder =
615615
newInvocationContextBuilder(session)
616616
.runConfig(runConfigBuilder.build())
617-
.userContent(Content.fromParts());
618-
liveRequestQueue.ifPresent(builder::liveRequestQueue);
617+
.userContent(Content.fromParts())
618+
.liveRequestQueue(liveRequestQueue);
619+
619620
return builder.build();
620621
}
621622

@@ -643,7 +644,7 @@ public Flowable<Event> runLive(
643644
return Flowable.defer(
644645
() -> {
645646
InvocationContext invocationContext =
646-
newInvocationContextForLive(session, Optional.of(liveRequestQueue), runConfig);
647+
newInvocationContextForLive(session, liveRequestQueue, runConfig);
647648

648649
Single<InvocationContext> invocationContextSingle;
649650
if (invocationContext.agent() instanceof LlmAgent agent) {

core/src/test/java/com/google/adk/runner/InputAudioTranscriptionTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@
3333
import com.google.genai.types.Modality;
3434
import com.google.genai.types.Part;
3535
import java.lang.reflect.Method;
36-
import java.util.Optional;
3736
import org.junit.Test;
3837
import org.junit.runner.RunWith;
3938
import org.junit.runners.JUnit4;
@@ -50,10 +49,9 @@ private InvocationContext invokeNewInvocationContextForLive(
5049
throws Exception {
5150
Method method =
5251
Runner.class.getDeclaredMethod(
53-
"newInvocationContextForLive", Session.class, Optional.class, RunConfig.class);
52+
"newInvocationContextForLive", Session.class, LiveRequestQueue.class, RunConfig.class);
5453
method.setAccessible(true);
55-
return (InvocationContext)
56-
method.invoke(runner, session, Optional.of(liveRequestQueue), runConfig);
54+
return (InvocationContext) method.invoke(runner, session, liveRequestQueue, runConfig);
5755
}
5856

5957
@Test

0 commit comments

Comments
 (0)