You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Add built‑in exponential backoff & retry on OpenAI API rate‐limit errors #233
Codex wrote this issue for me:
Currently any 429 "rate limit" response from the OpenAI API bubbles all the way out and causes the Codex‑CLI process to crash. We should instead catch rate‑limit errors, wait (with exponential back‑off), and retry automatically, so brief spikes don't kill the user's session.
Problem
Hitting the OpenAI API rate limit immediately aborts the CLI.
Users lose work/context when a single 429 becomes an unhandled exception.
There is no way to tune retry parameters or gracefully recover.
Proposal
Introduce a helper, e.g. codex/utils/openai_backoff.py:
importtimefromopenai.errorimportRateLimitError, OpenAIErrordefopenai_with_backoff(fn, *args, max_retries=10, initial_delay=1.0, **kwargs):
""" Wrap any OpenAI call (fn) so on RateLimitError it waits and retries with exponential backoff (capped at e.g. 60s). """delay=initial_delayforattemptinrange(max_retries):
try:
returnfn(*args, **kwargs)
exceptRateLimitError:
print(f"⏳ Rate limit hit, sleeping {delay:.1f}s (attempt {attempt+1}/{max_retries})")
time.sleep(delay)
delay=min(delay*2, 60.0)
exceptOpenAIError:
raiseraiseRuntimeError(f"OpenAI call failed after {max_retries} retries")
Monkey‑patch the two main entrypoints in startup (e.g. in codex/cli.py):
Activity
Joshuapwilley commentedon Apr 17, 2025
This issue makes this tool unusable in it's current state.
tibo-openai commentedon Apr 17, 2025
Plan looks good, please send a PR!
etburke commentedon Apr 17, 2025
+1
OneGitHubUsername commentedon Apr 17, 2025
I'm just a brain-damaged vibe coder. I had codex write this issue. I'm not confident enough to send a pr. Apologies!
tibo-openai commentedon Apr 17, 2025
In progress implementation is here:
#176
0xdevalias commentedon Apr 20, 2025
See also:
tibo-openai commentedon Apr 22, 2025
Should be fixed in latest release, please install 0.1.2504221401 and re-open if this is still an issue you encounter.
Share isolated run lifecycle across Browser and stories entries (open…
fix(gui): shorten isolated trace artifact paths (openai#233)