Repository navigation
feat(oauth): reset-first strategy for generic OAuth pools (carry #5408) - #7167
Conversation
Generic OAuth pools (Antigravity, xAI, Cursor, Kiro and the rest) can store and run reset-first under pool.kernel: the first attempt and a 429 rotation prefer the non-exhausted account whose weekly (else 5-hour) quota resets soonest, with headroom breaking ties. A passive provider with partial evidence keeps headroom order. The Anthropic kind still refuses it. The first-attempt pick uses the same eligible set as round-robin, so an Antigravity account whose model roster omits the requested model is not chosen. ocx account pool --strategy now accepts reset-first for generic pools as the server already does for ocx account strategy. Carried from #5408 (source head 2db9838). Co-authored-by: agentHits <140916359+agentHits@users.noreply.github.com>
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing: 16
✨ Finishing Touches
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: c50aa7cc0c
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| let rawReset = weekly?.resetAt ?? quota.weeklyResetAt; | ||
| if (rawReset === undefined && provider !== "google-antigravity" && provider !== "anthropic") { | ||
| // Providers without a weekly cadence: prefer an explicitly 5h-labeled window before | ||
| // falling back to first-window order. | ||
| const fiveHour = windows.find(w => /5h|five/i.test(w.label)) ?? windows[0]; | ||
| rawReset = fiveHour?.resetAt ?? quota.fiveHourResetAt; |
There was a problem hiding this comment.
Include monthly rollover evidence in reset-first ranking
When reset-first is enabled for Kiro—or for monthly-only xAI/Cursor quota responses—the strategy silently degenerates to headroom ordering: those quota readers store the known rollover in monthlyResetAt (and Kiro also exposes it through kiroAccountEvidence), but this selector only considers weekly, five-hour, and custom-window timestamps. Consequently every healthy Kiro candidate receives an infinite reset rank in both proactive selection and 429 rotation, so the advertised strategy never prefers the account that actually resets first. Include valid monthly/account-bound reset evidence among the candidate deadlines.
Useful? React with 👍 / 👎.
|
✅ Deterministic PR hygiene checks passed. |
|
Maintainer integration into
|
Summary
Carries the generic reset-first rotation out of #5408 by @agentHits (source head
2db983800a02785250cc3ebed86f399bc772303e), as the first of three stacked slices the earlier review asked for:Generic OAuth pools (Google Antigravity, xAI, Kiro, Cursor and the rest) can now store
reset-firstand, withpool.kernelon, run it. Both the first attempt (while the proactive preference is on) and a 429 rotation prefer the non-exhausted account whose quota resets soonest. That is the requested model family's weekly window when one is reported, otherwise the 5-hour window, with more headroom breaking ties. Exhausted accounts go last. Without quota evidence, or when a passive provider has evidence for only part of the ring, ordering stays on headroom. Withpool.kerneloff, a storedreset-firstis inert, like round-robin and fill-first.Before:
PUT /api/pool/settings {"provider":"google-antigravity","strategy":"reset-first"}returned 400. After: it returns 200 and round-trips. The Anthropic kind still refuses it withstrategy must be one of: quota, round-robin, fill-first, because the Anthropic runtime does not implement it. Ondevthat kind went through the generic parser, so this PR also gives the Anthropic kind its own parser.Changes from the source PR:
eligibleFailoverAccounts+preferKiroModelSupport). In feat(gui): unified provider workspace with pool controls and reset-first rotation #5408 it skipped that check, so a Gemini 4 Argon request could be steered to an Antigravity account whose roster does not list Argon. A new test covers this. It fails against the feat(gui): unified provider workspace with pool controls and reset-first rotation #5408 code (27 pass / 1 fail) and passes here.ocx account pool <generic> --strategy reset-firstis accepted, matching whatocx account strategyalready got from the server. The capability summary, generated skill surface, recipes and CLI reference are updated.providers.<name>.oauthAccountFailover.strategyin the configuration reference, plus the ownership note instructure/transports/inventory.md.Co-authored-by: agentHits 140916359+agentHits@users.noreply.github.com
Independent review round 1 fixed a further Kiro defect: reset-first omitted the account map used to validate Kiro's credential-bound quota evidence. Both proactive selection and refusal rotation now pass the map, so missing reset times retain headroom ordering and exhausted accounts stay last. The regression failed before the fix (27 pass / 1 fail) and passes after it.
Verification
Fresh review runs on macOS arm64 / Bun 1.4.3, with temporary
OPENCODEX_HOMEandCODEX_HOME:bun scripts/test.ts --parallel=1 tests/providers/kiro/kiro-pool-rank.test.ts tests/oauth/oauth-account-quota-rank.test.ts tests/server/account-pool-management-api.test.ts tests/cli/cli-account-policy.test.ts: 185 pass / 0 fail.bun run typecheck,bun run structure:check,bun scripts/file-size-ratchet.ts: pass on this layer.bun scripts/test.ts --parallel=1 tests/server/server-management-auth.test.ts: 47 pass / 0 fail.Checklist