The easiest way to do this would be to determine how does your brain figure this out and then apply it to the code..
If the mobs health is < 20%
and the mobs is walking
and the distance from where the person wiht the agro is and the mob is, is growing
then he is fleeing
Not all times does the mob face away from you...
Not all times does the mob turn to flee
They follow paths
So this would be first find out Targets.Target
Get Target.Targets position
Get Targets Postion
Save the distance
Check again in 1s
If Distance from Target and Targets.Target is larger then last check then he is fleeing..
If you want I can test some code on that and post it.. But that seems the best way in my opinion to figure it out..