Skip to content

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

Closed

Description

@zjsng

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

Activity

  1. robpresult-spec commented on Sep 24, 2025

    @robpresult-spec

    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

  2. scottyleics commented on Sep 24, 2025

    @scottyleics

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

  3. zjsng commented on Sep 24, 2025

    @zjsng
    Author

    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

  4. xiejesses commented on Sep 25, 2025

    @xiejesses

    +1, This issue is too affecting work.

  5. codedevmk commented on Sep 27, 2025

    @codedevmk

    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.

  6. roblevine commented on Sep 28, 2025

    @roblevine

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

  7. sebastiananders commented on Sep 28, 2025

    @sebastiananders

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

  8. raffdp commented on Sep 28, 2025

    @raffdp

    It should auto compact before blowing up!

  9. blixt commented on Oct 2, 2025

    @blixt

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

  10. BWBama85 commented on Oct 3, 2025

    @BWBama85

    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.

  11. HenryAlexis commented on Oct 3, 2025

    @HenryAlexis

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

  12. stalyndc commented on Oct 4, 2025

    @stalyndc

    same issued. please fix.

  13. denispcguy commented on Oct 4, 2025

    @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.
  14. stalyndc commented on Oct 4, 2025

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

    Can some conform if this work?

  15. bitflower commented on Oct 5, 2025

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

    Same here

  16. computa commented on Oct 6, 2025

    @computa
    Image This is fraustrating. tried every possible fix but looks like its not local but an openai issue. Please fix this issue.
  17. rexnetpl commented on Oct 6, 2025

    @rexnetpl

    The same problem

  18. vandocorreia commented on Oct 6, 2025

    @vandocorreia

    same here

  19. fullofcaffeine commented on Oct 7, 2025

    @fullofcaffeine

    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.

  20. amittell commented on Oct 7, 2025

    @amittell

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

    Also reported in issue #2921

  21. wds666666 commented on Oct 11, 2025

    @wds666666

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

  22. added
    contextIssues related to context management (including compaction)
    on Nov 2, 2025
  23. etraut-openai commented on Nov 18, 2025

    @etraut-openai
    Contributor

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingcontextIssues related to context management (including compaction)

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions