Skip to content

Bug: Claude/Anthropic 500/502/503/504 server errors are not retried #21422

@rich-jojo

Description

@rich-jojo

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

  1. Configure Anthropic as provider
  2. Trigger or wait for a 500/502/503/504 response (during outages or high load)
  3. Observe: immediate error with no retry attempt

Expected behavior

OpenCode should retry 500/502/503/504 with exponential backoff, the same as 429/529.

Metadata

Metadata

Assignees

Labels

coreAnything pertaining to core functionality of the application (opencode server stuff)

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions