codex icon indicating copy to clipboard operation
codex copied to clipboard

Facing frequent stream disconnection issue while using Codex CLI

Open D951516 opened this issue 10 months ago • 28 comments

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

D951516 avatar Jan 07 '26 22:01 D951516

Potential duplicates detected. Please review them and close your issue if it is a duplicate.

  • #8854
  • #8838

Powered by Codex Action

github-actions[bot] avatar Jan 07 '26 22:01 github-actions[bot]

Have you reached out to the Azure team and reported this problem to them?

If this is something you can repro, please use the /feedback slash command to upload your logs and session details and post the thread ID here. This will help us provide additional diagnosis.

etraut-openai avatar Jan 07 '26 23:01 etraut-openai

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

Image

D951516 avatar Jan 09 '26 13:01 D951516

@etraut-openai Do you have any updates on this issue??

D951516 avatar Jan 12 '26 19:01 D951516

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.

etraut-openai avatar Jan 12 '26 19:01 etraut-openai

Any ETA?? Please let us know once this is resolved.

D951516 avatar Jan 12 '26 19:01 D951516

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.

etraut-openai avatar Jan 13 '26 16:01 etraut-openai

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 avatar Jan 13 '26 17:01 D951516

@D951516, make sure you're using the latest published version of the CLI (0.80.0).

etraut-openai avatar Jan 13 '26 17:01 etraut-openai

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

cvietor avatar Jan 13 '26 18:01 cvietor

Thanks for the report @cvietor. Reopening the issue.

etraut-openai avatar Jan 13 '26 18:01 etraut-openai

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 added this to my config.toml

[model_providers.azure]
# ...
stream_max_retries = 10

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 avatar Jan 13 '26 20:01 cvietor

@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.

D951516 avatar Jan 13 '26 20:01 D951516

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 avatar Jan 13 '26 20:01 etraut-openai

@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 avatar Jan 20 '26 22:01 D951516

@D951516, no I haven't received any response or update from the Azure team either.

etraut-openai avatar Jan 20 '26 22:01 etraut-openai

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.

p-clements avatar Jan 26 '26 12:01 p-clements

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

Image

D951516 avatar Jan 26 '26 13:01 D951516

I am experiencing the same issues with gpt-5.2-codex via Azure

tosokr avatar Feb 06 '26 08:02 tosokr

I am also experiencing the same issue with gpt-5.1-codex via Azure

mhkwm avatar Feb 12 '26 05:02 mhkwm