[bug] Weekly-only accounts are benched at 5% remaining by the 5h preemptive threshold (weekly window arrives in the primary slot), even with the 7d threshold set to 0
Summary
For accounts whose only usage window is the weekly one, the weekly window arrives in the primary slot (status shows 7d … 95%/5% / secondary … 0%/100%; the stored snapshot has primary.windowDurationMins: 10080). The preemptive scheduler applies the 5h threshold to the primary slot, so these accounts are benched at 5% weekly remaining even when preemptiveQuotaRemainingPercent7d is set to 0.
Versions
codex-multi-auth 2.26.1 (same code in 2.26.2: dist/lib/preemptive-quota-scheduler.js, dist/lib/runtime-rotation-proxy.js), codex-cli 0.170.0, macOS.
What was observed
CODEX_AUTH_PREEMPTIVE_QUOTA_7D_REMAINING_PCT=0andpluginConfig.preemptiveQuotaRemainingPercent7d: 0were both in effect for the proxy process.- Two accounts stopped receiving traffic the moment their weekly window reached 95% used. After that each of them served exactly one
responsesrequest per hour — and every one of those returned 200 upstream. Nothing upstream was refusing them. - With two of three accounts benched this way the pool degenerated to a single account much earlier than necessary.
Cause
runtime-rotation-proxy.js builds the scheduler with
remainingPercentThresholdPrimary: getPreemptiveQuotaRemainingPercent5h(pluginConfig),
remainingPercentThresholdSecondary: getPreemptiveQuotaRemainingPercent7d(pluginConfig),
and PreemptiveQuotaScheduler.getDeferral compares snapshot.primary.usedPercent with the primary (5h) threshold without looking at how long that window actually is.
Workaround
Also set preemptiveQuotaRemainingPercent5h (or CODEX_AUTH_PREEMPTIVE_QUOTA_5H_REMAINING_PCT) to 0.
Suggested fix
Pick the threshold by the window's duration (e.g. windowDurationMins ≥ 1 day → the 7d setting) rather than by slot, or document that the "5h" setting governs whatever window is reported first.