Stream disconnected before completion
What version of Codex is running?
v0.39.0
Which model were you using?
gpt-5-codex high (but with all models)
What platform is your computer?
WSL (Linux on windows)
What steps can reproduce the bug?
I was fixing an error in my codebase and at a certain point it started giving me stream errors, which is impossible, since I don't have any network problems and the context I'm giving it is very small. This only happens with the new version; I never had this problem before:
⚠️ 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 208ms…
⚠️ 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 378ms…
⚠️ 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 837ms…
⚠️ 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.482s…
⚠️ 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.035s…
■ stream disconnected before completion: Your input exceeds the context window of this model. Please adjust your input and try again.
What is the expected behavior?
_No response_
What do you see instead?
<img width="1063" height="501" alt="Image" src="https://github.com/user-attachments/assets/b9475247-174f-4fd8-b2f7-34add9619e24" />
Additional information
_No response_
53 Comments
For me running /compact fixes it
Consistently receiving this on my MacBook as well.
Same for me, can't even run compact.
Can confirm i am getting the same error consistently using codex + cursor 1.6.27 on mac.
I'm getting this error, it started it yesterday. any hope for fix?
I am also getting this error. I have tried resetting vs code, logging in and out of Codex and deleting config file but no change. I'm on Window 11 and haven't had this error until now.
same on macbook pro M4 and Macos 26
Hey all, is this an error you see within one long session and are you all re-using the same session over and over again? Wondering if you have tried to create a new chat or session and whether you still hit this issue when you do?
Here is the "new chat" button in vscode:
<img width="480" height="33" alt="Image" src="https://github.com/user-attachments/assets/e3a33e71-8007-40a7-b69f-15d7d07611e2" />
@tibo-openai
This happens even when i delete the history in ~/.codex/
Very strange, 200k Context used i get this disgusting error. Fix it ASAP! Unuseable, it does mvn test BAM ! i get the input too long error?!?! for 10k lines code project
And i think the people here talk about the CLI, not the extension in VS Code.
@tibo-openai
This happens in both CLI and extension for me. And yes it's a long session where the context is consumed, but /compact doesn't work because I get the same error.
Sometimes if it's a big task, codex reaches the limit and just breaks midway. Not ideal. An auto-compact feature is needed like CC.
No fix but I get the same error now, was ok previously working on the same project with less complicated requests. /compact /clear or a new chat same problem.
Using latest CLI on MacBook, no current project/chat, fresh wipe of ~/.codex.
Yes. I'm on cli and I'm in the middle of debugging an issue. I would not want to switch to a new session. Coming from Claude Code I didn't have this problem before. There must be a way to work on a long session, no?
This is exactly what the problem is. Its "Full"
I frequently hit this too, because I am using task master to guide the codex CLI to work on bigger scope of tasks, this can go on for hours. In claude code it auto compacts the context when it is full. I think people are looking for that auto compact feature.
+1, context meter says 57% left. This is terrible UX.
EDIT: macOS 15.4, codex 0.39.
same for me !
stream error: stream disconnected before completion: Your input exceeds the context window of this model.
Its very annoying. Here i have to tell codex to work file local md files to not overload the context window.
/compact forgets the previous conversation and codex needs to reanalyze the content...
Switching back to Claude if now fix will be available....
Same problem here on macOS 26 and codex CLI v0.39.0. It is really weird coz most of the time it worked after a few (like 3~5) retries. It just won't work at the very first try.
I am using Codex CLI v0.39.0 and have encountered this issue in a new chat. My spending limits did not even reach 10%. The context meter says: '47.4K tokens used, 93% context left'
+1. Same here. 82% context left
+1, same here
+1, Code IDE Extension in Cursor
+1, same here
I was running into this issue yesterday and most of today with several different agent sessions. On investigation, the disconnect happened when an agent streamed a unit-test run that dumped tens of thousands of warning lines. Those logs landed on top of earlier cached conversation, so the model’s context window filled up and the session was terminated with a “too much input” error.
I've compensated by redirecting noisy command output to log files and post only brief summaries. So far this is working and I haven't triggered the error -- yet.
See if there's something you're asking the agent to do that could be returning a large volume of data.
+1
I am using codex plugin on cursor. No place to /compact
downgrade to 0.34, this problem will be bypassed.
The option of /compact in Claude is so good. If it reaches the end of the context, we issue that command, and it will stop there and continue where it left off. Hope we will have something like in the codex.
how do you do this?
Ask ChatGPT with your specific setup.
+1
on pro tier, same issue.
Also on pro and same issue. I noticed that sometimes it self compacts especially when its a long back and forth. However letting it run independently for a while it will eventually end up looping throwing input limit exceeded exception
I've found a workaround: just find the
jsonlfile containing the session data (on Linux~/.codex/sessions/{year}/{month}/{session}.jsonl), read the session hash from/statusoutput, or use grep:Then try to delete some lines from the end of the file to reduce the window. Start from a line that represents the user prompt to not get instructions re-run when you open codex again, it looks like
You'll lose some history context but it will recover the session (try to delete prompts you don't need in the context).
Same here. Now the only available way is start a new conservation.
hey fam. above dummy coder here. this worked for me. $AMFT mage salutes you. happy Coding!
This is the way... This usually happens when it runs a command with a large output. Trim commands and you will be happy.
Wow, this is the only way! Thanks!
Just to add to this - I found it didn't work for me, but what did work was to start a new chat and dump the link to the broken-chat json in the prompt and ask for comments. Kudos to ubugnu for finding the file, thanks :)
+1
this is a frustrating bug, open a new session and tell it that your last session failed and ask it to try to import the relevant bits you were working on it will pick up where you left off.
i deleted the whole
~/.codexfolder and it works.+1, seems to only happen with
gpt5-highfor me. So frustrating.had the same issue, no idea what it was, but when I start a new chat then it seem to be fixed.
Still happening, what is this mess
Billion dollar company but cant even handle stream errors
i deleted the whole ~/.codex folder and it works.
i deleted the whole ~/.codex folder and it works.
i met the same problem using gpt5-high, run /compact manually and it works
I use /model or /init also have the same problem ,this is why?
I've suffered a lot in thie problem.
Please fix it ASAP
Following up with my report. Unlike the overwhelming majority of reports, mine had nothing to do with the installation or any project, and almost appeared to be caused by an account level issue after a process of elimination. It finally solved itself (I assume by some fix outside of my visibility), and my report should no longer be taken into account. I'm only making this an additional comment because that too might be useful information for someone.
Updated codex and it seems to have solved it. I had an issue where codex was both installed as a formula and cask, but it should only be a cask?
I think the "Your input exceeds the context window of this model" error is now properly handled. I'm going to close this bug. If you see this behavior with the latest versions of codex, please open a new issue and provide any relevant details.