When AI is told to change its primary weapon, be it from a corpse or a box, it takes only the rifle and equips the pistol, since it doesn't have ammunition for the rifle. So far OK.
The problem starts after telling the AI to pick up magazines for the new rifle (or giving the mags to AI). AI fails to acknowledge, that he has the rifle ammo now and is stuck with pistol forever.
The only way to have the AI to use the rifle, is to temporarily switch to him and manually change to the primary weapon. Not fun to do, waste of time, immersion breaker and on missions, where AI squadmembers are not playable, you're simply screwed.
Desired outcome is to have the AI to detect, that he has rifle magazines in its inventory and to switch to primary weapon accordingly.