I had a similar issue with a mid 2014 MacBook Pro. It had been unused for a few months then when I picked it up it needed several updates which went fine. However, when it went to sleep it would randomly restart. The error logs showed a kernel panic. I reset NVRAM and PRAM with no success. I then ran the recovery diagnostics and it fixed a lot of errors pertaining to broken links and so forth, but nothing truly pointing to why the kernel panics.
Apple support chat recommended the recovery diagnostics, (already done), and reinstall the OS. OKAY, ran the internet recovery OS install and it failed for lack of disk space. Really? Checked and it had about 25.X GB free out of 250 GB.
It should be enough, but said it was about 220 MB short. OKAY, reboot the existing OS, remove all my data files to an external HD. Checked space available, now it's at 18 some-odd GB. What? That can't be right.
It got to under 17 GB free but showed about 70 GB purgeable. What is purgeable? Researched what that really meant, had about 1/2 dozen snapshot backup files of many GB each hidden away. Opened up Terminal, ripped out the snapshot backups and rebooted again. Still only about 17 GB free. Really, again?
Rebooted and suddenly I have about 70 GB free. Great, back to the recovery OS install just in case. Restarted and it was fine. Took about 45 minutes but it installed the current OS version and had no errors. Total space available, 183+ GB. So far no more kernel panics and nothing I found in any forum went down this path. Having the free space is nice but not directly related to anything other than the re-installation of the OS. What caused the kernel panics per the Apple support guy was likely a problem with the video card. I have no idea if it's entirely fixed or the root cause. Time will tell.