Why is my Macbook Pro going to sleep while using it?
First thing to do is examine your power manager logs:
pmset -g log | grep &quot;Entering Sleep&quot;

When you find the timestamp(s) correlating to the unexpected sleep, please update your question with the full text of the relevant time range from pmset -g log.