codex icon indicating copy to clipboard operation
codex copied to clipboard

“stream disconnected before completion” + “input exceeds context window” loop

Open zjsng opened this issue 1 year ago • 23 comments

What version of Codex is running?

0.40.0

Which model were you using?

gpt-5-codex (medium)

What platform is your computer?

Darwin 24.6.0 arm64 arm

What steps can reproduce the bug?

For me, everytime it completes a yarn test command, it seems to trigger this issue. It likely tried to read the entire output of yarn test and caused a soft lock of the conversation.

What is the expected behavior?

It shouldn't cause a soft lock of the current conversation, as I am not able to run /compact or any other command to avoid losing all context.

What do you see instead?

⚠️ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please
adjust your input and try again.; retrying 1/5 in 197ms…

⚠️ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please
adjust your input and try again.; retrying 2/5 in 374ms…

⚠️ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please
adjust your input and try again.; retrying 3/5 in 869ms…

⚠️ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please
adjust your input and try again.; retrying 4/5 in 1.634s…

⚠️ stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please
adjust your input and try again.; retrying 5/5 in 3.042s…

■ stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input
and try again.

Additional information

No response

zjsng avatar Sep 24 '25 02:09 zjsng

I get the same thing - stream error: stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.; retrying 2/5 in 434ms…

I try a different model - same thing. Try ChatGPT5 Account - Same thing - Try with Api key - same thing. ouch

robpresult-spec avatar Sep 24 '25 15:09 robpresult-spec

+1 here, same errors, makes the new model pretty much unusable now. Downgrading to GPT5 regular is not a solution as its terrible at coding work.

scottyleics avatar Sep 24 '25 18:09 scottyleics

For anyone else having the same issue, I made a workaround for the problem by saving in AGENTS.md an instruction to output the problematic terminal commands into a file and then reading it

zjsng avatar Sep 24 '25 23:09 zjsng

+1, This issue is too affecting work.

xiejesses avatar Sep 25 '25 08:09 xiejesses

same issue here, it says that I've exceeded my context yet when I check rate usage 5h limit 0% used · resets 11:13 PM and Weekly limit 10% used · resets Oct 1.

Switched to norma and codex thinking modes without success, changed to prerelease and back to latest and there is no difference, this extension is completly locked which makes no sense given my context usage.

codedevmk avatar Sep 27 '25 23:09 codedevmk

+1, model is pretty unusable for detailed work right now.

roblevine avatar Sep 28 '25 11:09 roblevine

Just encountered this. So while this issue persists I gonna use Claude Code CLI.

sebastiananders avatar Sep 28 '25 15:09 sebastiananders

It should auto compact before blowing up!

raffdp avatar Sep 28 '25 19:09 raffdp

I got this despite having a lot of context left, so my guess is the most recent tool call had a result so huge it immediately crossed the limit. Using /compact didn't resolve this because it seems the tool result is still included in that flow.

So it would be nice to be able to /undo or something which would take me back one step in the chat history, so I can keep using my 1 hour session by telling the AI how to proceed differently instead of just losing everything that was built up in that time...

(I know transcript has "edit prev" which lets me roll back my own messages, but that would roll back the majority of my session since Codex was in control for the most part.)

blixt avatar Oct 02 '25 17:10 blixt

I have not hit my rates and I am getting this:

Image

This is incredibly frustrating and making me want to move outside of ChatGPT.

BWBama85 avatar Oct 03 '25 16:10 BWBama85

Same issue here! I haven't reached my rates yet.

HenryAlexis avatar Oct 03 '25 21:10 HenryAlexis

same issued. please fix.

stalyndc avatar Oct 04 '25 19:10 stalyndc

In my case, pytest output was blowing up all the limits with huge 23k line output. I solved it by adding this to agents.md:

  • Capture pytest output in pytest_output.txt (e.g., append > pytest_output.txt or | tee pytest_output.txt) and read results from that file.
  • At the start of each session, recreate pytest_output.txt so it only contains fresh output.

denispcguy avatar Oct 04 '25 20:10 denispcguy

In my case, pytest output was blowing up all the limits with huge 23k line output. I solved it by adding this to agents.md:

* Capture pytest output in `pytest_output.txt` (e.g., append `> pytest_output.txt` or `| tee pytest_output.txt`) and read results from that file.

* At the start of each session, recreate `pytest_output.txt` so it only contains fresh output.

Can some conform if this work?

stalyndc avatar Oct 04 '25 20:10 stalyndc

stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.

Same here

bitflower avatar Oct 05 '25 20:10 bitflower

Image This is fraustrating. tried every possible fix but looks like its not local but an openai issue. Please fix this issue.

computa avatar Oct 06 '25 06:10 computa

The same problem

rexnetpl avatar Oct 06 '25 07:10 rexnetpl

same here

vandocorreia avatar Oct 06 '25 16:10 vandocorreia

Same here. This is the only thing keeping me from fully switching to Codex. Such a pity: great model, but the UX is too rough right now. Claude Code is miles ahead in that regard.

fullofcaffeine avatar Oct 07 '25 00:10 fullofcaffeine

Same problem here, seems unrecoverable once it happens it requires a fresh conversation.

Also reported in issue #2921

amittell avatar Oct 07 '25 18:10 amittell