Objective To investigate the clinical effect and safety study of agomelatine combined with eszopiclone in the treatment of epilepsy complicated by insomnia. Methods 69 epilepsy complicated by insomnia patients were collected in the outpatient of the Department of Neurology, the First Affiliated Hospital of Shanxi Medical University from December 2021 to October 2022. Patients were randomly divided into control group (34 cases) and observation group (35 cases) Patients in control group were given eszopiclone, 1.5 ~ 3 mg (3 ~ 5 times/week). Patients in observation group were given agomelatine 25 mg (1 time/day) and eszopiclone 1.5 ~ 3 mg (3 ~ 5 times/week). Patients in both groups maintained their original anti-seizure medications treatment regimen for 12 weeks during the study. Pittsburgh sleep quality index (PSQI), Insomnia severity scale (ISI), Patient health questionnaire-9 (PHQ-9) and Generalized anxiety disorder-7 (GAD-7) were used to compare differences in subjective sleep quality, insomnia severity, depression and anxiety symptoms before treatment and at the end of 4 and 12 weeks of treatment. The change of seizure frequency before and after treatment was statistically evaluated to assess epilepsy control. The adverse effects after medication were recorded in both groups. Results After 4 weeks and 12 weeks of treatment, the scores of PSQI, ISI, PHQ-9 and GAD-7 of both groups were significantly lower than those before treatment, and the scores of PSQI, ISI, PHQ-9 and GAD-7 in the combined group at the 4th week and 12 weeks after treatment were significantly lower than those in the single-drug group (P<0.05). The incidence of adverse reactions was 13.33% in the single-agent group and 15.63% in the combined group. Conclusions Agomelatine combined with eszopiclone improve subjective sleep quality, insomnia severity, depression and anxiety symptoms of patients more significantly.