I think it was Larry Niven, quite a few decades ago, that had SF stories where AIs were only good for a few months before becoming suicidal...
I just googled and there was a discussion on Reddit and they mentioned some Frank Herbert works where this was a thing.
Not one of the mainline "Known Space" stories, if it was Niven at all. Maybe the suggestion about Frank Herbert in another comment is right, I also read a lot by him besides Dune - I particularly appreciated the Bureau of Sabotage concept ...