Sexsomnia, or the condition known as sleep sex, is a distinct form of parasomnia, or an abnormal activity that occurs while you are sleeping. The conditions falls within the broad classes of sleep disorders, and in extreme cases, sexsomnia has been alleged as the cause of rare instances of sexual assault, including rape.
Sexsomnia is characterized by an individual engaging in sexual acts while in non-rapid eye movement, or NREM sleep. Causes are same as other sleep disorders, but also use of alcohol, sleep disruption, obstructive sleep apnea, and sleep deprivation.
There are medical treatments options like anti-anxiety and antidepressant medications. But you can also make lifestyle changes that can reduce the risk like talking with your partner and family, create a protective environment, avoid triggers, and practice good sleep hygiene.