Repository navigation
Conversation
Fixes cheaper-inference#18734. Preserve the configurable safety margin while using actual exhaustion for cached account eligibility.
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. |
This branch has not been deployed
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.
Summary
Fixes #18734.
Codex's cached-exhaustion predicate currently applies the shared 99% used early-cutoff default as an unconditional exhaustion threshold. Thus 1% or 0.5% remaining can exclude an account even when its configured minimum-remaining cutoff is 0%.
Related fixes and scope
This complements, rather than duplicates or reverts, #17884 / #17879. That fix prevents recent success from bypassing an explicit cutoff; it deliberately left cache predicates unchanged. Its merge commit is an ancestor of this PR's base, on which the new boundary test still fails. Both of its affected test suites pass with this change.
Related but distinct: #18330 (a stricter configured cutoff not taking effect).
No changes to paid/extra-credit opt-in, upstream 429 handling, cooldowns, breaker policy, dependencies, migrations, deployment configuration, or account settings. Genuine 0% remaining still blocks normally.
Target branch
release/v3.8.53, confirmed with the operator.139070680f77728e2309eb4df18463282a1c990a.Validation
quota-preflight-healthy-override-14359.test.tsandsse-auth.test.ts.git diff --check, and configured commit hooks passed without bypass.npm run lint: exits 1 with 7 errors / 1 warning in unchanged UI files. The seven reported errors reproduce when linting the exact base source blobs with the same installed toolchain; changed-file lint passes. No unrelated UI fixes or suppression changes are included.Focused tests run with Node 24.18.1 and better-sqlite3:
DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx/esm \ --import ./open-sse/utils/setupPolyfill.ts \ --import ./tests/_setup/isolateDataDir.ts \ --test --test-force-exit --test-concurrency=4 \ tests/unit/{codex-quota-exhaustion-boundary,codex-quota-optout,codex-quota-selection-hydration,quota-policy-generalization,quota-preflight,quota-preflight-policy-configured-cutoff,quota-cache-unknown-limits,quota-cache-hydrate-5015,quota-cache-snapshot-dedup-4438,agy-quota-exhaustion-threshold,antigravity-quota-skipping,codex-scope-cooldown-clear-12817}.test.ts DISABLE_SQLITE_AUTO_BACKUP=true node --import tsx/esm \ --import ./open-sse/utils/setupPolyfill.ts \ --import ./tests/_setup/isolateDataDir.ts \ --test --test-force-exit --test-concurrency=2 \ tests/unit/{quota-preflight-healthy-override-14359,sse-auth}.test.tsTests added / coverage notes
tests/unit/codex-quota-exhaustion-boundary.test.tsadds six cases: normal Codex and Spark at 1%, 0.5%, and 0% remaining. Each exercises live cache and snapshot hydration, and verifies that an explicit 99% early-cutoff check remains effective. No assertions are weakened or deleted.All published reproduction evidence uses synthetic temporary databases; no production requests, logs, credentials, account identifiers or private deployment configuration are included.
Additional gates:
npm run check:changelog-integrityandnpm run check:test-tla-orderpassed. Changelog fragment:changelog.d/fixes/18735-codex-cached-exhaustion-boundary.md.