The AI retreating when it reaches a certain health value is not the issue (it already does this) unless we are referring to it's failure to extend itself to obtain the kill (it will retreat even if it could win simply because it's health is low).
The issue is the AI's ability to assess it's possibility of success in any given combat or in performing long duration actions (teleport scrolls). Reprograming the AI with knowledge of it's enemy's skills and their total potential damage per second is the step the game needs to take in order for the computer to be a more formidable opponent.
To provide an example:
Let's say the computer is about to attack sedna that has specialized in pounce and heal. It needs to have knowledge of how much damage/healing those skills do and compare those skills with their own. So.. if pounce does 1000 damage and recharge is 6 seconds (cooldown flag) then she can inflict 167dmg/sec + auto attack damage (minus the casting time of this skill). It also needs to make an assessment of it's current hp with possible 'spike damage' and refuse to engage if the total available spike damage is equal to their remaining hp. Then the computer needs to assess their opponents ability to defend themselves, including damage reduction, total hp, regeneration and defensive abilities. So.. if healing can cure 1500 damage and recharge is 6 seconds (flag again) then she can regenerate 250hp/sec + natural regen.
The computer can now make an assessment of it's own abilities versus it's opponents using the following formula: If Opponent HP/(Computer damage/sec - opponent healing/sec) < Computer HP/(Opponent damage/sec - opponent healing/sec) then Attack. Lower levels of AI should have less than 100% accuracy in determining this.
The computer also needs to be informed of 'total surrounding damage' and 'total potential surrounding damage'. Meaning that it should be aware of it's opponents escape mechanisms (hiding behind towers, creeps, or other demigods) and add how much damage 'could' be inflicted before attempting to pursue 3 or 4 seconds in advance. The computer should also be given a higher priority to return to heal if their hp is below 50% or within spike damage of any of 2-3 of their opponents, depending on how many players are on the map. Snipe may require special rules..
The computer also needs to be programmed to include non-engagement measures of combat, such as using 'spit' on it's opponent and then retreating, regardless of it's chance of success, as long as it can successfully escape with more hp than it's opponent. Higher levels of AI should be given knowledge of their opponents MP as well and use that in their calculations of what skills they can use and how much damage/healing per second they can actually perform.