I feel like the devs are trying too hard to make the AI function in an AI-like way (weighting build options etc), and need to just bite the bullet and make AI operate according to build lists. Weight the build list that is followed according to the ethics/civics/planet resources or whatever, but the chance to build a building that makes no sense at all needs to be zero, not merely lower than the chance to build the right buildings. Gotta make sure agricultural planets get food processors, and more importantly that non-agricultural planets do not, etc.
I can go along with the AI "cheating" by having combinations of planets & build lists & similar if we could get that to work. Generating lists small sector by sector could be somewhat workable. The AI would likely never be good as it wouldn't understand how multiple sectors would interplay with each other BUT the AI might not be embarrassingly bad either.