[bug] forecast --live marks working accounts as unavailable
Summary
codex-multi-auth forecast --live reports both configured accounts as unavailable due to runtime skip: rate-limited, even though Codex continues to execute requests successfully.
The diagnostic output says the accounts are ready on disk but unavailable in runtime state, which appears to be a false-positive runtime availability check.
Reproduction
- Configure multiple accounts with codex-multi-auth.
- Run:
codex-multi-auth forecast --live - Run:
codex-multi-auth doctor --fix - Observe that both accounts are marked as unavailable.
- Run a normal Codex prompt and verify that Codex still responds successfully.
Expected Behavior
If Codex requests can still be executed successfully, accounts should not be reported as unavailable.
Actual Behavior
forecast --live reports:
Best-account preview (2 account(s), model gpt-5.5, live check on)
Result: 0 ready now | 0 waiting | 2 unavailable | 0 high risk
1. Account 1 [current] | unavailable | medium risk (45)
runtime skip: rate-limited; primary quota 2% used; secondary quota 27% used
quota: 5h 98% | 7d 73%
2. Account 2 | unavailable | medium risk (50)
runtime skip: rate-limited; primary quota 1% used; secondary quota 27% used
quota: 5h 99% | 7d 73%
Note: All accounts are blocked or exhausted. Wait for a reset, clear the block, or run `codex-multi-auth login` to add a fresh account.
doctor --fix reports:
Doctor diagnostics
Summary: 16 ok, 2 warnings, 0 errors
✓ storage-file: Account storage file found
✓ storage-readable: Storage file is readable
✓ codex-auth-file: Codex auth file found
✓ codex-auth-readable: Codex auth file is readable
✓ codex-config-file: Codex config file found
✓ codex-auth-store: Codex auth storage is set to file
✓ codex-cli-state: Codex CLI state loaded
✓ accounts: Loaded 2 account(s)
✓ active-index: Active index is valid (1)
✓ enabled-accounts: 2 enabled / 0 disabled
✓ duplicate-refresh-token: No duplicate refresh tokens detected
✓ duplicate-email: No duplicate emails detected
✓ placeholder-email: No placeholder emails detected
✓ refresh-token-shape: Refresh token format looks normal
✓ recommended-switch: Current account aligns with forecast recommendation
! forecast-runtime-alignment: 2 account(s) look ready on disk but unavailable in runtime state
account 1: runtime skip: rate-limited
account 2: runtime skip: rate-limited
✓ active-selection-sync: Manager active account and Codex active account are aligned
! auto-fix: Applied 1 fix(es)
Auto-fix actions (applied):
- Synced manager active account into Codex auth state
Additional Evidence
Immediately after forecast --live reported all accounts as unavailable, I ran:
codex "Reply only with: codex works"
and received:
text codex works
This suggests the runtime availability check is more restrictive than actual Codex request execution.
Environment
- codex-cli: 0.136.0
- codex-multi-auth: 2.2.1
- Node.js: v26.0.0
- macOS: 26.4.1
Compliance Confirmation
- [x] I am using this project for personal development workflows.
- [x] This report does not request policy bypasses or prohibited usage.
- [x] I removed any secrets/tokens from this report.
Additional context: I originally encountered this issue on version 2.2.0 and upgraded to 2.2.1 before opening this report.
The behavior is unchanged after the upgrade. forecast --live still reports all accounts as unavailable (runtime skip: rate-limited), while Codex continues to execute prompts successfully.
So this does not appear to be a regression introduced in 2.2.1 and upgrading did not resolve the issue.
Coding Plan
Summary
- localized fix in
lib/forecast.tsoverlay application block (~lines 256-274) - cross-reference time-bounded overlay reasons (
"rate-limited","cooling-down:...") with disk state before marking unavailable - ignore stale overlay when disk state shows no active rate-limit or cooldown
- add regression tests in
test/forecast.test.tsfor the stale-overlay scenario—this gap was explicitly noted in exploration findings
Design Choices
Design Choice 1: should we also clear stale skip reasons on successful requests in the proxy?
Options Considered:
- make forecast overlay application time-aware (defensive, localized fix)
- clear account skip reason on successful request in proxy (proactive cleanup)
- both approaches for defense in depth
Chosen Option: 1
Rationale: option 1—the forecast's job is to report accurate availability, and it has access to disk state to verify if overlay reasons are stale. this is the minimal fix that directly addresses the reported bug without touching the proxy's success path.
💡 User Tips
Regenerate the plan with different choices with @coderabbitai <feedback>.
Implementation Steps
Phase 1: Make Forecast Overlay Time-Aware for Rate-Limited Reasons
the overlay application at lib/forecast.ts:256-274 unconditionally marks accounts unavailable when overlayReason exists. for time-bounded reasons like "rate-limited", we should verify the condition is still active before applying.
Task 1: Add Time-Bounded Overlay Validation in evaluateForecastAccount
before applying the "rate-limited" overlay reason, cross-reference with disk state to check if the rate-limit is actually still active.
- in
lib/forecast.tsaround lines 256-274, modify the overlay application block - when
overlayReason === "rate-limited", check ifgetRateLimitResetTimeForFamily(account, now, "codex")returns null (no active rate limit on disk) - also verify
account.coolingDownUntilis not in the future (no active cooldown) - if both disk-state checks show no active time-bounded condition, skip applying the stale overlay reason
- if the overlay reason is NOT time-bounded (e.g.,
"circuit-open","token-exhausted","policy-blocked"), continue applying it unconditionally - the check should only apply to
"rate-limited"overlay reason since that's the one backed byrateLimitResetTimesdisk state
Task 2: Handle cooling-down Overlay Reason Similarly
the overlay can also contain "cooling-down:..." reasons that are time-bounded.
- when
overlayReason?.startsWith("cooling-down:"), cross-reference withaccount.coolingDownUntil - if
coolingDownUntilis null or<= now, the overlay reason is stale—skip applying it - this follows the same pattern as the rate-limited fix
🤖 Prompt for AI agents
modify the overlay application block in `lib/forecast.ts:256-274` to make
time-bounded overlay reasons validate against disk state before marking an
account unavailable.
- for the `overlayReason === "rate-limited"` case:
- call `getRateLimitResetTimeForFamily(account, now, "codex")` — if it returns
null, no active rate limit exists on disk
- also check that `account.coolingDownUntil` is null or `<= now`
- if both checks pass (no active disk-state condition), skip applying the stale
overlay reason entirely
- for the `overlayReason?.startsWith("cooling-down:")` case:
- check `account.coolingDownUntil` — if null or `<= now`, the overlay is stale,
skip applying it
- non-time-bounded reasons (`"circuit-open"`, `"token-exhausted"`,
`"policy-blocked"`) must continue to be applied unconditionally — do not change
their logic
- flag any concurrency risk: disk state is read at overlay application time;
ensure `now` is a consistent timestamp passed through rather than re-evaluated
mid-function
Phase 2: Add Regression Tests
the exploration confirms no existing test covers the scenario where overlay says rate-limited but disk state shows the limit has expired.
Task 1: Add Test for Stale Rate-Limited Overlay
add test cases in test/forecast.test.ts covering the new time-aware overlay logic.
- add test: overlay has
accountSkipReasons: { "0": "rate-limited" }, butaccount.rateLimitResetTimesis empty or all entries are in the past → account should NOT be marked unavailable from overlay - add test: overlay has
"rate-limited", ANDrateLimitResetTimes.codexis in the future → account SHOULD be marked unavailable (overlay is valid) - add test: overlay has
"cooling-down:...", butcoolingDownUntilis in the past → overlay should be ignored - add test: overlay has
"circuit-open"→ should still mark unavailable unconditionally (not time-bounded)
Task 2: Verify Edge Cases
ensure the fix handles edge cases correctly.
- test case: overlay has
"rate-limited", disk hasrateLimitResetTimeswith keys like"codex:5h"in the future → overlay should still apply (secondary rate-limit active) - test case: no overlay reason present → behavior unchanged
- test case:
overlayReason === "already-attempted"→ still ignored as before (line 265 already handles this)
🤖 Prompt for AI agents
add regression tests in `test/forecast.test.ts` targeting the stale-overlay
scenarios—these were explicitly missing per codebase exploration.
- **stale rate-limited overlay tests:**
- construct an account with `accountSkipReasons: { "0": "rate-limited" }` and
`rateLimitResetTimes` empty or all timestamps in the past → assert account is
NOT marked unavailable due to overlay
- construct an account with `accountSkipReasons: { "0": "rate-limited" }` and
`rateLimitResetTimes.codex` set to a future timestamp → assert account IS marked
unavailable
- **stale cooling-down overlay tests:**
- construct an account with `overlayReason` matching `"cooling-down:..."` and
`coolingDownUntil` in the past → assert overlay is ignored
- **non-time-bounded overlay tests:**
- construct an account with `overlayReason === "circuit-open"` → assert account
is still marked unavailable unconditionally
- **edge case tests:**
- overlay `"rate-limited"` with a future `"codex:5h"` key in
`rateLimitResetTimes` → overlay still applies
- no overlay reason → behavior unchanged
- `overlayReason === "already-attempted"` → still ignored per existing logic at
`lib/forecast.ts:265`
- flag: missing windows edge cases around timestamp comparison if `Date.now()`
resolution differs — ensure tests use injected/mocked `now` values, not live
clock
Research
the forecast system has two layers: disk state (rateLimitResetTimes, coolingDownUntil in account storage) which is time-aware, and runtime overlay (accountSkipReasons in runtime-observability.json) which is not. the disk-state checks in lib/runtime/account-status.ts:31 properly skip expired entries, but the overlay application in lib/forecast.ts:256-274 unconditionally marks accounts unavailable when any overlay reason exists. the overlay is only cleared via explicit recordRuntimeReset() or overwritten on subsequent pool exhaustion—successful requests don't clear it.
🚀 Next Steps
🤖 All AI agent prompts combined
Task: 1
modify the overlay application block in `lib/forecast.ts:256-274` to make
time-bounded overlay reasons validate against disk state before marking an
account unavailable.
- for the `overlayReason === "rate-limited"` case:
- call `getRateLimitResetTimeForFamily(account, now, "codex")` — if it returns
null, no active rate limit exists on disk
- also check that `account.coolingDownUntil` is null or `<= now`
- if both checks pass (no active disk-state condition), skip applying the stale
overlay reason entirely
- for the `overlayReason?.startsWith("cooling-down:")` case:
- check `account.coolingDownUntil` — if null or `<= now`, the overlay is stale,
skip applying it
- non-time-bounded reasons (`"circuit-open"`, `"token-exhausted"`,
`"policy-blocked"`) must continue to be applied unconditionally — do not change
their logic
- flag any concurrency risk: disk state is read at overlay application time;
ensure `now` is a consistent timestamp passed through rather than re-evaluated
mid-function
===============================================================================
Task: 2
add regression tests in `test/forecast.test.ts` targeting the stale-overlay
scenarios—these were explicitly missing per codebase exploration.
- **stale rate-limited overlay tests:**
- construct an account with `accountSkipReasons: { "0": "rate-limited" }` and
`rateLimitResetTimes` empty or all timestamps in the past → assert account is
NOT marked unavailable due to overlay
- construct an account with `accountSkipReasons: { "0": "rate-limited" }` and
`rateLimitResetTimes.codex` set to a future timestamp → assert account IS marked
unavailable
- **stale cooling-down overlay tests:**
- construct an account with `overlayReason` matching `"cooling-down:..."` and
`coolingDownUntil` in the past → assert overlay is ignored
- **non-time-bounded overlay tests:**
- construct an account with `overlayReason === "circuit-open"` → assert account
is still marked unavailable unconditionally
- **edge case tests:**
- overlay `"rate-limited"` with a future `"codex:5h"` key in
`rateLimitResetTimes` → overlay still applies
- no overlay reason → behavior unchanged
- `overlayReason === "already-attempted"` → still ignored per existing logic at
`lib/forecast.ts:265`
- flag: missing windows edge cases around timestamp comparison if `Date.now()`
resolution differs — ensure tests use injected/mocked `now` values, not live
clock
💡 Iterate on the plan with:
`@coderabbitai` <feedback>
Example Feedback
- `@coderabbitai` You can skip phase 3. Add a simple unit test case for phase 2.
- `@coderabbitai` For design choice 1 go ahead with option 3 and replan.
💬 Have feedback or questions? Drop into our discord!
ndycode/codex-multi-auth#120 - feat(cli): add codex auth best account switching [merged]
ndycode/codex-multi-auth#337 - fix report live token freshness handling [merged]
ndycode/codex-multi-auth#480 - Fix runtime rotation pool diagnostics [merged]
ndycode/codex-multi-auth#487 - fix(runtime): surface skip reason in pinned 503 (⚠️ Possible Duplicate Issue(s)
🔗 Related PRs
#486) [merged]
ndycode/codex-multi-auth#502 - fix(quota): detect unsupported Codex model from detail shape (#501) [merged]
📝 Issue Planner
Check the box below or use the @coderabbitai plan command to generate an implementation plan and prompts that you can use with your favorite coding assistant.
- [ ] Create Plan
🧪 Issue enrichment is currently in open beta.
To disable automatic issue enrichment, add the following to your .coderabbit.yaml:
issue_enrichment:
auto_enrich:
enabled: false
💬 Have feedback or questions? Drop into our discord!
Fixed in 2.2.2 (now on npm latest).
Root cause: the runtime overlay in runtime-observability.json persisted a per-account skip reason (rate-limited, cooling-down, token-exhausted) on pool exhaustion and was only cleared by an explicit runtime reset — never on a subsequent successful request. After the underlying window expired, forecast/doctor kept reporting the account unavailable even though the proxy (which re-derives skip reasons per request) still routed to it successfully.
Two-part fix:
forecastnow cross-references time-bounded overlay reasons (rate-limited,cooling-down) against disk state and ignores stale ones.- the proxy clears an account's persisted skip reason on a successful request, which covers
token-exhausted(no time-based expiry for the forecast to validate against).
doctor's forecast-runtime-alignment warning shares the forecast evaluation, so it clears too.
Please npm i -g codex-multi-auth@latest and confirm forecast --live + doctor no longer flag your working accounts. Reopen if it persists.