v1.3.0: fix all-accounts Usage API 403 (deprecated /wham/usage → /codex/usage)#14
Open
Mr-V1be wants to merge 1 commit intoguard22:mainfrom
Open
v1.3.0: fix all-accounts Usage API 403 (deprecated /wham/usage → /codex/usage)#14Mr-V1be wants to merge 1 commit intoguard22:mainfrom
Mr-V1be wants to merge 1 commit intoguard22:mainfrom
Conversation
Fix "Usage API returned 403" across all accounts and recover rotation health.
Root cause: OpenAI deprecated /backend-api/wham/usage for Codex OAuth tokens
(returns 403 for every token, including active ChatGPT Pro). The plugin then
marked every account as authInvalid and stopped routing ("No available
accounts after filtering").
Changes:
- usage-limits: switch to /backend-api/codex/usage (live endpoint) with the
`originator: codex_cli_rs` header to bypass Cloudflare default gating.
- usage-limits: retry up to 3 times with backoff on Cloudflare HTML 403
challenges (per-IP bursts trigger those; proper JSON errors are not retried).
- usage-limits: split 401 vs 403 classification — 403 falls through to the
probe path instead of marking the token as invalid.
- limits-refresh: auto-clear authInvalid / authInvalidatedAt on any
successful refresh so stale flags from earlier 403s recover automatically.
- refresh-queue: default concurrency lowered 20 -> 5 to stay below
Cloudflare's /codex/usage per-IP threshold. The
OPENCODE_MULTI_AUTH_REFRESH_QUEUE_CONCURRENCY env override is unchanged.
- probe-limits: honor CODEX_CLI_BIN env var so operators can point the
spawn probe at a newer `codex` binary.
- Rebuild dist/.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Live fix for "Usage API returned 403" showing up on every account in the dashboard, plus the cascading "No available accounts after filtering" loop in OpenCode's rotation.
Root cause
OpenAI deprecated
GET /backend-api/wham/usagefor Codex-scope OAuth tokens. It now returns 403 for every token — including active ChatGPT Pro/Business plans that chat fine through/codex/responses. The plugin interpreted those 403s as "auth invalid", flippedauthInvalid: trueon every account, and the rotation layer then filtered all of them out → 503noEligibleAccounts.Verified by direct curl with the same token that routes chat successfully:
The response schema on
/codex/usageis a superset of what this plugin already parses (rate_limit.primary_window/secondary_windowwithused_percent,reset_at, etc.) — no parser changes required.Changes
/backend-api/codex/usage(live endpoint). Addoriginator: codex_cli_rsheader — without it Cloudflare intermittently returns an HTML challenge instead of JSON.authInvalid/authInvalidatedAton any successful refresh, so stale flags set by the pre-fix 403 storm recover themselves on the next refresh./codex/usage; 5 completes a full 22-account refresh in a few seconds with zero challenges.OPENCODE_MULTI_AUTH_REFRESH_QUEUE_CONCURRENCYstill overrides.CODEX_CLI_BINenv var so operators can point the spawn probe at a newercodexbinary (e.g. the VS Code-extension build that already has HTTP fallback when/responsesWSS hits Cloudflare).Upgrade notes
None required. Drop-in, behavior-preserving for accounts that were already healthy. Operators who bumped concurrency past 20 via env var are unaffected (cap unchanged at 20).
After installing, the dashboard's next Refresh limits (all) will clear every stale
authInvalid: trueflag set by pre-fix 403 classifications. Accounts that were mistakenly sidelined will re-enter rotation automatically.Test plan
npm run lint(tsc --noEmit) — cleannpm run build— dist regenerated/wham/usage403,/codex/usage200 with the same tokenprimary_window.used_percentsurfaced for every account