Repository navigation
fix(codex): keep rediscovering main-account credits after an unavailable observation - #6886
Conversation
…ble observation The recovery sweep only renewed already spendable credit evidence, so one zero, null, restricted or retracted WHAM read stopped discovery and the main account stayed refused locally even after credits were usable again. Keep consented, unpaused accounts with an exhausted window eligible for paced lookups, keep admission gated on fresh positive evidence, and bound the consented refusal's Retry-After to the base metadata interval. Closes #6845.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to This change lets opted-in main accounts keep checking for recovered credits after the included window is exhausted. Requests stay blocked until spendable credits are confirmed. No merge-blocking risk was found. Pre-merge checks |
|
…WHAM refuses auth
|
✅ Deterministic PR hygiene checks passed. |
Summary
An opted-in ChatGPT main account whose included window is full can now rediscover its credits after a single bad credit observation, and its local refusal tells clients to retry within minutes instead of days.
Before this change the background recovery sweep only renewed credit evidence that was already spendable. One WHAM read with a zero, null, missing or spending-restricted balance (or omitted
creditswithrate_limit.allowed:false, which retracts evidence) madecreditRecoveryNeeded()false, so the sweep stopped probing. Credits that were usable again were never observed, and every request kept failing locally in a few milliseconds with 429 "Codex main account reached its usage limit, and spending ChatGPT credits is off or no fresh spendable balance is available", while direct Codex spent the same credits normally (#6845). The refusal'sRetry-Afteralso pointed at the included-quota reset, which can be days away.Now:
has_creditsalone or approximate message counts never authorize spending.Retry-Afteris capped at the base five-minute metadata interval (or a sooner included reset). Without consent it still follows the included-quota reset.structure/providers/openai-tiers.md,openai-accounts.mdand the Codex integration guide describe the new recovery rule.Closes #6845
Verification
bun test tests/codex-integration/main-account-credit-renewal.test.ts tests/codex-integration/codex-credits-after-limit-main.test.ts tests/codex-integration/main-account-hard-lock-recovery.test.ts: 147 pass, 0 fail. New cases: positive → zero / null / restricted / omitted-with-allowed:false→ later"3000"re-probes after backoff and restores admission; missing initial evidence probes; refusal continues while unavailable; consent off, paused and needs-reauth do not probe; the consentedRetry-Afteris bounded.main-account-credit-renewal.test.tsgives 42 pass, 23 fail.bun test tests/lab/core-lab-boundary.test.ts tests/codex-integration/codex-quota-parser-parity.test.ts: 80 pass.bun run typecheck,bun run structure:check,bun run privacy:scan, file-size ratchet, docs build: pass.Checklist
Summary by CodeRabbit