For shits and giggles I tried introducing a mod mechanic that would give the AI comparable levels of metal to that of their materials. The AI still produced lower quality gear, even when higher quality was available.
So I assumed a theory that the AI would always produce units when it could, with the highest quality. This would lead to it perpetually being out of one resource, as there would always be a limiter. But this was not so. Even when I made sure the AI had over 20 000 metal and materials, and 100k+ gildar, it still continued building units with leather armor instead of master heavy plate, which I know it had access to. Indeed, not even with such abundant resources did the AI ever construct any other unit with more than one warrior (squad/group/party/raid), except diplomacy units.
There seem to be a disconnect here between what the AI can do and what it does do. Even when in a position to be able to construct the right units, it continues to produce the wrong units. I am oversimplifying, of course.
The AI, it seems, need to be able to "save" resources until a suitable unit can be produced, especially middle or late game. The AI badly needs to avoid wasting resources on poor unit management (single units with only a weapon and leather gear).
Furthermore, not once have I seen AI make use of training units with higher quality. This is also a huge waste on behalf of the AI, as it is one of the best ways to save resources.