[Feature]: Adaptive idle 5-hour quota staggering for N ChatGPT Plus accounts

Aperta
#7,206 12 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 1 giorno

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
12/100
Tipo di issue
Funzionalità
Chiarezza
Da chiarire
Stato di attività
Attiva
Stack tecnologico
typescript

Direzione di ricerca

This is a design proposal, not a scoped task. The payload names no source files or tests. Start with the maintainer update on #3376 and the existing per-account activation work in #2969 and #6018, and confirm which quota-history and reset-aware selection pieces already exist. A useful first step is agreeing with the maintainer on scope, since the request asks whether this should be an independent follow-up. Done would mean an accepted design and a split into smaller tasks.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

account-pool enhancement needs-design
Area

Authentication and account pool

What are you trying to accomplish?

I use multiple ChatGPT Plus accounts with Codex through the OpenCodex account pool. Each eligible account can have a five-hour quota window. My goal is to reduce the periods in which every account is simultaneously waiting for its short-window quota to refresh, especially after bursts of Codex work.

This request is for an opt-in, pool-level, idle-aware quota activation policy that works for any number N ≥ 2 of eligible Plus accounts, not just an A/B rotation. It should observe real upstream windows, start unused eligible windows at deliberately staggered times during idle periods, and gradually repair timing drift after real use changes their anchors.

The primary target is multi-account ChatGPT Plus, with extensibility to other account plans only when the provider's observed window semantics make it safe and meaningful.

This feature does not request more upstream quota, replacement of OpenCodex routing, or a hard requirement that users wait for a synthetic schedule.

What prevents this today?

