Erroneous tokens per min
Resolved 💬 10 comments Opened Aug 13, 2025 by gnaservicesinc Closed Aug 13, 2025
💡 Likely answer: A maintainer (enriquemorenotent, contributor)
responded on this thread — see the highlighted reply below.
What version of Codex is running?
codex-cli 0.21.0
Which model were you using?
gpt-5
What platform is your computer?
Linux 6.15.0-4-generic aarch64 aarch64
What steps can reproduce the bug?
Just ran /init for the first time in a repo in a fodler.
\F0\9F\96\90 stream disconnected before completion: Rate limit reached for gpt-5 in organization org-4186rp37ux
4fzmyzgp01lbvp on tokens per min (TPM): Limit 40000000, Used 40000000, Requested 19304. Please try a
gain in 28ms. Visit https://platform.openai.com/account/rate-limits to learn more.
Token usage: total=18006 input=16800 (+ 70656 cached) output=1206 (reasoning 896)
What is the expected behavior?
_No response_
What do you see instead?
_No response_
Additional information
_No response_
10 Comments
Same error -- on Sequoia 15.3.2 / Windows 10 +11. On the Pro account.
🖐 stream disconnected before completion: Rate limit reached for gpt-5 in organization org-4186rp37ux4fzmyzgp01lbvp on tokens per min (TPM): Limit 40000000, Used 40000000, Requested 13621. Please try again in 20ms. Visit https://platform.openai.com/account/rate-limits to learn more.
same on pro also
Same 40M token error for me too.
Pro user.
WSL2/Debian 12 under Windows 11
Just upgraded to release build today for codex-cli 0.21.0
gpt-5 / high
Linux User-PC 6.6.87.2-microsoft-standard-WSL2 #1 SMP PREEMPT_DYNAMIC Thu Jun 5 18:30:46 UTC 2025 x86_64 GNU/Linux
Just exited the session. I don't think this is on the client end, this sounds like a throttle on the backend, but in case it is helpful, session token stats:
Token usage: total=205077 input=151765 (+ 3748352 cached) output=53312 (reasoning 30976)
Same thing happening to me. Ubuntu 24.04, Codex v0.21.0
same issue here happening over and over and over
So I also see this in Windows (OpenAI Teams plan), WSL2, Ubuntu, codex v0.21.0.
This is a definite regression from v0.20.0 which i've just tried and don't see the same error at all... For the maintainers, if it helps, I've used "Chat with GitHub" and it's helped me narrow down the issue - hopefully it helps get you closer to the solution:
Here’s a focused technical breakdown of the likely regression causing "stream disconnected before completion" to be more common in 0.21.0 than in 0.20.0, using your context and the actual code.
Where the Error is Triggered
The error
is produced in
CodexErr, and is emitted in theprocess_sseasync function incodex-rs/core/src/client.rs. This function processes SSE (Server Sent Events) streams from the Responses API. The error is triggered if the stream is closed, errors, or times out before emitting aresponse.completedevent.Key locations:
What Changed Between 0.20.0 and 0.21.0?
1. Streaming Path and Output Deltas
The most likely regression area is in changes to how incremental output events are handled. In particular, the code comments note:
This means a significant change was made to forward output items as they are streamed, rather than waiting for the
response.completedevent. If for any reason the stream ends without aresponse.completed, the error will be triggered.2. Retry and Timeout Handling
There are also changes around retry and timeout configuration in tests and (likely) in user-facing code, e.g.:
stream_max_retriesstream_idle_timeout_msIf these became stricter or more aggressive, you would see more transient network/SSE issues causing the error to be surfaced.
3. Error Propagation
The code path for
process_ssenow emitsCodexErr::Streamfor more event types and error conditions (e.g. stream ends, idle timeout, SSE parse error, network error).Why Is It More Frequent in 0.21.0?
response.completed(e.g. disconnects, backend bug, network blip), the new incremental forwarding makes Codex more sensitive and will surface this error more often.response.completed, whereas older versions may have ignored or hidden this case.Recommended Next Steps
response.completed.process_ssefunction’s diff between 0.20.0 and 0.21.0, focusing on how it handles incremental events and finalization.TL;DR
The main code causing this regression is in
codex-rs/core/src/client.rs, functionprocess_sse. In 0.21.0, incremental SSE event handling causesCodexErr::Stream("stream closed before response.completed")to be surfaced more often if the stream ends without a proper completion event. This is likely due to intended changes for better streaming UX and correctness, but it exposes stream/network/backend flakiness that was previously hidden.The same for me.
The temporary workaround is to install the previous release:
Run this if on Mac, and it should work fine until they fix it.
Uninstalls existing installs and installs working version through NPM.
My apologies, the issues should be resolved now, this was server side error so no version rollback is required.
It was also happening to me in v0.19