After years of fighting with it, I think the culprit turned out to be simple poor sleep. I finally found a sleep aid that works reliably and without undesirable side effects (cannabis gummies) and, after being able to sleep reliably for a while, was able to stop taking antidepressants and still feel better than before.
It’s hard to overstate the importance of getting enough sleep.