When using the OpenAI API with the code_interpreter tool, the first generated file is correctly annotated and downloadable via a file_id. However, any subsequent files requested in the same container are created but not annotated in the response. Without annotation, these later files cannot be retrieved programmatically through the API’s file endpoints.
Steps to Reproduce
- Ask for the first file:
response = client.responses.create(
include=["code_interpreter_call.outputs"],
model="gpt-5",
input="Give me an excel file with the number 42 in it.",
stream=True,
tools=[{"type": "code_interpreter", "container": {"type": "auto"}}],
)
.xlsxfile is created.
Response includes annotation with a valid file_id.
File is downloadable via the API.
- Ask for another file in the same container:
response = client.responses.create(
include=["code_interpreter_call.outputs"],
model="gpt-5",
input=[
{"role": "user", "content": "Give me an excel file with the number 42 in it."},
{"role": "assistant", "content": "Here you go. [Download the Excel file](sandbox:/mnt/data/number_42.xlsx)"},
{"role": "user", "content": "Now give me the same as a CSV file."}
],
stream=True,
tools=[{"type": "code_interpreter", "container": "cntr_..."}],
)
Second file (e.g., .csv) is generated.
Response only contains a sandbox-style link (sandbox:/mnt/data/number_42.csv).
No annotation is present (annotations: []).
Container listing shows the file exists.
Attempting to fetch the file via file_idresults in404 Not Found.