-
Notifications
You must be signed in to change notification settings - Fork 15.4k
Bug: Claude/Anthropic 500/502/503/504 server errors are not retried #21422
Copy link
Copy link
Open
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)
Description
What happened?
When Anthropic's API returns a transient server error (HTTP 500, 502, 503, or 504), OpenCode immediately fails with no retry:
{"type":"api_error","message":"Claude API returned a server error. This is usually temporary — try again in a moment."}
The same infrastructure already retries 429 and 529 — but 500/502/503/504 are silently dropped.
Root cause
parseAPICallError() in packages/opencode/src/provider/error.ts trusts input.error.isRetryable from the Vercel AI SDK for non-OpenAI providers. The @ai-sdk/anthropic package only sets isRetryable: true for 429 and 529. HTTP 500/502/503/504 get isRetryable: false, so SessionRetry.retryable() returns undefined and the retry loop exits.
OpenAI already has a isOpenAiErrorRetryable() override — the same pattern needs to apply universally.
Steps to reproduce
- Configure Anthropic as provider
- Trigger or wait for a 500/502/503/504 response (during outages or high load)
- Observe: immediate error with no retry attempt
Expected behavior
OpenCode should retry 500/502/503/504 with exponential backoff, the same as 429/529.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
coreAnything pertaining to core functionality of the application (opencode server stuff)Anything pertaining to core functionality of the application (opencode server stuff)
Type
Fields
Give feedbackNo fields configured for issues without a type.