Repository navigation
Description
Client or integration
Direct HTTP/API client (a desktop widget that called ocx provider quota --json every 60 s during these observations). The same path serves GET /api/provider-quotas.
Area
Proxy and routing (provider quota reports)
Summary
The 5-minute provider quota report cache (CACHE_TTL_MS in quota-wire.ts) is effectively disabled whenever the built-in ChatGPT forward provider is in pool mode and Codex requests are passing through the proxy. Every fetchProviderQuotaReports call therefore re-probes every provider upstream, including Anthropic's rate-limited /api/oauth/usage endpoint.
The cache key includes a digest of the Codex pool accounts' quota, and that digest includes updatedAt. Each proxied OpenAI response refreshes the main account's quota observation, so updatedAt changes every few seconds even when no percent or reset value changes. fetchProviderQuotaReports computes key before probing and commitKey after probing, and only commits when they match. While traffic is flowing they almost never match, so nothing is cached and the next call starts from scratch.
A second effect follows. Because previousCache.key === key is also false, previous is empty. When one provider probe returns null (a transient failure that should keep the last-good row), there is no last-good row to keep, and the provider disappears from the response entirely.
Expected: when only observation timestamps change, the cache commits and is reused for up to CACHE_TTL_MS, and a transient null probe keeps the bounded last-good row as the comments in quota.ts describe.
Reproduction
- Configure the built-in
openaiprovider in forward/pool mode (sohasCodexPoolProvider(config)is true) plus ananthropicOAuth provider. - Keep Codex requests flowing through the proxy (in our case Codex auto-review requests, model
codex-auto-review, several per minute). - Call
ocx provider quota --jsononce per minute and recordgeneratedAt, each report'supdatedAt, and which providers are present. - In parallel, watch
~/.opencodex/codex-quota-cache.json→quotas.__main__.updatedAt.
Observed:
quotas.__main__.updatedAtchanged 9 times between 17:12:05 and 17:13:18 (KST), each about 2 s after anopenai/codex-auto-reviewentry inusage.jsonl(17:12:03, 17:12:08–12, 17:12:25, 17:12:38–40, 17:13:00–02, 17:13:07, 17:13:16). Percent values did not change.- Every minutely response had
generatedAtequal to the request time and a freshopenaiupdatedAt, so no response came from the cache. - Between 16:53 and 16:57, the
anthropicrow was missing from 4 of 5 responses. The account wasHealthyandprovider-account-quota-cache.jsonheld a successful read from 16:58.
Root cause (code references, identical in 2.93.0 and dev 96e0e00)
src/providers/quota/report-cache.ts:157quotaSignatureValue()includesupdatedAt: quota.updatedAt(line 166).src/providers/quota/report-cache.ts:191providerQuotaFromCodexQuota()setsupdatedAttoDate.now()when the stored quota has none, which would also change the signature on every call.src/providers/quota/report-cache.ts:197cacheKeyWithAggregationState()hashes those signatures into the key (|codex-pool:<digest>).src/providers/quota.ts:242computeskeybefore probing.:289computescommitKeyafter probing.:329commits only whencommitKey === key.src/providers/quota.ts:254fast path and:267previousboth requirecurrentCache.key === key, so neither the cache nor the last-good fallback applies.
Suggested fix
- Drop
updatedAtfromquotaSignatureValue()(and avoid theDate.now()fallback reaching the signature). The key would then change only when a presented value changes: percent, reset time, plan, paused, needsReauth or active account. Staleness stays bounded byCACHE_TTL_MSandLAST_GOOD_MAX_AGE_MS. - Optionally, decouple last-good retention from the exact key: keep the previous row for a provider whose probe returned
nullas long as the provider set part of the key (cacheKey(config)) is unchanged.
If updatedAt is in the signature on purpose (for example, so the pooled openai aggregation refreshes after each observation), a coarser freshness bucket or a separate per-provider refresh for openai would avoid re-probing every other provider.
A regression test could call fetchProviderQuotaReports twice with a stub Anthropic probe, advance only the main Codex quota updatedAt between the two calls, and assert that the second call makes no upstream probe and still returns the anthropic row.
Version
@bitkyc08/opencodex 2.93.0 (installed). The same code is on origin/dev at 96e0e00 (2026-10-29).
Operating system
Windows (DisplayVersion 26H2)
Provider and model
anthropic (OAuth, /api/oauth/usage) and openai (built-in ChatGPT forward, pool mode)
Logs or error output
# service.log has no quota-probe entries: probeAnthropicUsageQuota returns { quota: null, failure } without logging.
# The HTTP status of the failed Anthropic usage reads is therefore not confirmed (429 suspected).Redacted configuration
{
"providers": {
"openai": { "adapter": "openai-responses", "authMode": "forward" },
"anthropic": { "adapter": "anthropic", "authMode": "oauth" },
"xai": { "adapter": "openai-chat", "authMode": "oauth" },
"google-antigravity": { "adapter": "google", "authMode": "oauth" }
}
}Checks
- I searched existing issues and documentation. (Searched "quota cache key updatedAt", "cacheKeyWithAggregationState", "quota re-probe", "quota anthropic usage 429"; related but different: Main-account hard lock never releases when the blocking 5h window stops being observed #6244, [Bug] Anthropic pool: Retry-After-sourced cooldowns do not recover after a fresh usage read proves headroom (plan upgrade / window reset) #6989.)
- I removed secrets, tokens, account details, request credentials, and personal data.
Activity
fix(providers): keep the observation clock of an exhausted reset-less…
test(providers): restamp the #7956 cases with a controlled clock
fix(providers): keep the quota report cache when pool readings are on…
lidge-jun commentedon Oct 30, 2026
Fixed on
devby #7992, merged as 8063be2. Thanks @Caesar7812 for the precise root-cause report.The Pool part of the provider quota report cache key no longer contains each account's raw
updatedAt. It carries whether the reading is fresh or stale, so timestamp-only restamps from proxied Codex traffic no longer miss the cache. Reports are served from the cache for up to its 5-minute TTL, and a transient probe failure (for example Anthropic's/api/oauth/usage) keeps the bounded last-good row instead of dropping the provider. Real value changes still invalidate the cache, as do pause, reauth and active-account changes and a fresh-to-stale transition. One clock stays in the key:shortObservedAtfor an exhausted 5-hour window with no reset time, because that clock alone decides whether the window still blocks. A displayed per-accountupdatedAtcan lag by up to the cache TTL.Closing manually because PRs into
devdo not auto-close issues. The fix reaches users with the next release.