Skip to content

fix(codex): separate cached exhaustion from configured quota cutoff - #18735

Open
insoln wants to merge 2 commits into
cheaper-inference:release/v3.8.53from
insoln:fix/codex-exhaustion-boundary-20261101
Open

insoln wants to merge 2 commits into
cheaper-inference:release/v3.8.53from
insoln:fix/codex-exhaustion-boundary-20261101

Conversation

@insoln

@insoln insoln commented Nov 1, 2026 •

Copy link
Copy Markdown
Contributor

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%.

  • Use 100% used only for actual scoped Codex cached exhaustion.
  • Keep the shared 99% default and configurable early-cutoff enforcement unchanged.
  • Cover ordinary Codex and Spark, positive remainder and true exhaustion, both before and after persisted-snapshot hydration.

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

  • Active upstream base: release/v3.8.53, confirmed with the operator.
  • Base reviewed: 139070680f77728e2309eb4df18463282a1c990a.
  • ⚠️ base-red inherited: 🔴 Release branch not green: release/v3.8.53 #17219. Broad CI is not claimed green; this PR does not attempt to fix unrelated release failures.

Validation

  • New regression before the fix: 4 failed / 2 passed.
  • After the fix: 91 focused quota/cache/cooldown tests passed.
  • Compatibility with fix(sse): enforce configured quota cutoff after recent success #17884: 78 tests passed across quota-preflight-healthy-override-14359.test.ts and sse-auth.test.ts.
  • Prettier, changed-file ESLint, git diff --check, and configured commit hooks passed without bypass.
  • Full 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.
  • Full unit shards, Vitest, coverage and production build are left to CI per CONTRIBUTING.md.

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.ts

Tests added / coverage notes

tests/unit/codex-quota-exhaustion-boundary.test.ts adds 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-integrity and npm run check:test-tla-order passed. Changelog fragment: changelog.d/fixes/18735-codex-cached-exhaustion-boundary.md.

Fixes cheaper-inference#18734. Preserve the configurable safety margin while using actual exhaustion for cached account eligibility.
@insoln
insoln requested a review from diegosouzapw as a code owner November 1, 2026 22:22
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T22:26:13.085988Z 1c83ee9 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(backend): codex cached exhaustion hardcodes 99% usage independently of configured cutoff

1 participant