opencode icon indicating copy to clipboard operation
opencode copied to clipboard

feat: Add retry mechanism for Anthropic overloaded errors

Open tito opened this issue 4 months ago • 4 comments

Implement automatic retry with exponential backoff when Anthropic returns {"type": "overloaded_error"} responses, by checking the error message on overloaded_error inclusion.

Changes

  • Add ServiceOverloadedError type to properly categorize these errors
  • Implement configurable retry logic with exponential backoff and jitter
  • Add retry configuration schema with sensible defaults (20 retries, 30s max delay)

Configuration

We can now configure retry behavior in opencode.json:

{
  "retry": {
    "maxRetries": 20,
    "initialDelay": 1000,
    "maxDelay": 30000
  }
}

Closes #833

tito avatar Jul 15 '25 18:07 tito

i ended up submitting a PR upstream: https://github.com/vercel/ai/pull/7317

thdxr avatar Jul 15 '25 19:07 thdxr

@thdxr So i should dismiss this one ?

tito avatar Jul 15 '25 20:07 tito

Or could we patch this library on opencode side to then be able to parse and work on that error ? I don't know how long we should wait for the upstream PR to be merged

tito avatar Jul 15 '25 20:07 tito

I believe this is still necessary to fix this issue: https://github.com/sst/opencode/issues/1712

WilliamAGH avatar Aug 11 '25 19:08 WilliamAGH