Repository navigation
fix(capacity): count uncalibrated Codex plans instead of excluding them #3198
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,6 +8,28 @@ export const CODEX_CONFIGURED_CAPACITY_WEIGHTS = { | |
| pro: 20, | ||
| } as const; | ||
|
|
||
| /** | ||
| * Weight for a plan the map above has not calibrated. | ||
| * | ||
| * `CodexAccount.plan` is an unrestricted upstream string and cannot be enumerated: the | ||
| * bundled model snapshot alone carries 21 distinct plan names (`edu_plus`, `finserv`, | ||
| * `k12`, `quorum`, `self_serve_business_usage_based`, …) against the five listed above. | ||
| * Treating an unlisted plan as unknown dropped the account from the estimate entirely and | ||
| * reported "incomplete coverage" — which is how a Business seat upgraded to Premium | ||
| * disappeared from its own capacity report (#3155), and it was already happening to the | ||
| * other sixteen snapshot plans without anyone noticing. | ||
| * | ||
| * `src/codex/quota.ts` reached the same conclusion about the same field: an allowlist is a | ||
| * list of the plans someone remembered. Counting an unfamiliar plan at the baseline seat | ||
| * weight — the value `plus`, `team`, and `business` already carry — under-states a large | ||
| * seat, which is a visibly conservative estimate. Excluding it silently overstates coverage | ||
| * the operator does not have, which is worse. | ||
| * | ||
| * Uncalibrated plans are still counted in `unknownPlanAccounts` so the estimate's | ||
| * uncertainty stays on screen. | ||
| */ | ||
| export const CODEX_DEFAULT_CAPACITY_WEIGHT = 1; | ||
|
|
||
| /** Match the provider-report last-good freshness bound. */ | ||
| export const CODEX_CAPACITY_MAX_QUOTA_AGE_MS = 30 * 60_000; | ||
|
|
||
|
|
@@ -85,11 +107,17 @@ type MutableWindow = { | |
| oldestUpdatedAt: number; | ||
| }; | ||
|
|
||
| function configuredWeight(plan: unknown): number | undefined { | ||
| /** True when this plan has a calibrated weight rather than falling back to the default. */ | ||
| function isCalibratedPlan(plan: unknown): boolean { | ||
| const normalized = codexPlanKey(plan); | ||
| return !!normalized && Object.hasOwn(CODEX_CONFIGURED_CAPACITY_WEIGHTS, normalized); | ||
| } | ||
|
|
||
| function configuredWeight(plan: unknown): number { | ||
| const normalized = codexPlanKey(plan); | ||
| return normalized && Object.hasOwn(CODEX_CONFIGURED_CAPACITY_WEIGHTS, normalized) | ||
| ? CODEX_CONFIGURED_CAPACITY_WEIGHTS[normalized as keyof typeof CODEX_CONFIGURED_CAPACITY_WEIGHTS] | ||
| : undefined; | ||
| : CODEX_DEFAULT_CAPACITY_WEIGHT; | ||
|
Comment on lines
+116
to
+120
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
This fallback reverses the published contract in AGENTS.md reference: AGENTS.md:L343-L344 Useful? React with 👍 / 👎. |
||
| } | ||
|
|
||
| function normalizedPercent(value: unknown): number | undefined { | ||
|
|
@@ -188,7 +216,9 @@ export function aggregateCodexPoolCapacity( | |
|
|
||
| for (const account of accounts) { | ||
| const weight = configuredWeight(account.plan); | ||
| if (weight === undefined) unknownPlanAccounts += 1; | ||
| // Still reported, so the operator can see the estimate is conservative for this seat — | ||
| // but no longer a reason to drop the account from the aggregate (#3155). | ||
| if (!isCalibratedPlan(account.plan)) unknownPlanAccounts += 1; | ||
| if (account.paused) pausedAccounts += 1; | ||
| if (account.needsReauth) reauthAccounts += 1; | ||
| const quota = account.quota; | ||
|
|
@@ -204,7 +234,7 @@ export function aggregateCodexPoolCapacity( | |
| const custom = quota?.customWindows ?? []; | ||
| const hasQuota = hasKnownQuotaWindow(quota); | ||
| if (!hasQuota) missingQuotaAccounts += 1; | ||
| if (account.paused || account.needsReauth || weight === undefined || !quota || !hasQuota || !quotaFresh) continue; | ||
| if (account.paused || account.needsReauth || !quota || !hasQuota || !quotaFresh) continue; | ||
|
|
||
| let contributed = false; | ||
| const contributionKeys = new Set<string>(); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When an uncalibrated account is paused, needs reauthentication, lacks quota, or has stale quota,
unknownPlanAccountsis still incremented before the source excludes it from every window; nevertheless, this component tells the operator that every account in that count "is counted at the baseline seat weight." The coverage-only fixture demonstrates the contradiction withincludedAccounts: 0andunknownPlanAccounts: 1. Track included uncalibrated accounts separately or use wording that does not claim all of them contributed.AGENTS.md reference: gui/AGENTS.md:L9-L10
Useful? React with 👍 / 👎.