File tree Expand file tree Collapse file tree
main/java/com/google/adk/tools
test/java/com/google/adk/tools Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -61,7 +61,7 @@ public Completable processLlmRequest(
6161 ImmutableList .Builder <Tool > updatedToolsBuilder = ImmutableList .builder ();
6262 updatedToolsBuilder .addAll (existingTools );
6363
64- String model = llmRequestBuilder .build ().model ().get ( );
64+ String model = llmRequestBuilder .build ().model ().orElse ( null );
6565 if (model != null && (model .startsWith ("gemini-2" ) || model .startsWith ("gemini-3" ))) {
6666
6767 updatedToolsBuilder .add (Tool .builder ().googleSearch (GoogleSearch .builder ().build ()).build ());
Original file line number Diff line number Diff line change 11package com .google .adk .tools ;
22
33import static com .google .common .truth .Truth .assertThat ;
4+ import static org .junit .jupiter .api .Assertions .assertDoesNotThrow ;
45
56import com .fasterxml .jackson .core .type .TypeReference ;
67import com .fasterxml .jackson .databind .ObjectMapper ;
@@ -354,5 +355,16 @@ public void runAsync_withClassAndObjectMapper_convertsArguments() throws Excepti
354355 testObserver .assertValue (expected );
355356 }
356357
358+ @ Test
359+ public void testProcessLlmRequest_WithNoModel_DoesNotThrowsException () {
360+ GoogleSearchTool tool = GoogleSearchTool .INSTANCE ;
361+ LlmRequest .Builder requestBuilder = LlmRequest .builder ();
362+
363+ assertDoesNotThrow (
364+ () -> {
365+ tool .processLlmRequest (requestBuilder , null );
366+ });
367+ }
368+
357369 public record TestToolArgs (int i , String s ) {}
358370}
You can’t perform that action at this time.
0 commit comments