Fix Codex OAuth rate limit reset handling#531
Merged
ericdallo merged 2 commits intoJul 15, 2026
Conversation
Use the authoritative usage-limit response reset and bound structured rate-limit waits so quota snapshot metadata cannot stall sessions for hours. 🤖 Generated with [ECA](https://eca.dev) (openai/gpt-5.6-sol - xhigh) Co-Authored-By: eca-agent <git@eca.dev>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Since a recent upgrade the, Codex sessions have started to stall randomly after finishing a step, for example a tool call.
There seems to be a bug in the way rate limits are read from the messages, and by default there's cap on the wait time. This PR should fix it.
AI Summary
Problem
ECA could put a ChatGPT/Codex OAuth session to sleep for hours after a 429 response. It inferred retry timing from apparently exhausted
x-codex-primary-*andx-codex-secondary-*quota-window headers and selected the latest reset, while ignoring the authoritative reset in the response body. BecauserateLimitMaxWaitSecondswas optional, that inferred delay was uncapped by default.The behavior was checked against the official
openai/codeximplementation at commitf90e7deea6a715bbd153044af6f475eefa749177:codex-rs/codex-api/src/api_bridge.rshandles a 429usage_limit_reachedresponse by reading numericerror.resets_atUnix epoch seconds from the JSON body.x-codex-*primary and secondary window fields are quota snapshots; they are not independently used as retry delays.usage_limit_reachedfollows the normal bounded retry path.Fix
error.resets_atonly whenerror.typeisusage_limit_reached.retry-afteras the highest-priority signal, while allowing expired higher-priority values to fall through to a usable future reset.rateLimitMaxWaitSecondscap to the total scheduled delay, including the existing one-second safety buffer; provider overrides remain supported.Verification
clojure -M:test --focus eca.llm-providers.errors-test— 9 tests, 83 assertionsclojure -M:test --focus eca.llm-api-test— 24 tests, 323 assertionsclojure -M:test --focus eca.llm-providers.openai-test— 21 tests, 75 assertionsLC_ALL=C bb test— 778 tests, 4,274 assertions, 0 failurespython3 -m json.tool docs/config.json— passedgit diff --check— passedclj-kondowas not available in the local environment.