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
feat: Add configurable max retry limit for SessionRetry mechanism #26675
When a provider returns persistent 5xx errors (e.g., 500 Internal Server Error), the built-in SessionRetry mechanism retries indefinitely with exponential backoff. This can lead to extremely long wait times (hours) without any way to configure a maximum retry count.
Observed Behavior
When DeepSeek-V4-Pro returns a 500 error, OpenCode retries with exponential backoff:
Attempt 1: 2s delay
Attempt 5: 32s delay
Attempt 10: ~17min delay
Attempt 13: ~2h 11min delay
...continues indefinitely
The retry mechanism has:
RETRY_INITIAL_DELAY = 2000ms
RETRY_BACKOFF_FACTOR = 2
RETRY_MAX_DELAY = 2147483647ms (~24.8 days)
No maximum retry count limit
Code Reference
The retry policy in SessionProcessor uses Effect's n.retry(cr.policy({...})) which has no configurable max attempts. The maxRetries: d.retries ?? 0 only applies to the Vercel AI SDK layer, not the Effect retry policy.
Proposed Solution
Add a configurable maximum retry limit to the SessionRetry mechanism:
// opencode.json
{
"session": {
"retry": {
"maxAttempts": 5, // Stop retrying after 5 attempts"maxDelay": 30000// Optional: cap max delay at 30s
}
}
}
Provider outages: When a provider is down for extended periods, users should be able to set a limit and let fallback mechanisms (like model switching plugins) take over
Cost control: Prevent extremely long retry loops that consume time/resources
User experience: Users can set reasonable limits and manually intervene when needed
Current Workaround
None. Users must manually abort sessions when retries become excessive. Plugin-based fallback systems (like oh-my-openagent) can switch models but cannot control OpenCode's internal retry count.
Activity
github-actions commentedon May 10, 2026
This issue doesn't fully meet our contributing guidelines.
What needs to be fixed:
[FEATURE]:(current title usesfeat:prefix)Please edit this issue to address the above within 2 hours, or it will be automatically closed.
This issue might be a duplicate of existing issues. Please check:
If you believe this was flagged incorrectly, please let a maintainer know.
feat: add configurable max retry limit for SessionRetry
github-actions commentedon May 10, 2026
This issue has been automatically closed because it was not updated to meet our contributing guidelines within the 2-hour window.
Feel free to open a new issue that follows our issue templates.