OpenCodex already has bounded quota history, Codex reset-first selection and opted-in per-account scheduled activation (see #3376 / maintainer update). Those are useful primitives, but are not the same as coordinating the five-hour activation phases of an entire pool while idle.

Two failure modes of naive implementations:

  1. Independent per-account reactivation re-synchronizes windows. Even if A first starts at 00:00 and B at 02:30, independent auto-activation may start both at an inconvenient common boundary in a subsequent round.
  2. Static A → B → A rotation breaks under real usage. If A starts at 00:00 but exhausts early and real work reaches B at 01:00 (before B's planned 02:30 activation), B may now reset at about 06:00 instead of 07:30. A's next reset around 05:00 and B's around 06:00 are now clustered. A fixed repeating schedule does not repair that drift. Blocking the user's 01:00 request would be worse.

For N=3/4/5+, independently trying to hold fixed slots becomes even more fragile as accounts join/leave the eligible cohort, weekly quotas run out, and real work changes individual window anchors.

What should OpenCodex do?

A. Active mode — real work always wins

  • Real user / agent traffic passes through immediately, retaining existing routing, affinity, priorities, threshold switching, cooldowns, and failover. Never delay, reject, or re-route otherwise valid real work solely to maintain phase spacing.
  • Suspend/cancel conflicting pending synthetic idle-activation jobs. Treat a real request that starts a window as the authoritative event, not the previously scheduled warmup time.
  • Observe actual 5-hour and weekly quota states/reset deadlines from the upstream account; preserve the observed state for later rescheduling. Provide manual pause for use through clients not visible to the proxy.

B. Idle mode — coordinated, best-effort staggered pre-activation

  • Enter after there are no active proxied tasks/streams and a configurable quiet period (suggested default: 30 minutes). Reset the idle timer upon new real activity.
  • A single pool-level coordinator owns background activation for accounts opting into this policy. Per-account scheduled auto-activation must not independently fire a conflicting warmup while pool-level staggering is enabled.
  • Count only eligible, authenticated, healthy accounts with supported five-hour windows; exclude paused, unknown, unsupported, weekly-exhausted, or otherwise unusable accounts from the active five-hour cohort. Recompute N whenever eligibility changes.
  • For the eligible homogeneous five-hour cohort, aim to distribute future verified reset/activation phases approximately evenly around the 300-minute cycle. Target adjacent phase gap: 300/N minutes (two accounts: 150 min; three: 100 min; four: 75 min; five: 60 min). This is an optimization target, not a fixed switching timer or a promise of guaranteed availability.
  • Issue a minimal permitted activation request only for an unstarted / newly eligible window if its activation semantics are supported and verified. If a window is already active, do not send a redundant warmup.

C. Dynamic phase realignment after genuine usage

  • When real traffic starts a window earlier/later than predicted, cancel stale warmups and recalculate from authoritative observed reset times, rather than assuming historical slot times still govern.
  • If the pool's next reset boundaries bunch together, gradually defer only future idle-only activations to spread the phase gaps again, subject to a configurable maximum deferral (suggested initial cap: 60 minutes per proposed adjustment, adjustable/disableable). Do not attempt to move an already anchored upstream window.
  • A real request during a deferral must proceed immediately; the pending synthetic job is cancelled and the next plan is recomputed. Missed jobs after a restart/sleep are evaluated afresh, not replayed in a burst.
  • If the provider state is unknown, activation is unverified, the proposed change has no clear benefit, or the capacity cost of deferral exceeds its likely benefit, skip the adjustment. Best-effort/no-op is acceptable.

D. State, safety, and observability

  • Distinguish UNSTARTED, ACTIVE, EXHAUSTED, ELIGIBLE_AFTER_RESET, and UNKNOWN. used_percent=0 is insufficient evidence that an idle rolling window is already anchored.
  • Persist a stable intended schedule, per-account window generation/activation marker, last verified reset observation and reasons for decisions. Do not repeatedly calculate a desired slot from reset_at ≈ now + 300min on an unstarted window: that deadline may slide and starve nonzero slots forever (see codex-lb #1976).
  • Make requests idempotent per window generation, bounded in frequency/retries and safe on ambiguous 200/429/401 outcomes. Verify startup with upstream state; do not assume a local account switch starts a provider quota window.
  • Enforce upstream five-hour and weekly limits. Do not let weekly-only or incompatible accounts occupy five-hour staggering slots.
  • New behavior must be explicitly opt-in and disabled by default, and comply with provider-permitted operations. Expose any tokens/quota consumed by synthetic warmup; do not assume it is free.
  • Dashboard/CLI should show active vs idle scheduler mode; number of eligible accounts N; observed account reset times; next planned background activation; last real-use interruption; and reasons for skipping/deferring.
Example usage or interface

Illustrative configuration only (not existing OpenCodex keys):

{
  "providers": {
    "codex": {
      "accountPool": {
        "idleQuotaStaggering": {
          "enabled": true,
          "targetPlan": "plus",
          "idleAfterMinutes": 30,
          "spacing": "adaptive-even",
          "maxIdleDeferralMinutes": 60,
          "realTrafficAlwaysWins": true
        }
      }
    }
  }
}

For N eligible Plus accounts:

Eligible N Ideal adjacent phase gap
2 150 minutes
3 100 minutes
4 75 minutes
5 60 minutes

Two-account interference example (illustrative, assuming first-use-anchored windows):

Time Real event Correct scheduling behavior
00:00 A's window starts (next reset ~05:00) Record actual A window
01:00 A is exhausted, real Codex work reaches B before planned 02:30 warmup Serve immediately; B's real window starts (next reset ~06:00); cancel the 02:30 synthetic job
03:00 Work ends Start quiet-period countdown
~05:00 A is eligible for new window If idle and policy permits, consider A activation
~06:00 B is eligible for new window If idle, defer B's synthetic activation modestly when beneficial to restore spacing
06:15 User requests B during deferral (if this happens) Serve immediately, cancel synthetic job and recalculate

With three or more accounts, the same procedure computes gaps over the actual eligible cohort instead of assuming only A and B.

Alternatives or workarounds
  • Independent automatic activation: simple but may repeatedly synchronize all accounts after later resets.
  • Fixed five-hour A/B rotation: fails as soon as real requests start one account at a different time; not generalizable to N accounts.
  • Pure reset-first routing: useful for choosing accounts for real work, but does not keep background activation phases distributed.
  • Manual staggered warmups: operationally tedious, easily disrupted by real traffic and restarts.
  • No synthetic activations: safest baseline, should remain the default; however, it cannot proactively establish useful staggered windows during idle time.
Acceptance criteria
  • With 2, 3, and 5+ eligible Plus accounts, an idle pool plans distinguishable 5-hour slots without unnecessary simultaneous warmups; count N is dynamic.
  • A real request starts account B before its planned slot: no request-path delay, B's synthetic job is cancelled, and the scheduler adapts to B's actual reset deadline.
  • Across at least two later cycles, the scheduler does not unknowingly fall back into synchronized activation because of independently firing per-account workers.
  • Active traffic during a scheduled/deferred warmup, or account eligibility change, triggers safe cancellation and replanning.
  • No invalid slot calculation or indefinite starvation for an unstarted window with sliding reset timestamps; weekly-only accounts never distort the short-window cohort.
  • Restart/sleep recovery, stale metadata, ambiguous activation success, 401/429, weekly exhaustion, and provider-unsupported behavior all fail safely without burst duplicate requests.
  • Background warmups are opt-in, bounded, measurable (quota/token cost), and do not interfere with ongoing sessions.
  • Evaluate against current behavior using cumulative time when all eligible accounts are unusable, ability to serve real requests, total warmup cost, and user-visible latency. Merely producing evenly spaced planned timestamps is not success; verify actual upstream windows.
  • Existing automatic activation / routing behavior remains unchanged when the new mode is disabled.
Additional context

This is a separately trackable extension of the broader quota scheduling umbrella #3376, not a request to reimplement its existing primitives. An earlier detailed proposal/comment is at https://github.com/lidge-jun/opencodex/issues/3376#issuecomment-6197367914 .

Related OpenCodex issues: #2969 (per-account activation), #2874 and #4079 (reset-aware selection), #6018 (persisted activation deadlines). External design/bug references:

Maintainer question: Would an optional pool-level Adaptive Idle Quota Staggering policy be a good independently scoped follow-up to #3376, reusing the existing quota history, routing, and auto-refresh components?

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.
Lingua principale
TypeScript
Stelle
16.9k
Fork
1.3k
Merge medio
1g 4h
PR unite (30g)
814

Preparare l'ambiente

Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di lidge-jun/opencodex

Tutte le issue di lidge-jun/opencodex

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.