Skip to content

Anthropic overloaded_error is not retried, halts session #20384

Closed

Description

@OliPetry

Bug description

When the Anthropic API is at capacity, it returns a stream error:

{"type":"overloaded_error","message":"Overloaded"}

This error is not recognized as retryable. The session halts with a terminal UnknownError instead of retrying with exponential backoff.

Steps to reproduce

  1. Use an Anthropic model (e.g., claude-opus-4-6)
  2. Send a request when the API is under heavy load
  3. Observe the session stops with {"type":"overloaded_error","message":"Overloaded"} displayed as a raw JSON error

Expected behavior

The error should be classified as a retryable API error, triggering the existing exponential backoff retry logic (2s → 4s → 8s → 16s → 30s cap), similar to how too_many_requests and rate limits are handled.

Actual behavior

The error falls through parseStreamError() (which only handles body.type === "error", not "overloaded_error"), becomes a NamedError.Unknown, and retryable() does not match it — the session halts.

Environment

  • OpenCode version: 1.3.6
  • Provider: Anthropic (via custom gateway)
  • Model: claude-opus-4-6
  • OS: macOS

Activity

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

    @github-actions
    Contributor

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

    There are also several previously closed issues on this same topic (#163, #833, #1057, #1318) which may be worth reviewing to understand prior fix attempts.

  3. OliPetry commented on Apr 1, 2026

    @OliPetry
    Author

    This is related to #19394 but covers a different code path:

    The two fixes are complementary — #19394's suggested fix (override isRetryable for 5xx status codes) wouldn't catch this case because stream errors don't carry an HTTP status code. The PR (#20373) adds overloaded_error handling specifically in parseStreamError().

  4. removed
    coreAnything pertaining to core functionality of the application (opencode server stuff)
    on May 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions