Skip to content

Latest commit

 

History

History
69 lines (37 loc) · 7.92 KB

v2.7.1.md

File metadata and controls

69 lines (37 loc) · 7.92 KB

v2.7.1

A correctness release. No new features and no configuration changes — this is the output of a whole-repo bug hunt across the refresh lease, quota forecasting, account storage, the request pipeline, and account routing. Every fix below was reproduced before it was written, and each ships with a regression test that fails against the previous code.

Two of these could silently send your requests to the wrong account or stall refreshes for every process on the machine, so upgrading is recommended for anyone running more than one account.

Closes #635. Landed as #636, #637, and #638.

Account routing

A manual pin could silently route to the wrong account

chooseAccount honours pinnedAccountIndex by position, but the account-removal paths only remapped activeIndex — never the pin. Once accounts shifted, a stale in-range pin pointed at a different account, and the loader kept it because it only range-checks the pin rather than checking identity.

The dangerous path is automatic: the runtime account check removes accounts whose refresh token was revoked, with no user action. Pool [A,B,C,D] pinned to index 2 (C), A gets revoked and removed, and every subsequent request routes to D — an account you never pinned, with no error surfaced. A pin on the last account instead went out of range, and because the pin suppresses stale-state recovery the pool wedged with a 503 until you manually unpinned.

Both removal paths — the interactive delete and the automatic revoked-token removal — now follow the pinned account by identity, re-resolving its new index or clearing the pin when that account is gone. The proxy's hot-path pin reader also now rejects negative and non-integer pins, matching the validation every other reader already applied (#638).

Token refresh

A transient refresh failure blocked refreshes for every process for 20 seconds

The cross-process refresh lease caches a result so followers can reuse the owner's freshly minted token. It cached any result — including a failure. Since a network error or timeout returns {type:"failed"} rather than throwing, one transient blip was published to the lease and served verbatim to every other caller for the full result TTL (20s), blocking a real refresh that would have succeeded. A cached 429 was worse: routed through the guardian it could put an otherwise healthy account into a multi-minute cooldown.

Only successful results are cached now — a failure carries no token material to share. The lock is still released immediately, so the next caller becomes owner and retries for real (#637).

A waiting lease acquire could be evicted into a duplicate refresh

The refresh queue evicted acquire-stage entries after maxEntryAgeMs (30s), but a lease acquire may legitimately block for the lease wait budget (35s by default). An acquire still waiting could be evicted and spawn a second refresh for the same token — and because OpenAI rotates a refresh token on first use, that second refresh fails with invalid_grant on a healthy account. Eviction now waits for the wait budget plus slack, and reads the budget the coordinator was actually configured with (CODEX_AUTH_REFRESH_LEASE_WAIT_MS or the constructor) rather than the compiled-in default (#637).

Quota display and forecasting

Monthly (Codex Business) windows were labelled 5h

The account menu hardcoded the positional labels 5h and 7d. A Codex Business account's primary window is 30 days, so the row read 5h ##------- 18% reset 28d 11h — a five-hour window that resets in 28 days. The percentage and reset were always right; only the label lied.

Labels are now derived from the window's real duration, so a monthly window renders 30d. The summary-string fallback and the ready-first sort were resolving windows by that same hardcoded label, which would have dropped a Business row's quota bar entirely and sunk the account to the bottom of the sort; both now resolve by duration (#635, #636).

An exhausted account could still be recommended, and a usable one benched

Two rounding and classification defects in forecast:

  • A live probe reporting a window 100% used with no reset time stayed ready and could be returned as the best account, because the wait calculation found no reset to wait on. It is now treated as exhausted when there is no known recovery — while a 100%-used window that does carry a reset stays a recoverable delayed account.
  • Exhaustion was decided on the rounded left-percent, so 99.6% used rounded to 0% left and the account was benched despite having quota — for a 30-day Business window, potentially for the rest of the month. Exhaustion now tests the raw used-percent, and the same raw check selects which windows contribute a wait, so a 99.6%-used sibling can no longer inflate a reported wait from 60 seconds to 28 days (#637).

Account storage

Import and legacy migration dropped the manual pin

Both import and the legacy per-project storage migration rebuilt storage from scratch, discarding pinnedAccountIndex and resetting affinityGeneration to 0. The reset generation is the dangerous half: a running proxy holding a higher in-memory generation would then clobber a newer CLI pin — reintroducing exactly the lost update the generation counter exists to prevent.

Both paths now carry the fields through, and re-resolve the pin by identity rather than by index, because the deduplication both paths perform can move accounts to different positions (#637).

Request pipeline

  • Fast-session trimming dropped the instructions it was preserving. The trim keeps up to two leading developer/system instructions plus the most recent turns, then sliced the tail to fit the budget — discarding exactly the head instructions it had just selected. It now reserves budget for them (#637).
  • A genuinely empty completion skipped the empty-response retry. output: [] counted as "has output", so an empty answer was returned instead of retried. The check is now shape-aware, matching the equivalent choices check (#637).

Rate limiting and budgets

  • A timed-out request never got its token back. The token-bucket refund window was 30s while the default fetch timeout is 60s, so by the time a timed-out request tried to refund, its consumption had already aged out of the window. The result was gradual token-bucket starvation and spurious token-exhausted skips. The window now covers the full request lifetime (#637).
  • Project- and profile-scoped budgets were silently unenforced. Budget limits are stored under a normalised key but were looked up with the raw key, so any budget whose key carried uppercase or spaces (for example a project directory named MyApp) never matched and never applied. Global budgets were unaffected (#637).

Upgrade notes

No configuration changes and no migration. Two behaviours change visibly:

  • Account rows for monthly-quota accounts now show 30d where they previously showed 5h. The underlying numbers are unchanged.
  • Project- and profile-scoped budgets that silently did nothing will now actually enforce. If you set one earlier and saw no effect, check it before upgrading.