Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,19 @@ export const openaiErrorDataSchema = z.object({

export type OpenAIErrorData = z.infer<typeof openaiErrorDataSchema>

// Status codes that should trigger automatic retry
const RETRYABLE_STATUS_CODES = new Set([
404, // OpenAI Responses API can return 404 for transient "Item not found" errors
408, // Request Timeout
429, // Too Many Requests / Rate Limited
500, // Internal Server Error
502, // Bad Gateway
503, // Service Unavailable
504, // Gateway Timeout
])

export const openaiFailedResponseHandler: any = createJsonErrorResponseHandler({
errorSchema: openaiErrorDataSchema,
errorToMessage: (data) => data.error.message,
isRetryable: (response) => RETRYABLE_STATUS_CODES.has(response.status),
})
Loading