Sector coding in general is very questionable and weak on common sense.
Let's start with simple rules of the thumb:
Rule 1 - If we put sector priority on some resource, with "Respect tiles on", we actually mean - "Respect the sector tiles, and build this resource on all empty tiles left"
Rule 2 - If we put sector priority on some resource, with "Respect tiles off", we actually mean - "Don't respect the sector tiles, and build this resource on all empty tiles left"
Rule 3 - We tend to respect science tiles to maximize yields, that means with "Respect tiles on" we always build and upgrade science lab according to science resource present on tile
Rule 4 - If we disrespect tiles, labs on empty spots and labs overriding anything else are upgraded to bring the most lacking science type up to speed.
Rule 5 - Food should never be overproduced unless specifically put as sector priority. First to be replaced are 1-food tiles, then 2-food tiles. In general, 3-4 food tiles are too good to pass up the opportunity to farm those up.
Rule 6 - Spaceports should build just enough upgrades to fit economy upgrades. Those are, in order of priority: solar panel, hydroponic farms, observatory
Rule 7 - It is *always* more profitable to build level 1 building under every pop present, than keep upgrading something. So, if sector has any pops on empty ground, these should have the priority to get resource production under their feet a.s.a.p.
Rule 8 - For double resource tiles things get a bit more complicated but still doable. First, we check sector focus - if sector wants to focus one of the resources, we suggest we can build it. Next, we check if we have double-producing buildings (like Slave processing hub or Farm as Agrarian Iddyl), and make sure we build that instead.
Rule 9 - When all Ascention perks are completed, and we no longer need Unity, we don't build Unity pure buildings, and replace existing ones.
Rule 10 - If we have access to Pop growth speed %% buildings, we prioritize working it with pop right after the Colony base. As example, I had sector Gene clinic ready, but it refused to work it until all other tiles were covered.
I understand that initially when you pass a planet to sector, AI starts with clearing all tiles to understand what to do with the planet. As a human, I can see what resources I got under the obstacles, and can plan tile cleanup ahead of pop growth, clearing 1-2 tiles ahead. Not having this behaviour coded in is just lazy. There is no excuse for this.
I'm not sure how sector AI behaves with specific builds/finetuning, like inward perfectionists + agrarian addyl for example.
I hope Stellaris team finally sits down at some point and try to make a really good efficient sector AI, which i entirely possible, but obviously needs time investment, which they seem to focus on useless DLC (Human Empires, anyone).
Yes. YES. The sector AI is dumb, this is acknowledged, but the worst it's that it's not even doing what you ask it to do. If there is an energy deficit, then let ME deal with it, unless I asked you to ("Balanced resource production" for instance).
And about optimization, we're not asking the AI to check all possible configurations of the position of the main building to maximize input of the wanted resource or to simulate production for the next year to know which building it should upgrade first, we want it to do common sense things. Like, you know, not waiting the planet to be completely full to put a POPs on a Gene Center, or prioritizing building level 1 buildings (+2 production, fast, cheap) on tiles with inactive POPs rather than upgrading (+1 production, slow, more expensive) already existent buildings of the same type.
The game has been released almost two years ago and this kind of issues is still there. I come back every patch hoping the sector AI has been "fixed". I usually do a couple games and then quit because of frustration. I have to admit it's still better than 1.0, but come on, how long it's gonna take to get this feature to work properly?