It's based on intimacy. If you reach too low of an intimacy, it will run away. You lose intimacy by forgetting to feed, and by dying.
"Intimacy Characteristics
Classification Point Range
Very shy Less than 100 Ready to abandon its ownerShy 100–249 Uses unhappy emotes such as

and /wah
Neutral 250–749 Uses friendly emotes such as

and

Cordial 750–909 Uses affectionate emotes such as

and

Loyal 910–1000 Talks often and uses affectionate emotes "
source