As stated in the title. This may not be a good example because I was just fooling around with Dragon Knight and was level 25 with ridiculous items, but I noticed that sometimes the AI just paced back and forth to and away from me while I was pushing their towers. I know it's not a very good example because it will never happen in a real game, but the AI should know when to retreat. Perhaps if the player or thing they're fighting against is some amount of levels higher than them... Perhaps 8? Then they run away, unless they have teamates to reinforce.