Have you ever read Hyperion? Best sci fi I’ve read, and basically that’s a large part of the plot.
Hyperion is great.
Also The Three Laws of Robotics outlaws a AI takeover!!