You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FEATURE]: Cooldown-aware runtime failover on rate limits and temporary provider failures #16867
I have verified this feature I'm about to request hasn't been suggested before.
Describe the enhancement you want to request
I have searched existing issues and could not find the same request.
This is a feature request, not a bug report.
I am opening this issue first for design discussion before any PR.
Problem
OpenCode supports many providers and models, but when a configured model/provider hits a runtime failure such as:
HTTP 429
quota exhausted
temporary provider unavailability
transient timeout
the session may stop instead of trying another configured option.
That interrupts workflows even when the user has other valid providers or models configured.
Proposed solution
Please consider an opt-in, cooldown-aware runtime failover mechanism.
A possible direction:
classify retryable runtime failures such as rate limit, quota exhaustion, temporary unavailable, timeout
put the failing credential/profile/model into cooldown for a short period
retry with another configured profile, model, or provider
surface the failover decision clearly in logs / UI
cap retries to avoid loops
Expected behavior
If the primary model fails with a retryable runtime error:
mark it temporarily unavailable
try the next configured option
continue the session if another option succeeds
show which fallback was used and why
Why this would help
This would improve:
resilience
workflow continuity
cost/performance routing
practical multi-provider usage
Important constraint
This should be explicit and user-configured. I am not asking for silent quota bypassing. I am asking for legitimate failover across user-configured providers / models / profiles.
Additional context
This seems especially useful for people who intentionally configure multiple providers so a temporary outage or 429 does not fully block the session.
In the meantime, I put together a stopgap script that probes all three providers for live quota and auto-updates opencode.json to disable dead ones until they recover.
Underlying issue this works around:SubscriptionUsageLimitError in retry.ts falls through to the generic exhausted/unavailable match, so OpenCode retries the same dead provider indefinitely with exponential backoff up to 30s. This causes agents to spin for minutes/hours when a subscription is exhausted rather than failing fast or falling back to another provider. The one-line fix would be adding SubscriptionUsageLimitError alongside FreeUsageLimitError in the non-retryable check — but the broader cooldown-aware failover from this issue would be the proper solution.
It would be great if OpenCode could do this automatically: detect when a provider has a known long-duration outage (subscription exhausted, weekly limit hit, monthly quota depleted) and either fail fast or fall back to another configured provider, rather than retrying indefinitely. The info needed to make these decisions is already available from the provider APIs — this script demonstrates that.
Activity
github-actions commentedon Mar 10, 2026
This issue might be a duplicate of existing issues. Please check:
If these are distinct enough to warrant separate issues, please clarify how this differs from #16038 in particular.
Amperstrand commentedon Apr 14, 2026
In the meantime, I put together a stopgap script that probes all three providers for live quota and auto-updates
opencode.jsonto disable dead ones until they recover.https://gist.github.com/Amperstrand/64d3e13dc917be7c0b7b5baac3361417
What it does:
~/.config/opencode/opencode.json: setsdisabled_providersand picks the best availablemodel~/.local/share/opencode/auth.json— no keys in the scriptUsage:
Underlying issue this works around:
SubscriptionUsageLimitErrorinretry.tsfalls through to the genericexhausted/unavailablematch, so OpenCode retries the same dead provider indefinitely with exponential backoff up to 30s. This causes agents to spin for minutes/hours when a subscription is exhausted rather than failing fast or falling back to another provider. The one-line fix would be addingSubscriptionUsageLimitErroralongsideFreeUsageLimitErrorin the non-retryable check — but the broader cooldown-aware failover from this issue would be the proper solution.It would be great if OpenCode could do this automatically: detect when a provider has a known long-duration outage (subscription exhausted, weekly limit hit, monthly quota depleted) and either fail fast or fall back to another configured provider, rather than retrying indefinitely. The info needed to make these decisions is already available from the provider APIs — this script demonstrates that.
github-actions commentedon Jul 4, 2026
To stay organized issues are automatically closed after 60 days of no activity. If the issue is still relevant please open a new one.