I think this question really just highlights the fact that the concept of punishing a criminal because they "deserve" it, because they are "responsible" is incredibly outdated.
Rather than looking at a given person (or AI) to determine whether they are "responsible" for a crime, what we should do instead is look at what factors going into the crime were most predictive of that crime being carried out - and then take whatever action makes the most sense to lower the probability of that same crime happening again.
Punishing someone because they deserve it is regressive and utterly pointless. But what isn't pointless is taking tangible, pragmatic steps to limit future damages. It's the year 2023. Why do I still have to say this?
I wrote another comment yesterday explaining something similar: https://medium.com/@nebulasaurus/i-think-this-is-a-great-analysis-of-how-the-idea-of-free-will-has-been-developed-and-discussed-33b590d2ab1d