Hi; I just randomly found this thread while looking for similar issues (crashing / freezing) on my system. My problems are on Debian 13 and I don’t have a solution yet (I’m putting together a post to ask about it tomorrow), but in your case the problem is very likely in version of the firmware-amd-graphics package – the version available in Debian 12 has known issues and needs to be updated to at least one from the end of February 2024.
Last year I wrote more details about it at InstallingDebianOn/FrameWork/Laptop13/AMD_7040_Series - Debian Wiki, but I did not update it since then; you should probably disregard the instructions for manual firmware update, and instead install firmware-amd-graphics package from stable-backports (currently offering version 20240709).
I would not recommend updating to Debian 13 (trixie) at this moment, because I did so a month ago and the random infrequent crashes I was having before became much more frequent. So there is likely some issue with new kernel or drivers.