3636import java .util .ArrayList ;
3737import java .util .List ;
3838import java .util .Map ;
39- import java . util . Optional ;
39+ import org . jspecify . annotations . Nullable ;
4040import org .slf4j .Logger ;
4141import org .slf4j .LoggerFactory ;
4242
@@ -140,7 +140,7 @@ public CodeExecutionResult executeCode(
140140 executeCodeInterpreter (
141141 getCodeWithImports (codeExecutionInput .code ()),
142142 codeExecutionInput .inputFiles (),
143- codeExecutionInput .executionId ());
143+ codeExecutionInput .executionId (). orElse ( null ) );
144144
145145 // Save output file as artifacts.
146146 List <File > savedFiles = new ArrayList <>();
@@ -173,7 +173,7 @@ public CodeExecutionResult executeCode(
173173 }
174174
175175 private Map <String , Object > executeCodeInterpreter (
176- String code , List <File > inputFiles , Optional < String > sessionId ) {
176+ String code , List <File > inputFiles , @ Nullable String sessionId ) {
177177 ExtensionExecutionServiceClient codeInterpreterExtension = getCodeInterpreterExtension ();
178178 if (codeInterpreterExtension == null ) {
179179 logger .warn ("Vertex AI Code Interpreter execution is not available. Returning empty result." );
@@ -196,8 +196,9 @@ private Map<String, Object> executeCodeInterpreter(
196196 paramsBuilder .putFields (
197197 "files" , Value .newBuilder ().setListValue (listBuilder .build ()).build ());
198198 }
199- sessionId .ifPresent (
200- s -> paramsBuilder .putFields ("session_id" , Value .newBuilder ().setStringValue (s ).build ()));
199+ if (sessionId != null ) {
200+ paramsBuilder .putFields ("session_id" , Value .newBuilder ().setStringValue (sessionId ).build ());
201+ }
201202
202203 ExecuteExtensionRequest request =
203204 ExecuteExtensionRequest .newBuilder ()
0 commit comments