Skip to content

[Bug]: Pool account keeps a stale 5-hour limit after a Plus → Pro upgrade #7961

Closed

Description

@SupernovaTitanium

Client or integration

OpenCodex dashboard

Area

Authentication and account pool

Summary

After upgrading a pool (non-main) ChatGPT account from Plus to Pro, opencodex keeps the account at 5h 100% · limit reached on the dashboard, and routing skips it until the old Plus 5-hour window's shortResetAt elapses. Every WHAM probe since the upgrade reports no 5-hour window at all, so the reading being enforced comes from the old plan.

Expected: a complete WHAM observation that proves there is no burst window should retire the carried short-window tuple for pool accounts. #6287 (fixing #6244) already does this for the main account.

Root cause

parseMainPolicyUsageQuota() already derives shortWindowAbsent: true from this topology, and mergeAccountQuota() skips assignCarriedShort() when it sees that marker. Pool accounts never get there, for two reasons:

  1. setAccountQuotaFromParsed() (src/codex/quota.ts:336) forwards shortWindowAbsent only when isMain && mainWriter.
  2. The pool probe (src/codex/auth-api/pool-quota-probe.ts:380) and the re-login path (src/codex/auth-api/login-flow.ts:281) pass the plain parseUsageQuota() result as the policy observation, so the marker is never computed for pool accounts.

Pool accounts therefore always take the "unknown usage, retain the entire known tuple" branch. That branch is right for partial header observations, but wrong for a complete WHAM snapshot without a short window. Both lines are unchanged on dev as of today.

Proposed fix

Compute the marker for pool and login WHAM observations too, and let setAccountQuotaFromParsed() honour it for non-main accounts. Main-account behaviour without a mainWriter is unchanged.

--- a/src/codex/quota.ts
+++ b/src/codex/quota.ts
@@ -333,7 +333,7 @@
-  const displayQuota: MainPolicyQuotaObservation = isMain && mainWriter && policyQuota?.shortWindowAbsent === true
+  const displayQuota: MainPolicyQuotaObservation = (!isMain || mainWriter) && policyQuota?.shortWindowAbsent === true
     ? { ...quota, shortWindowAbsent: true }
     : quota;
