Facing frequent stream disconnection issue while using Codex CLI
What version of Codex is running?
codex-cli 0.77.0
What subscription do you have?
Using Azure Microsoft Foundry Open AI Models
Which model were you using?
gpt-5-codex , gpt-5.1-codex
What platform is your computer?
Microsoft Windows NT 10.0.26100.0 x64
What issue are you seeing?
We are repeatedly experiencing streaming failures while executing commands using OpenAI models.
Users consistently encounter the following error:
stream disconnected before completion: response.failed event received
This occurs even for simple prompts, and the response stream fails before completion.
We also intermittently receive the following error:
"Item with id 'rs_06b3ecdc79f7f90b006957c907543438197a56565d3b3ff2278' not found."
"type": "invalid_request_error"
"param": "input"
Actions Taken So Far
To mitigate the streaming issue, we have already:
> Increased the quota limits
> Added stream retry logic/parameters to allow session continuation
→ This prevents the session from dropping immediately, but causes extreme slowness during execution
Even after these changes, the stream continues to disconnect intermittently.
What steps can reproduce the bug?
It is occurring randomly even for simple Hello message.
What is the expected behavior?
_No response_
Additional information
_No response_
28 Comments
Potential duplicates detected. Please review them and close your issue if it is a duplicate.
Powered by Codex Action
Have you reached out to the Azure team and reported this problem to them?
If this is something you can repro, please use the
/feedbackslash command to upload your logs and session details and post the thread ID here. This will help us provide additional diagnosis.Yes, I have reached out to the Azure team, and they have done some troubleshooting. They advised contacting OpenAI and also checked and told me there are no quota-related issues.
Here is the thread ID: 019ba0ff-abfa-7de1-ae95-6ccd46017244
<img width="1307" height="273" alt="Image" src="https://github.com/user-attachments/assets/ae7c6a33-6fad-4a53-938d-f5ba73f72ef9" />
@etraut-openai Do you have any updates on this issue??
This appears to be the same issue as #8371 and #8302. We're testing a fix for this internally and will roll it out once we're confident that it addresses the issue and doesn't cause any regressions.
Any ETA?? Please let us know once this is resolved.
We think we have mitigated this issue. The more recent models (like 5.2) sometimes take longer to generate the next batch of tokens during streaming, and this can sometimes exceed an HTTP timeout value, which resulted in a stream disconnect.
I'm going to mark this bug as closed, but if you see this again in the next few days, please use /feedback to upload your logs and post your thread ID here.
Hi @etraut-openai, thanks for the update.
We generally use GPT-5.1-Codex or GPT-5-Codex. I will ask my team to try this out, but could you please confirm which Codex CLI version includes the fix so we can update accordingly?
@D951516, make sure you're using the latest published version of the CLI (0.80.0).
I am using 0.80.0 since yesterday and still face the same issue.
My thread id: 019bb884-e9de-7b81-a560-2132765632e1
I am also using gpt-5.1-codex, also gpt-5.1-codex-max
Thanks for the report @cvietor. Reopening the issue.
I added this to my config.toml
and with that increased retry count, codex manages to reconnect (mostly continuing after 7th or 8th try).
I could finish my task with this, which always failed before, sometimes directly in the beginning, sometimes after a couple of minutes in.
@cvietor We tried the Stream_max_retries workaround earlier and were able to proceed, but users reported issues due to frequent stream disconnects. Each disconnect triggers 7–8 reconnection attempts, which increases latency and becomes time-consuming while running long-running jobs.
If you are using the Azure model provider, please report this issue to the Azure team. The error you're seeing appears to be specific to their implementation.
I suspect that the underlying problem is the same as the issue we recently fixed in the OpenAI endpoint, but the error message and the way it is manifested is different, and we can't say for sure that it's the same problem. If it is, you should see it go away when the Azure team picks up the code changes from OpenAI over the next few days.
I will also reach out to my Azure contacts to see if we can figure out a solution.
@etraut-openai Have you received any updates or a solution on this? I see that many other OpenAI users have also reported this issue.
Our team is still experiencing the problem and has not received any confirmation from the Azure team indicating that the issue is on their end.
@D951516, no I haven't received any response or update from the Azure team either.
This occurs for us when using GPT5.2 primarily, even on the latest 0.91 version. For now we are sticking with 5.1 Max which seems to be affected far less often, if at all.
Here are the recent error messages and the thread ID shared by our team. They are using GPT-5-Codex and GPT-5.1-Codex Max
<img width="1316" height="343" alt="Image" src="https://github.com/user-attachments/assets/a54e6f60-8aeb-45b1-87df-9dc4674bf3a0" />
I am experiencing the same issues with gpt-5.2-codex via Azure
I am also experiencing the same issue with gpt-5.1-codex via Azure
I am also experiencing the same issue with gpt-5.1-codex via Azure
Please report these problems to the Azure team. There's not much the Codex team can do about this.
I'm experiencing this several times a day, even outside of Azure
I am also experiencing the same issue with gpt-5.3-codex via Azure
Oddly enough, since GPT-5.4 has been out, I haven't seen this issue much in
gpt-5.3-codexany more. In any case, bumping retries up to 30 mostly tosses this under the rug.I kept running into this on Azure with gpt-5.3-codex and 5.4. Built a workaround that auto-retries on stream disconnect and splits large tasks into separate sessions to avoid context overflow and compaction errors.
https://github.com/pauldinu10/codex-smart
It's a PowerShell wrapper that runs each task from a tasks.md file as a fresh codex exec --full-auto session. If the stream drops, it retries automatically up to N times. Not a fix, but makes Codex usable for long migrations.
If you're still seeing this issue, please report it to the Azure team.
Hey all, are you still having the issues using azure ai foundry through codex ? If yes I managed to fix the issue (I think). I was experiencing the issue everyday and then I thought about a parameter in azure AI foundry.
When you create a deployment (basically deploy gpt 5.4 or 5.5 model in Azure AI Foundry), you can control the token per minute rate and by default it is set to 250k. I increased it to a million token per minute and it solved the issue.
I think the issue was that once codex reach the limit, it get rate alerte from azure ai foundry which leads to the reconnecting.
<img width="711" height="171" alt="Image" src="https://github.com/user-attachments/assets/df4d8815-fe6b-4720-9bd3-31cc7c2fff87" />