Code Interpreter does not provide annotations

I used to be able to get file annotations like this (the same code worked 2 days ago):

response = await client.responses.create(
    model="gpt-5",
    tools=[
        {
            "type": "code_interpreter",
            "container": container.id,
        },
    ],
    input=inputs,
)
pprint(response.model_dump(), width=800)

all_file_annotations = [
    annotation
    for output in response.output
    if output.type == "message"
    for content in output.content
    if content.type == "output_text"
    for annotation in content.annotations
    if annotation.type == "container_file_citation"
]
print(response.output_text)
print("File annotations:", all_file_annotations)
print("==================================")

file_annotation = all_file_annotations[0]
file_id = file_annotation.file_id
file_name = file_annotation.filename
container_id = file_annotation.container_id

Have there been any changes to how file annotations work in the last 2 days?

Looks like the models don’t output any annotations in the responses anymore.

2 Likes

Agree, getting jack squat for files asked to be generated, even though the AI is writing links:

  "output": [
    {
      "id": "rs_68b9b080bca08193b7dc0cfbfe4bf8160600819327394ce9",
      "summary": [],
      "type": "reasoning",
      "content": null,
      "encrypted_content": null,
      "status": null
    },
    {
      "id": "ci_68b9b09239e4819390cb81d5fcee74be0600819327394ce9",
      "code": "import random\r\n\r\n# Generate 10 random integers exactly representable by float64 (0 .. 2**53)\r\nvals1 = [random.randint(0, 2**53) for _ in range(10)]\r\nvals2 = [random.randint(0, 2**53) for _ in range(10)]\r\n\r\npath1 = \"/mnt/data/float64_ints_1.txt\"\r\npath2 = \"/mnt/data/float64_ints_2.txt\"\r\n\r\nwith open(path1, \"w\") as f:\r\n    for v in vals1:\r\n        f.write(f\"{v}\\n\")\r\n\r\nwith open(path2, \"w\") as f:\r\n    for v in vals2:\r\n        f.write(f\"{v}\\n\")\r\n\r\npath1, path2, vals1, vals2",
      "container_id": "cntr_68b9b080470c81908931b99dd4ae296c061491f14a8a7d95",
      "outputs": null,
      "status": "completed",
      "type": "code_interpreter_call"
    },
    {
      "id": "msg_68b9b09728c08193a97ee3a01113739c0600819327394ce9",
      "content": [
        {
          "annotations": [],
          "text": "I\u2019ve created two text files, each containing 10 random integers that are exactly representable in float64 (range 0 to 2^53), one per line.\n\n- [Download float64_ints_1.txt](sandbox:/mnt/data/float64_ints_1.txt)\n- [Download float64_ints_2.txt](sandbox:/mnt/data/float64_ints_2.txt)\n\nIf you intended 64-bit signed integers instead (int64 range), or you want negative values, let me know and I\u2019ll regenerate accordingly.",
          "type": "output_text",
          "logprobs": []
        }
      ],
      "role": "assistant",
      "status": "completed",
      "type": "message"
    }
  ]

Both deliberately instructed, and alternately, a mere advisory to ensure links:

fix_annotations = (
    "\n\n"
    "## python\n"
    "\n"
    "- Use python tool scripts freely to solve "
    "mathematical problems and to verify code algorithms.\n"
    "- For user-requested generated data file "
    "deliverables made by python scripts, produced "
    "files must be offered as links to the user, such as "
    "[your_file.txt](sandbox:/mnt/data/your_file.txt)\n"
    "- Do not use python tool to deliver code itself. "
    "You provide code you write in a markdown code fence "
    "block as a `final` output.\n"
)

fix_annotations = """
Remember: the user cannot observe the code you send to python tool nor the mount point.
You must produce markdown links to generated files so that the files can be downloaded.
"""
task = "Deliver two txt files for me, each with 10 random float64-sized ints, one per line."

inputs = [
  {
    "role": "developer",
    "content": [
      {"type": "input_text", "text": system + fix_annotations},
    ]
  }, ...

The AI manages to burn 4500 tokens a call to run a script, though.

(An aside: gpt-5 on ChatGPT is reasoning at about 1 token per second…)

2 Likes

Yeah, in my case, I’m asking it to generate an Excel file. The output contains a reference to a file:

Download the spreadsheet
[Download the Excel: file.xlsx](sandbox:/mnt/data/file.xlsx)

Yet, the annotations are empty:

{'content': [{'annotations': [],
              'logprobs': [],
...
...

The same code used to work just fine 2 days ago. I’m not sure what the issue is now.

1 Like

Same on gpt-4.1:


      "content": [
        {
          "annotations": [],
          "text": "Your files are ready! Each contains 10 random 64-bit integers, one per line.\n\n- [Download random_ints1.txt](sandbox:/mnt/data/random_ints1.txt)\n- [Download random_ints2.txt](sandbox:/mnt/data/random_ints2.txt)",
          "type": "output_text",
          "logprobs": []

Where’s my files, code bro?

Gonna flag a mod to pass this up the chain.

1 Like

Looks like the issue is resolved. It started working properly today.

I see this was marked as solved, but I am curious if you have tried it without reasoning on gpt-5 models. I have tried countless instructions and combinations of models + reasoning instructions, and the only way I get consistent file generation is with gpt-5 with reasoning set at medium.

gpt-5-mini is hopeless from a file generation standpoint for me. same with gpt-4.1

And like you said, the reasoning really slows the process down. With responses API I am seeing really slow response times and the code interpreter tool running 3-4 times per call to do a simple “summarize” or “analyze” question against a simple xlsx file