@@ -952,6 +952,14 @@
+/** Pool policy evidence: a WHAM topology without a burst window retires a carried 5-hour reading (e.g. after a plan upgrade). */
+export function withWhamShortWindowAbsence(
+  data: WhamUsageResponse,
+  quota: Omit<StoredAccountQuota, "updatedAt">,
+): MainPolicyQuotaObservation {
+  return parseMainPolicyUsageQuota(data)?.shortWindowAbsent === true ? { ...quota, shortWindowAbsent: true } : quota;
+}
--- a/src/codex/auth-api/pool-quota-probe.ts
+++ b/src/codex/auth-api/pool-quota-probe.ts
@@ -377,7 +377,7 @@
-  setAccountQuotaFromParsed(accountId, quota, writerGeneration, undefined, validPolicyObservation ? quota : null,
+  setAccountQuotaFromParsed(accountId, quota, writerGeneration, undefined, validPolicyObservation ? withWhamShortWindowAbsence(data, quota) : null,
--- a/src/codex/auth-api/login-flow.ts
+++ b/src/codex/auth-api/login-flow.ts
@@ -278,7 +278,7 @@
-                  policyQuota = isValidWhamHistoryObservation(data) ? quota : null;
+                  policyQuota = quota && isValidWhamHistoryObservation(data) ? withWhamShortWindowAbsence(data, quota) : null;

(plus the withWhamShortWindowAbsence import in both auth-api files)

Local verification on 2.94.0 with the bundled Bun 1.4.4, bun test ./short-absence.test.ts with OPENCODEX_HOME pointed at a temp dir: 3 pass, 0 fail. The three cases:

  • The current pool path keeps shortPercent: 100, which reproduces this bug.
  • The patched path clears shortPercent and shortResetAt and keeps weeklyPercent: 0.
  • A Plus-style WHAM response with a 5-hour primary window does not get the marker.

Live check: after reloading the proxy, the first pool probe dropped the stale tuple, and GET /api/codex-auth/quota returned { weeklyPercent: 0, weeklyResetAt, resetCredits } for the upgraded account.

The patch touches auth-api, so I understand a PR would need maintainer-sponsored. I'm happy to open one against dev if this direction looks right.

Reproduction

  1. Add a ChatGPT Plus account to the Codex account pool (not the main account) and use it until its 5-hour window reads 100%.
  2. While that 5-hour window is still open, upgrade the same ChatGPT account to Pro. The next token refresh carries chatgpt_plan_type: "pro" (credential generation 6 → 7 here).
  3. Wait for the next pool WHAM probes. Each one now contains only a weekly window: rate_limit.primary_window is a 7-day window at used_percent: 0, and there is no 5-hour window. All later source: "wham" history samples in codex-quota-cache.json show only weekly 0% with a new reset 7 days after the upgrade.
  4. Look at the account card in the dashboard, or at quotas[<id>] in codex-quota-cache.json. shortPercent: 100, shortObservedAt (the last Plus-era sample) and shortResetAt are still present. updatedAt advances every minute while the short tuple is carried forward unchanged, and the account stays excluded from routing.

The same thing in a unit-level repro against src/codex/quota.ts:

const now = Math.floor(Date.now() / 1000);
const preUpgrade = { shortPercent: 100, shortResetAt: now + 3600, shortWindowSeconds: 18000, weeklyPercent: 18, weeklyResetAt: now + 5 * 86400 };
const proWham = { plan_type: "pro", rate_limit: { allowed: true,
  primary_window: { used_percent: 0, limit_window_seconds: 604800, reset_at: now + 7 * 86400 },
  secondary_window: null } };

setAccountQuotaFromParsed("pool-a", preUpgrade, undefined, undefined, preUpgrade);
const q = parseUsageQuota(proWham);
setAccountQuotaFromParsed("pool-a", q, undefined, undefined, q); // what pool-quota-probe does today
getAccountQuota("pool-a")?.shortPercent; // 100, expected undefined

Version

2.94.0

Operating system

Windows 11 (build 26300)

Provider and model

openai (Codex ChatGPT account pool, Pro plan)

Logs or error output

# codex-quota-cache.json, quotas[<pool account>] ~1.5 h after the upgrade (before the fix)
{"weeklyPercent": 0, "weeklyResetAt": 1793873765, "shortPercent": 100, "shortObservedAt": 1793268611036, "shortResetAt": 1793277412, "shortWindowSeconds": 18000, "resetCredits": 2}

# latest history samples for the same account (all after the upgrade)
observedAt 14:36:40 source=wham gen=7 windows={weekly: 0%}
observedAt 14:37:41 source=wham gen=7 windows={weekly: 0%}
observedAt 14:38:42 source=wham gen=7 windows={weekly: 0%}

Screenshots and supporting files

No response

Redacted configuration

No response

Checks

  • I searched existing issues and documentation.
  • I removed secrets, tokens, account details, request credentials, and personal data.

Activity

  1. added
    bug
    account-pool
    on Oct 29, 2026
  2. added a commit that references this issue on Oct 30, 2026
    ba0556d
  3. lidge-jun commented on Oct 30, 2026

    @lidge-jun
    Owner

    Fixed on dev by #7980, merged as ba0556d. Thanks @SupernovaTitanium for the diagnosis and proposed fix; you are credited as co-author.

    A complete, valid WHAM probe with no 5-hour window now retires a pool account's carried 5-hour tuple, as it already did for main (#6287), so an account upgraded from Plus to Pro is no longer held at "5h 100% · limit reached". Retirement requires a live captured credential writer for that account and credential generation. Partial or header-only observations, invalid or unparseable readings and an explicit allowed: false keep the tuple.

    Closing manually because PRs into dev do not auto-close issues. The fix reaches users with the next release.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    account-poolbug

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions