Sonny is over 100, and no matter how genetically strong someone's mind is, it's inevitably going to slip when you reach such an age. I doubt he really understands much of what his life was anymore, just recognizes faces and voices. It's also possible he's waiting for the right time to send Michael to open his hospital window so he can come up from behind and shove him out.