@@ -104,7 +104,7 @@ public async Task ComputerToolWithScreenshotRoundTrip()
104104 BinaryData screenshotBytes = BinaryData . FromBytes ( File . ReadAllBytes ( screenshotPath ) ) ;
105105 ResponseItem screenshotReply = ResponseItem . CreateComputerCallOutputItem (
106106 computerCall . CallId ,
107- ComputerCallOutput . CreateScreenshotOutput ( screenshotBytes , "image/png" ) ) ;
107+ ComputerCallOutput . CreateScreenshotOutput ( screenshotBytes , "image/png" ) ) ;
108108
109109 responseOptions . PreviousResponseId = response . Id ;
110110 response = await client . CreateResponseAsync ( [ screenshotReply ] , responseOptions ) ;
@@ -234,7 +234,7 @@ in client.CreateResponseStreamingAsync(message, responseOptions))
234234 public async Task CodeInterpreterToolWithoutFileIds ( )
235235 {
236236 OpenAIResponseClient client = GetTestClient ( ) ;
237-
237+
238238 ResponseTool codeInterpreterTool = ResponseTool . CreateCodeInterpreterTool ( ) ;
239239 ResponseCreationOptions responseOptions = new ( )
240240 {
@@ -247,16 +247,18 @@ public async Task CodeInterpreterToolWithoutFileIds()
247247
248248 Assert . That ( response , Is . Not . Null ) ;
249249 Assert . That ( response . OutputItems , Is . Not . Null . And . Not . Empty ) ;
250-
250+
251251 // Basic validation that the response was created successfully
252252 Assert . That ( response . Id , Is . Not . Null . And . Not . Empty ) ;
253+
254+ Assert . That ( response . Tools . FirstOrDefault ( ) , Is . TypeOf < CodeInterpreterTool > ( ) ) ;
253255 }
254256
255257 [ Test ]
256258 public async Task CodeInterpreterToolWithEmptyFileIds ( )
257259 {
258260 OpenAIResponseClient client = GetTestClient ( ) ;
259-
261+
260262 ResponseTool codeInterpreterTool = ResponseTool . CreateCodeInterpreterTool ( new List < string > ( ) ) ;
261263 ResponseCreationOptions responseOptions = new ( )
262264 {
@@ -269,9 +271,11 @@ public async Task CodeInterpreterToolWithEmptyFileIds()
269271
270272 Assert . That ( response , Is . Not . Null ) ;
271273 Assert . That ( response . OutputItems , Is . Not . Null . And . Not . Empty ) ;
272-
274+
273275 // Basic validation that the response was created successfully
274276 Assert . That ( response . Id , Is . Not . Null . And . Not . Empty ) ;
277+
278+ Assert . That ( response . Tools . FirstOrDefault ( ) , Is . TypeOf < CodeInterpreterTool > ( ) ) ;
275279 }
276280
277281 [ Test ]
@@ -303,9 +307,11 @@ public async Task CodeInterpreterToolWithContainerIdFromContainerApi()
303307
304308 Assert . That ( response , Is . Not . Null ) ;
305309 Assert . That ( response . OutputItems , Is . Not . Null . And . Not . Empty ) ;
306-
310+
307311 // Basic validation that the response was created successfully
308312 Assert . That ( response . Id , Is . Not . Null . And . Not . Empty ) ;
313+
314+ Assert . That ( response . Tools . FirstOrDefault ( ) , Is . TypeOf < CodeInterpreterTool > ( ) ) ;
309315 }
310316 finally
311317 {
@@ -321,6 +327,69 @@ public async Task CodeInterpreterToolWithContainerIdFromContainerApi()
321327 }
322328 }
323329
330+ [ Test ]
331+ public async Task CodeInterpreterToolWithUploadedFileIds ( )
332+ {
333+ OpenAIFileClient fileClient = GetTestClient < OpenAIFileClient > ( TestScenario . Files ) ;
334+ OpenAIResponseClient client = GetTestClient ( ) ;
335+
336+ // Create some test files to upload
337+ string csvContent = "name,age,city\n Alice,30,New York\n Bob,25,Los Angeles\n Charlie,35,Chicago" ;
338+ string pythonContent = "# This is a simple Python file\n def hello():\n print('Hello from uploaded file!')\n \n if __name__ == '__main__':\n hello()" ;
339+
340+ List < string > fileIds = new ( ) ;
341+
342+ try
343+ {
344+ // Upload CSV file
345+ using Stream csvStream = BinaryData . FromString ( csvContent ) . ToStream ( ) ;
346+ OpenAIFile csvFile = await fileClient . UploadFileAsync ( csvStream , "test_data.csv" , FileUploadPurpose . Assistants ) ;
347+ Validate ( csvFile ) ;
348+ fileIds . Add ( csvFile . Id ) ;
349+
350+ // Upload Python file
351+ using Stream pythonStream = BinaryData . FromString ( pythonContent ) . ToStream ( ) ;
352+ OpenAIFile pythonFile = await fileClient . UploadFileAsync ( pythonStream , "test_script.py" , FileUploadPurpose . Assistants ) ;
353+ Validate ( pythonFile ) ;
354+ fileIds . Add ( pythonFile . Id ) ;
355+
356+ // Create CodeInterpreter tool with uploaded file IDs
357+ ResponseTool codeInterpreterTool = ResponseTool . CreateCodeInterpreterTool ( fileIds ) ;
358+ ResponseCreationOptions responseOptions = new ( )
359+ {
360+ Tools = { codeInterpreterTool } ,
361+ } ;
362+
363+ OpenAIResponse response = await client . CreateResponseAsync (
364+ "Analyze the CSV data in the uploaded file and create a simple visualization. Also run the Python script that was uploaded." ,
365+ responseOptions ) ;
366+
367+ Assert . That ( response , Is . Not . Null ) ;
368+ Assert . That ( response . OutputItems , Is . Not . Null . And . Not . Empty ) ;
369+
370+ // Basic validation that the response was created successfully
371+ Assert . That ( response . Id , Is . Not . Null . And . Not . Empty ) ;
372+ Assert . That ( response . Tools . FirstOrDefault ( ) , Is . TypeOf < CodeInterpreterTool > ( ) ) ;
373+ }
374+ catch
375+ {
376+ // If the test fails, still try to clean up the files immediately
377+ // (They'll also be cleaned up in OneTimeTearDown, but this is more immediate)
378+ foreach ( string fileId in fileIds )
379+ {
380+ try
381+ {
382+ await fileClient . DeleteFileAsync ( fileId ) ;
383+ }
384+ catch
385+ {
386+ // Best effort cleanup
387+ }
388+ }
389+ throw ;
390+ }
391+ }
392+
324393 [ Test ]
325394 public async Task StreamingResponses ( )
326395 {
@@ -593,7 +662,7 @@ public async Task FileInputFromIdWorks()
593662 BinaryData . FromBytes ( File . ReadAllBytes ( filePath ) ) ,
594663 "test_favorite_foods.pdf" ,
595664 FileUploadPurpose . UserData ) ;
596- Validate ( newFileToUse ) ;
665+ Validate ( newFileToUse ) ;
597666
598667 ResponseItem messageItem = ResponseItem . CreateUserMessageItem (
599668 [
0 commit comments