Feature request: automatic back-off + prompt/token optimiser to avoid rate-limit exits
Resolved 💬 4 comments Opened Apr 27, 2025 by lucasrod Closed Aug 7, 2025
💡 Likely answer: A maintainer (tibo-openai, collaborator)
responded on this thread — see the highlighted reply below.
Summary
The CLI currently stops immediately when hitting TPM limits.
Adding an auto-back-off / retry mechanism and an optional token-usage report would:
- Prevent unexpected exits (see related bug report).
- Help users trim prompts before submission.
Current version / environment
- Codex CLI rev: v0.1.2504161551
- Model: o4-mini
- Platform: Darwin 24.4.0 arm64 arm
Proposed behaviour
- Retry logic
- Config flags:
--max-retries,--base-delay-ms,--max-delay-ms. - Respect
x-ratelimit-resetor fallback to the numeric seconds in the error message.
- Token usage insight
- After each request, optionally print:
````
Prompt: 18 452 tok Completion: 53 432 tok Total: 71 884 tok
- Provide tips (“Consider removing large binary blobs or minified JS”).
- Docs update
- Add a “Reducing token usage” section with concrete examples (e.g., strip comments, use
<<file:README.md#L1-L200>>inclusions).
Additional information
Similar SDKs (Python / JS official clients) already expose openai.error.RateLimitError handling examples.
Having parity in the CLI would improve UX and reduce load on the API.
4 Comments
An implementation of exponential backoff was released in 0.1.2504221401, however even with this newer version I am experiencing frequent crashes due to rate limits.
Please update to latest version, see https://github.com/openai/codex/blob/main/CHANGELOG.md#012504251709. The version mentioned above is very outdated. The retry logic explain is implemented and I would like to not introduce extra complexity in the form of configurable flags. This should just work well out of the box.
-------
Regarding 2), there is a pending implementation of a /cost command here: https://github.com/openai/codex/pull/322. I am pinging the author to see if they still want to push this forward.
Regarding 3), it's a great idea and in general I'm very supportive of changes that both reduce token usage directly or better inform users on how to configure things better here.
@tibo-openai - I am still experiencing these backoff errors on the later version that includes the "fix" - I left a comment here with the specific error I am experiencing - https://github.com/openai/codex/issues/690#issuecomment-2837467256
Thank you for the detailed feature request! We're primarily focused on the native/Rust implementation of Codex CLI. Please try the latest version, and if this is still an issue, we'd be happy to consider a contribution to the
codex-rs/implementation. Your feedback is invaluable in improving the CLI experience.