| 1161 | } |
| 1162 | |
| 1163 | export function categorizeRetryableAPIError( |
| 1164 | error: APIError, |
| 1165 | ): SDKAssistantMessageError { |
| 1166 | if ( |
| 1167 | error.status === 529 || |
| 1168 | error.message?.includes('"type":"overloaded_error"') |
| 1169 | ) { |
| 1170 | return 'rate_limit' |
| 1171 | } |
| 1172 | if (error.status === 429) { |
| 1173 | return 'rate_limit' |
| 1174 | } |
| 1175 | if (error.status === 401 || error.status === 403) { |
| 1176 | return 'authentication_failed' |
| 1177 | } |
| 1178 | if (error.status !== undefined && error.status >= 408) { |
| 1179 | return 'server_error' |
| 1180 | } |
| 1181 | return 'unknown' |
| 1182 | } |
| 1183 | |
| 1184 | export function getErrorMessageIfRefusal( |
| 1185 | stopReason: BetaStopReason | null, |