Leading U.S. tech companies including OpenAI, Google and Microsoft have agreed to a set of voluntary safeguards to mitigate the risks of artificial intelligence, an early step ahead of more formal regulations as lawmakers around the world rush to develop a coherent response to guide the fast-moving technology.