Should “Auto” Spawn a New Container After Timeout?

In the Responses API, using the code_interpreter tool with container set to “auto” and passing previous_response_id causes calls to fail once the original container expires. Shouldn’t “auto” either disregard the expired container when none is needed or automatically create a new one?

Hi!

Can you post a snippet of the code you used to create the problem?

Below is the general format of calls made when the issue was encountered:

{
    "model": "gpt-4.1",
    "tools": [{
      "type": "code_interpreter",
      "container": { "type": "auto" }
    }],
    "instructions": "You are a personal math tutor. When asked a math question, write and run code to answer the question.",
    "input": "I need to solve the equation 3x + 11 = 14. Can you help me?",
    "previous_response_id": "resp_abc123"
  }

A container shuts down if it is idle for 20 minutes. Any later request that uses previous_response_id and refers to a message generated by that expired container will fail with the error message “container has expired.”

Essentially, a response thread cannot survive an expired container.

I think that “auto recover” would be a desired behavior, but the docs don’t say anything about it.

What it states in the docs by “auto” is just that it will reuse a previously used container or create a new one, but not that it will check if it has expired.

  1. Auto mode: as seen in the example above, you can do this by passing the "container": { "type": "auto", files: ["file-1", "file-2"] } property in the tool configuration while creating a new Response object. This automatically creates a new container, or reuses an active container that was used by a previous code_interpreter_call item in the model’s context. Look for the code_interpreter_call item in the output of this API request to find the container_id that was generated or used.

But certainly it would be an useful new feature.

2 Likes

Greatly appreciate this feedback @dominic1 . I’d like to share this directly with the product team so that it can be factored. Please share this and anything else you’d like our team to review to support@openai.com. Thank you.

2 Likes