If someone has an epileptic seizure or a diabetic goes into hypoglycemic shock whilst driving and gets into a head on collision and kills someone should they go to prison? They call it mental illness for a reason.
I’ve known people with epilepsy who were banned from driving due to this possibly. If they had driven and gotten a seizure and killed someone, they would have been driving with a reckless disregard for the safety of others, which is enough of a mens rea to form intention for some level of murder conviction.
It is likely this is largely true, even if not formally banned from driving, so the answer is probably yes to your hypothetical they should go to prison, or pulling the normative phrase out, likely would go to prison (subject to many mitigating factors).
Perhaps epilepsy was a bad choice. How about for cardiac arrest, stroke, or any number of undiagnosed medical conditions that could cause someone to create dangerous/fatal conditions outside of their control?
Even if we accept your premise that having a mental illness precludes one from taking responsibility for their actions, you still have to deal with the fact that they are a serious danger to society. One of the uses of prison is to take people who would otherwise murder and eat people and remove them from society, so that they can't do that.