# Code\_interpreter, reasoning and previous\_response\_id bug? (Item ‘...’ of type ‘reasoning’ was provided without its required following item.)

**URL:** <https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124>\
**Category:** Bugs\
**Tags:** code-interpreter\
**Created:** [June 5, 2025, 1:25pm UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124 "2025-06-05T13:25:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![sabbadin12](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sabbadin12/32/136546_2.png) [@sabbadin12](https://community.openai.com/u/sabbadin12)\
**Post date:** [June 5, 2025, 1:25pm UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124/1 "2025-06-05T13:25:37Z")

</div>

happens both with o3 and o4-mini

- first call is ok .. it returns a list of reasoning items all with same id,say ‘rs\_ABCD’
- second call .. same to the first call BUT i provide previous\_response\_id (and a different question of course )..  
And i get  
“error”: {  
“message”: “Item ‘rs\_ABCD’ of type ‘reasoning’ was provided without its required following item.”,  
“type”: “invalid\_request\_error”,  
“param”: “input”,  
“code”: null  
}  
}

did not find any help googling .. can someone suggest anything to solve ?  
thanks  
enrico

P.S. : same flow work with gpt4.1 (that has no reasoning items)

---

<div class="post-metadata">

**Author:** ![sabbadin12](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sabbadin12/32/136546_2.png) [@sabbadin12](https://community.openai.com/u/sabbadin12)\
**Post date:** [June 5, 2025, 2:07pm UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124/2 "2025-06-05T14:07:00Z")

</div>

as workaround . it looks like that it works if one omits the previous\_response\_id and passes “explicitly” all previous question items as item reference  
“input”: [  
..  
{  
“id”: “x1”,  
“type”: “item\_reference”  
},  
{  
“id”: “x2”,  
“type”: “item\_reference”  
},

– new question  
]

still , i would prefer to store a single id (previous\_response\_id ) on my side than the full list

---

<div class="post-metadata">

**Author:** ![sabbadin12](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sabbadin12/32/136546_2.png) [@sabbadin12](https://community.openai.com/u/sabbadin12)\
**Post date:** [June 5, 2025, 2:31pm UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124/3 "2025-06-05T14:31:13Z")

</div>

well, nope, it does not always work ☹ .. sometime it does, some time same error

---

<div class="post-metadata">

**Author:** ![chester.curme](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/chester.curme/32/411870_2.png) [@chester.curme](https://community.openai.com/u/chester.curme)\
**Post date:** [June 25, 2025, 1:39pm UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124/4 "2025-06-25T13:39:55Z")

</div>

+1. This seems to happen consistently when files are attached to the container. Here is a minimal example. Let me know if I’m doing something wrong!

```python
import io

from openai import OpenAI

client = OpenAI()

# Create sample file
csv_content = """X,Y
-1,-0.84
-0.8,-0.72
-0.6,-0.56
-0.4,-0.39
-0.2,-0.2
0,0
0.2,0.2
0.4,0.39
0.6,0.56
0.8,0.72
"""

csv_file = io.BytesIO(csv_content.encode("utf-8"))

# Upload file
file = client.files.create(file=csv_file, purpose="user_data")
file_id = file.id
print(f"File ID: {file_id}")

# Generate first response
model = "o4-mini"
reasoning = {"effort": "medium", "summary": "auto"}

response_1 = client.responses.create(
    model=model,
    reasoning=reasoning,
    tools=[
        {
            "type": "code_interpreter",
            # Create a new container
            "container": {"type": "auto", "file_ids": [file_id]},
        }
    ],
    input="Please plot the sample data and tell me what you see.",
)
print("\n------\n")
print(response_1)

# Follow up raises BadRequestError
response_2 = client.responses.create(
    model=model,
    reasoning=reasoning,
    input="Thanks!",
    previous_response_id=response_1.id,
)
print("\n------\n")
print(response_2)

```

---

<div class="post-metadata">

**Author:** ![molefrog](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/molefrog/32/649393_2.png) [@molefrog](https://community.openai.com/u/molefrog)\
**Post date:** [July 1, 2025, 1:11pm UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124/5 "2025-07-01T13:11:27Z")

</div>

We are experiencing the same issue. In our case, it can be reproduced when there is a reasoning step together with the CodeInterpreter tool. We receive the error when the agent does a hand-off to another agent with different `effort` setting.

---

<div class="post-metadata">

**Author:** ![suzzzy](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/suzzzy/32/599202_2.png) [@suzzzy](https://community.openai.com/u/suzzzy)\
**Post date:** [August 18, 2025, 1:52am UTC](https://community.openai.com/t/code-interpreter-reasoning-and-previous-response-id-bug-item-of-type-reasoning-was-provided-without-its-required-following-item/1279124/6 "2025-08-18T01:52:23Z")

</div>

I found solution!!

Do not input reasoning\_id when you use tool as “code\_interpreter” .

When I used GPT-5, I experienced a similar issue.  
So I ran many test cases and eventually discovered a pattern in how the Responses API behaves.

I posted this solution.

Try making good use of the _item input_.  
I hope this information was helpful to you.
