Stream disconnected before completion

Resolved 💬 53 comments Opened Sep 19, 2025 by YoloMark98 Closed Nov 18, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator) responded on this thread — see the highlighted reply below.

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_

View original on GitHub ↗

53 Comments

BinaryBeastMaster · 10 months ago

For me running /compact fixes it

mxroute · 10 months ago

Consistently receiving this on my MacBook as well.

edgardcham · 10 months ago

Same for me, can't even run compact.

chris-thriveo · 10 months ago

Can confirm i am getting the same error consistently using codex + cursor 1.6.27 on mac.

necatituran · 10 months ago

I'm getting this error, it started it yesterday. any hope for fix?

Mac-V-Sog · 10 months ago

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.

yurgon · 10 months ago

same on macbook pro M4 and Macos 26

tibo-openai collaborator · 10 months ago

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" />

zerox80 · 10 months ago

@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

zerox80 · 10 months ago

And i think the people here talk about the CLI, not the extension in VS Code.

edgardcham · 10 months ago

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

scottyleics · 10 months ago

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.

mxroute · 10 months ago
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 alt="Image" width="480" height="33" src="https://private-user-images.githubusercontent.com/177053821/492045924-e3a33e71-8007-40a7-b69f-15d7d07611e2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTg0ODkxOTcsIm5iZiI6MTc1ODQ4ODg5NywicGF0aCI6Ii8xNzcwNTM4MjEvNDkyMDQ1OTI0LWUzYTMzZTcxLTgwMDctNDBhNy1iNjlmLTE1ZDdkMDc2MTFlMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwOTIxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDkyMVQyMTA4MTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lZDE1ZDU2MDQ0OGU0Y2M5NzAyYjZjMmVkZjc3MzdkZjJlMWIzMmMxMjQxZWIzODU1MzI0YWViOTJkZDc2N2NiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.dFc0o_F_d6NZ-Fl16_Y21yclIKCQSCl6RFUVQerUjwg">

Using latest CLI on MacBook, no current project/chat, fresh wipe of ~/.codex.

minhdanh · 10 months ago
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: Image

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?

TheWickie · 10 months ago
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 alt="Image" width="480" height="33" src="https://private-user-images.githubusercontent.com/177053821/492045924-e3a33e71-8007-40a7-b69f-15d7d07611e2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTg0OTYxNTAsIm5iZiI6MTc1ODQ5NTg1MCwicGF0aCI6Ii8xNzcwNTM4MjEvNDkyMDQ1OTI0LWUzYTMzZTcxLTgwMDctNDBhNy1iNjlmLTE1ZDdkMDc2MTFlMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwOTIxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDkyMVQyMzA0MTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lNWFmOWRjNGJlOTNlMDhiZDg0ZmM1MjJjMWFiYmZhZGYxYTYzY2NlYzYxNjlmM2VjYzgzMDE0NWQ3NjEzNTM0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.xn50RMr9xautgP5LXds2y5sE0z2AnWM_cc_PVKB8-Cg">

This is exactly what the problem is. Its "Full"

shatteringtheabyss · 10 months ago
> 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 alt="Image" width="480" height="33" src="https://private-user-images.githubusercontent.com/177053821/492045924-e3a33e71-8007-40a7-b69f-15d7d07611e2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTg0OTYxNTAsIm5iZiI6MTc1ODQ5NTg1MCwicGF0aCI6Ii8xNzcwNTM4MjEvNDkyMDQ1OTI0LWUzYTMzZTcxLTgwMDctNDBhNy1iNjlmLTE1ZDdkMDc2MTFlMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwOTIxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDkyMVQyMzA0MTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lNWFmOWRjNGJlOTNlMDhiZDg0ZmM1MjJjMWFiYmZhZGYxYTYzY2NlYzYxNjlmM2VjYzgzMDE0NWQ3NjEzNTM0JlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.xn50RMr9xautgP5LXds2y5sE0z2AnWM_cc_PVKB8-Cg"> 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.

fullofcaffeine · 10 months ago

+1, context meter says 57% left. This is terrible UX.

EDIT: macOS 15.4, codex 0.39.

TheSunnySideUpAT · 10 months ago

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

Liskie · 10 months ago

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.

justchillinghere · 10 months ago

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'

aleksg17 · 10 months ago

+1. Same here. 82% context left

Zewkin · 10 months ago

+1, same here

hoverlover · 10 months ago

+1, Code IDE Extension in Cursor

GeorgeAlexandruS · 10 months ago

+1, same here

jasonwblock · 10 months ago

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.

callzhang · 10 months ago

+1
I am using codex plugin on cursor. No place to /compact

Aristurtle11 · 10 months ago

downgrade to 0.34, this problem will be bypassed.

suvvari8 · 10 months ago

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.

Mineregon · 9 months ago
downgrade to 0.34, this problem will be bypassed.

how do you do this?

therightjon · 9 months ago
> downgrade to 0.34, this problem will be bypassed. how do you do this?

