Skip to content

fix: 5xx errors from non-standard providers are not retried #19203

@okuyam2y

Description

@okuyam2y

Description

MessageV2.fromError currently only upgrades APICallError instances to retryable APIError. When an OpenAI-compatible provider throws a plain Error or object with HTTP status fields instead, the error falls through to NamedError.Unknown, so session retry logic never runs.

Reproduction

  1. Configure a custom OpenAI-compatible provider that occasionally returns 502/503
  2. The error object may be:
    • An Error with a statusCode or status property (not APICallError)
    • A plain object with status/statusCode or response.status/response.statusCode
    • An Error whose .message is a JSON string containing statusCode
  3. OpenCode treats all of these as non-retryable Unknown errors

Expected behavior

Any error with HTTP status >= 500 should be classified as APIError with isRetryable: true, regardless of the error object shape.

4xx handling is unchanged by this fix.

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