Skip to content

[Feature]: reset-near weighted allocation for Codex and Anthropic account pools #8177

Closed

Description

@vibewriter-hand

Area

Authentication and account pool

What are you trying to accomplish?

We want new sessions to use quota that resets soon without concentrating every new session on one account. Among eligible accounts, the account whose weekly reset is closest should receive about half of new-session assignments, while the other eligible accounts share the remaining half by round-robin. Existing session bindings must stay on their account.

What prevents this today?

2.97.0 has reset-first for the Codex pool and generic OAuth pools, but the Anthropic pool rejects it. reset-first is also all-or-nothing: it always prefers the earliest reset account, so one account can receive all new sessions. There is no weighted half allocation.

  • Anthropic strategy parsing accepts only quota, round-robin, and fill-first (src/oauth/pool-kernel.ts:31-43, src/server/management/oauth-account-routes.ts:686-694).
  • Codex reset-first is implemented at src/codex/routing/selection.ts:535.
  • Generic OAuth reset-first is implemented at src/oauth/generic-account-failover.ts:358.
  • The gap is the weighted mix and Anthropic support.

We currently run a local patch for this behavior and want to retire it when upstream provides an equivalent opt-in strategy.

What should OpenCodex do?

Add an opt-in reset-near-weighted strategy for Codex and Anthropic account pools. For each new session, consider accounts with:

  • a weekly reset within 24 hours,
  • 5-hour usage below 60%,
  • weekly remaining above 2%,
  • usage evidence fresh within 15 minutes.

The earliest-reset eligible account gets weight N-1 (about half of new assignments); the other eligible accounts share the rest by round-robin. If no account qualifies, or evidence is missing or stale, fall back to equal round-robin. Preserve existing bindings and never move a healthy bound session. Keep existing cooldown, pause, reauthentication, and model/priority rules. Do not use missing, future-dated, or stale quota data.

Example usage or interface

ocx account pool codex --strategy reset-near-weighted
ocx account pool anthropic --strategy reset-near-weighted
{
  "providers": {
    "codex": { "accountPool": { "strategy": "reset-near-weighted" } },
    "anthropic": { "accountPool": { "strategy": "reset-near-weighted" } }
  }
}

Alternatives or workarounds

reset-first for Codex (#4079, #7167) consumes the earliest reset but can concentrate all new sessions on one account. Equal round-robin ignores reset urgency. Manual account switching is the current workaround.

Additional context

Related: #3376 (quota history and reset ordering umbrella), #4079 (Codex reset-first), #7167 (generic reset-first), #7234 (closed quota-weighted draft). This request is a weighted half allocation, not pure reset-first or remaining-quota scoring. We can provide the local patch and test evidence if useful.

Checks

  • I searched existing issues and documentation.
  • This request describes a concrete OpenCodex workflow rather than merely naming a desired technology.
  • I removed secrets and personal data.

Activity

  1. github-actions commented on Nov 5, 2026

    @github-actions
    Contributor

    Automated translation bookkeeping — detected language: English.

  2. added
    enhancement
    account-pool
    on Nov 5, 2026
  3. vibewriter-hand commented on Nov 5, 2026

    @vibewriter-hand
    ContributorAuthor

    Implementation draft: #8180. The PR is draft because the auth/management surface requires maintainer sponsorship; local typecheck and focused routing tests pass.

  4. Ingwannu commented on Nov 7, 2026

    @Ingwannu
    Owner

    Confirmed on dev (aaa3c20f3f):

    • The Anthropic pool accepts only quota, round-robin and fill-first (src/oauth/pool-kernel.ts:30).
    • reset-first exists only for the Codex pool (src/codex/routing/selection.ts:535) and generic OAuth pools (src/oauth/generic-account-failover.ts:358).
    • No pool has a weighted mix.

    This fits under the #3376 reset-scheduling umbrella.

    Scope: a new strategy needs an owner decision.

    • Anthropic. That pool is deliberately narrower than Codex because Anthropic OAuth is terms-sensitive (header comment of src/oauth/anthropic-routing.ts). Adding reset-driven scheduling there is a policy change, not just a new value for the parser to accept.
    • Codex. The Codex half is a smaller step because reset-first already exists there.

    Design questions:

    1. Which reset counts for Anthropic? The shared weekly_all window, or a model-scoped row (e.g. Fable) when the request targets that family? This depends on the open [Bug]: Inactive weekly_scoped (Fable) limits are still dropped after #8088, hiding real per-account Fable usage from the pool #8110 decision about inactive scoped rows.
    2. Freshness. Anthropic usage probes are rate-limited and mostly follow the active account. A 15-minute freshness requirement may leave most accounts on the round-robin fallback most of the time. What does your local data show?
    3. Interaction with stickyLimit. The weighting applies per new session, so the "about half" target needs a defined interaction with stickyLimit > 1.
    4. Fixed or configurable thresholds? Fixed 24h / 60% / 2% / 15-minute thresholds are easier to review.

    #8180 (draft) implements this. It changes pool strategy parsing and the management routes, so it needs the completed readiness checklist and a maintainer review first. This comment does not approve it.

  5. lidge-jun commented on Nov 19, 2026

    @lidge-jun
    Owner

    Implemented by #8180, merged into dev as 7d9de0d. The Codex and Anthropic pools have a new weighted strategy. The eligible account whose quota resets soonest gets about half of new-session assignments, and the remaining accounts share the rest by round-robin. Existing session bindings stay on their account.

    Weighted placement only uses fresh five-hour and weekly quota evidence that belongs to the current credential. When that evidence expires, routing falls back to plain round-robin. The dashboard settings and the English and Spanish docs describe the strategy.

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-poolenhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions