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

Resolved 💬 23 comments Opened Sep 24, 2025 by zjsng Closed Nov 18, 2025
💡 Likely answer: A maintainer (etraut-openai, contributor) responded on this thread — see the highlighted reply below.

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_

View original on GitHub ↗

22 Comments

robpresult-spec · 9 months ago

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

scottyleics · 9 months ago

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

zjsng · 9 months ago

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

xiejesses · 9 months ago

+1, This issue is too affecting work.

codedevmk · 9 months ago

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.

roblevine · 9 months ago

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

sebastiananders · 9 months ago

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

raffdp · 9 months ago

It should auto compact before blowing up!

blixt · 9 months ago

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

BWBama85 · 9 months ago

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

<img width="471" height="523" alt="Image" src="https://github.com/user-attachments/assets/fdd74c46-268d-4560-bf05-822b79629fbf" />

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

HenryAlexis · 9 months ago

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

stalyndc · 9 months ago

same issued. please fix.

denispcguy · 9 months ago

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.
stalyndc · 9 months ago
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?

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

Same here

computa · 9 months ago

<img width="872" height="1313" alt="Image" src="https://github.com/user-attachments/assets/ddf31f26-1379-44ca-ba1c-5c72d777d963" />
This is fraustrating.
tried every possible fix but looks like its not local but an openai issue.
Please fix this issue.

rexnetpl · 9 months ago

The same problem

vandocorreia · 9 months ago

same here

fullofcaffeine · 9 months ago

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.

amittell · 9 months ago

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

Also reported in issue #2921

wds666666 · 9 months ago

What a stupid bunch openai is, why don't you know the correct answer to the reference Claude?

etraut-openai contributor · 8 months ago

I think this issue is now addressed. If you are still seeing this with the latest version of codex, please open a new issue with repro steps and relevant details.

Showing cached comments. Read the full discussion on GitHub ↗