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
- Configure a custom OpenAI-compatible provider that occasionally returns 502/503
- 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
- 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.
Description
MessageV2.fromErrorcurrently only upgradesAPICallErrorinstances to retryableAPIError. When an OpenAI-compatible provider throws a plainErroror object with HTTP status fields instead, the error falls through toNamedError.Unknown, so session retry logic never runs.Reproduction
Errorwith astatusCodeorstatusproperty (notAPICallError)status/statusCodeorresponse.status/response.statusCodeErrorwhose.messageis a JSON string containingstatusCodeUnknownerrorsExpected behavior
Any error with HTTP status >= 500 should be classified as
APIErrorwithisRetryable: true, regardless of the error object shape.4xx handling is unchanged by this fix.