codex icon indicating copy to clipboard operation
codex copied to clipboard

stream error: stream disconnected before completion: stream closed before response.complete; retrying...

Open FreedomLabsIO opened this issue 1 year ago • 46 comments

What version of Codex is running?

codex-cli 0.7.0

Which model were you using?

codex-mini-latest

What platform is your computer?

Linux 6.8.0-63-generic x86_64 x86_64

What steps can reproduce the bug?

Send any prompt after codex login

What is the expected behavior?

Model response

What do you see instead?

Image

Additional information

No response

FreedomLabsIO avatar Jul 15 '25 07:07 FreedomLabsIO

same error on macos anyone help?

BedrettinOrtak avatar Jul 15 '25 16:07 BedrettinOrtak

Same error on WSL...

Qi-jsallis avatar Jul 15 '25 19:07 Qi-jsallis

Same error on WSL...

Cai-z-us avatar Jul 15 '25 19:07 Cai-z-us

Will anyone take care of this problem?

BedrettinOrtak avatar Jul 15 '25 20:07 BedrettinOrtak

+1

nicolas-san avatar Jul 15 '25 22:07 nicolas-san

  • same problem

pwnz22 avatar Jul 16 '25 07:07 pwnz22

same issue in macOS with azure APIs

polcrub avatar Jul 16 '25 12:07 polcrub

same issue version 0.7

youvalv avatar Jul 16 '25 13:07 youvalv

@bolinfest

Cai-z-us avatar Jul 16 '25 18:07 Cai-z-us

After endless searching and experimenting, I got past this issue. I don't think it's as much Codex's fault as the transition going on at Azure right now. I went to Azure AI Foundry and pieced together this config that works with codex with plain ol' gpt-4o.

model_provider = "azure"
provider = "azure"
model = "<deployment name>" # Your deployment name, not the ai model name.

# This From AI Foundry:
# https://<your resource>.openai.azure.us/openai/deployments/<deployment name>/chat/completions?api-version=2025-01-01-preview

[model_providers.azure]
name         = "Azure OpenAI" # Not certain if this name matters.
base_url     = "https://<resource>.openai.azure.us/openai/deployments/<deployment name>"
env_key      = "AZURE_OPENAI_API_KEY"
#wire_api     = "responses" # Don't think this works with GPT-4o
query_params = { api-version = "2025-01-01-preview" } # Get this from AI Foundry URL. Azure AI Services had the wrong version, which sent me down the wrong path for half a day.

I have tested this with the latest npm version (0.7.0)

markuskreitzer avatar Jul 16 '25 18:07 markuskreitzer

Just to clarify, do you have any amount of money topped up to your credit? Check it here: https://platform.openai.com/settings/organization/billing/overview I had the same issue, but as soon as I topped up my balance with $5, the error message is gone. Even though I have/had $38 in credit grants.

xHeaven avatar Jul 16 '25 20:07 xHeaven

ı have 120$ but not working

BedrettinOrtak avatar Jul 16 '25 21:07 BedrettinOrtak

I have an Azure student license for context. The only configuration that does something for me is:

# Default settings ── used when you run plain `codex`
model_provider  = "azure"
provider        = "azure"
model           = "o4-mini"            # pick whatever you want as your day-to-day default

[model_providers.azure]
name         = "Azure OpenAI"
# NOTE: leave **only** the part up to /openai
base_url    = "https://<resource>.cognitiveservices.azure.com/openai"
env_key      = "AZURE_OPENAI_API_KEY"        
wire_api     = "responses"                   
query_params = { api-version = "2025-04-01-preview" }

Where my "resource" name is the "folder" with multiple models deployed, I did not find a way to access an individual deployed model. Moreover, any other api-version fails. With this configuration o3-mini seems to work for more than one message (o4-mini always fails after the first response, always). see:

Image

With o4-mini:

Image

The set up it's just too messy. I'm working with the 0.7.0 version installed via brew.

polcrub avatar Jul 17 '25 11:07 polcrub

https://grok.com/share/bGVnYWN5_291468fe-b9cd-44a4-928e-dbc5be3b4542

I did build the latest main branch up until now, the codex cli interface is different (OpenAI Codex (research preview) v0.0.0-dev ). And now nothing works with the config I shared before, which I had to convert to JSON since for some reason the .toml version is ignored. See:

Image

At least it loads faster and you can try more messages once past the error. I'm giving up.

polcrub avatar Jul 17 '25 13:07 polcrub

Image

Same for me

doroness avatar Jul 20 '25 19:07 doroness

Same error as everyone above. I have $ in my api credit.

when I logged in initially I got:

Credit redemption request failed: HTTP Error 400: Bad Request Successfully logged in

sjdefalco avatar Jul 21 '25 16:07 sjdefalco

For me, if I use the default model it works just fine, but if I update config.toml to have model = "o3" then I receive this error endlessly. Similarly, if I launch with codex -m o3, will get the same error. It seems specific to using o3 for me. I have a Plus subscription so I wouldn't expect there to be an issue with credits, etc.

netpoetica avatar Jul 21 '25 19:07 netpoetica

For me ocurred the same when using the models: codex-mini-latest and o4-mini. But when using o3-mini it started working. Is codex cli limited to specific models for the moment?

fnavarijo avatar Jul 21 '25 23:07 fnavarijo

As a small update - I found that after I went through Verification in my Organization (using third party Persona svc) I was able to use o3 via codex/cli for quite some time (hours). I did however once again just start observing the same issue consistently, 3 or 4 retries resulting in BackgroundEvent { message: "stream error: stream disconnected before completion..." }

netpoetica avatar Jul 22 '25 03:07 netpoetica