Ask ChatGPT with your specific setup.

BottyBott · 9 months ago

+1
on pro tier, same issue.

marcohefti · 9 months ago

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

ubugnu · 9 months ago

I've found a workaround: just find the jsonl file containing the session data (on Linux ~/.codex/sessions/{year}/{month}/{session}.jsonl), read the session hash from /status output, or use grep:

grep -r "<some text from the last prompt you entered>" ~/.codex/sessions/

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

{ ... "type":"response_item","payload":{"type":"message","role":"user" .... }}

You'll lose some history context but it will recover the session (try to delete prompts you don't need in the context).

TakiGuan · 9 months ago

Same here. Now the only available way is start a new conservation.

algomoneyfest · 9 months ago
I've found a workaround: just find the jsonl file containing the session data (on Linux ~/.codex/sessions/{year}/{month}/{session}.jsonl), read the session hash from /status output, or use grep: grep -r "<some text from the last prompt you entered>" ~/.codex/sessions/ 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 { ... "type":"response_item","payload":{"type":"message","role":"user" .... }} You'll lose some history context but it will recover the session (try to delete prompts you don't need in the context).

hey fam. above dummy coder here. this worked for me. $AMFT mage salutes you. happy Coding!

shadowyman · 9 months ago
I've found a workaround: just find the jsonl file containing the session data (on Linux ~/.codex/sessions/{year}/{month}/{session}.jsonl), read the session hash from /status output, or use grep: grep -r "<some text from the last prompt you entered>" ~/.codex/sessions/ 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 { ... "type":"response_item","payload":{"type":"message","role":"user" .... }} You'll lose some history context but it will recover the session (try to delete prompts you don't need in the context).

This is the way... This usually happens when it runs a command with a large output. Trim commands and you will be happy.

mynavitechtus-sontd · 9 months ago
I've found a workaround: just find the jsonl file containing the session data (on Linux ~/.codex/sessions/{year}/{month}/{session}.jsonl), read the session hash from /status output, or use grep: grep -r "<some text from the last prompt you entered>" ~/.codex/sessions/ 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 { ... "type":"response_item","payload":{"type":"message","role":"user" .... }} You'll lose some history context but it will recover the session (try to delete prompts you don't need in the context).

Wow, this is the only way! Thanks!

sirrrella · 9 months ago
I've found a workaround: just find the jsonl file containing the session data (on Linux ~/.codex/sessions/{year}/{month}/{session}.jsonl), read the session hash from /status output, or use grep: grep -r "<some text from the last prompt you entered>" ~/.codex/sessions/ 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 { ... "type":"response_item","payload":{"type":"message","role":"user" .... }} You'll lose some history context but it will recover the session (try to delete prompts you don't need in the context).

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

timothee-aubourg · 9 months ago

+1

Kelsidavis · 9 months ago

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.

p3x-robot · 9 months ago

i deleted the whole ~/.codex folder and it works.

fullofcaffeine · 9 months ago

+1, seems to only happen with gpt5-high for me. So frustrating.

shenfangqi123 · 9 months ago

had the same issue, no idea what it was, but when I start a new chat then it seem to be fixed.

ashe0047 · 9 months ago

Still happening, what is this mess

ashe0047 · 9 months ago

Billion dollar company but cant even handle stream errors

p3x-robot · 9 months ago
Still happening, what is this mess

i deleted the whole ~/.codex folder and it works.

p3x-robot · 9 months ago
Billion dollar company but cant even handle stream errors

i deleted the whole ~/.codex folder and it works.

Hexthebaldy · 9 months ago

i met the same problem using gpt5-high, run /compact manually and it works

evzz74 · 9 months ago

I use /model or /init also have the same problem ,this is why?

Aniurm · 9 months ago

I've suffered a lot in thie problem.

Please fix it ASAP

mxroute · 9 months ago
> 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 alt="Image" width="480" height="33" src="https://private-user-images.githubusercontent.com/177053821/492045924-e3a33e71-8007-40a7-b69f-15d7d07611e2.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NTg0ODkxOTcsIm5iZiI6MTc1ODQ4ODg5NywicGF0aCI6Ii8xNzcwNTM4MjEvNDkyMDQ1OTI0LWUzYTMzZTcxLTgwMDctNDBhNy1iNjlmLTE1ZDdkMDc2MTFlMi5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjUwOTIxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI1MDkyMVQyMTA4MTdaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1lZDE1ZDU2MDQ0OGU0Y2M5NzAyYjZjMmVkZjc3MzdkZjJlMWIzMmMxMjQxZWIzODU1MzI0YWViOTJkZDc2N2NiJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCJ9.dFc0o_F_d6NZ-Fl16_Y21yclIKCQSCl6RFUVQerUjwg"> Using latest CLI on MacBook, no current project/chat, fresh wipe of ~/.codex.

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.

WilliamWatcher · 9 months ago

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?

etraut-openai contributor · 8 months ago

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.