Many owners of 2013 MacBook Airs are still being plagued with their Macs intermittently going to sleep, and this has been nicknamed the Black Screen Of Death (BSOD) by people posting to the Apple discussion groups. I originally posted about this on 8/15/2013.
Apple has attempted to resolve this by releasing both OS and graphic driver updates, which have helped some but not all. The problem is more prone to happen when running of battery power, and is often times triggered by vibration, such as bumping the computer or typing too hard on the keyboard. This leads me to believe the root cause is with an internal sensor.
If you have a 2013 MacBook Air that is intermittently going to sleep when it shouldn’t, and is under warranty or AppleCare, I would recommend taking it to Apple ASAP for service. For those that are experiencing this problem with an out of warranty MacBook Air, some have reported success with installing the Google Code project named macosx-nosleep-extension, which is a kernel extension that prevents Macs from going into sleep mode.