Skip to content

Claude/Anthropic 500/502/503/504 server errors are not retried #21420

Closed

Description

@rich-jojo

Bug Report

What happened?

When Anthropic's API returns a transient server error (HTTP 500, 502, 503, or 504), OpenCode does not retry the request — it immediately fails with an error like:

{"type":"api_error","message":"Claude API returned a server error. This is usually temporary — try again in a moment."}

Expected behavior

Transient server errors should be retried with exponential backoff, the same way rate-limit errors (429) and overload errors (529) already are.

Root cause

In packages/opencode/src/provider/error.ts, parseAPICallError() trusts input.error.isRetryable from the Vercel AI SDK for non-OpenAI providers. The @ai-sdk/anthropic package only marks status codes 429 and 529 as isRetryable: true. Generic 500/502/503/504 responses get isRetryable: false, so SessionRetry.retryable() returns undefined and the retry loop stops immediately.

OpenAI already has a special override in isOpenAiErrorRetryable() — the same approach needs to be applied universally.

Environment

  • OpenCode version: latest dev
  • Provider: Anthropic (Claude)

Activity

  1. added
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on Apr 8, 2026
  2. github-actions commented on Apr 8, 2026

    @github-actions
    Contributor

    This issue might be a duplicate of existing issues. Please check:

    If you believe this is distinct, please clarify how it differs from the above (especially #19394, which describes the same root cause in error.ts).

  3. rich-jojo commented on Apr 24, 2026

    @rich-jojo
    Author

    Closing as a duplicate of #19394. Both describe the same Anthropic 5xx APICallError retry-classification path in packages/opencode/src/provider/error.ts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions