The myriad of things that can cause a resident to become agitated boggles my mind. It can be something as simple as asking them if they're ready to go to dinner. Of course, we don't know what's going on inside their heads at that moment, so maybe just the interruption is enough to tip them over the edge.
There's only one proper response to a resident's agitation. "I'm sorry." Sometimes it calms them, sometimes it doesn't but there isn't any other real option. Step two is reporting any behaviors to the charge nurse. Making snotty comments back or being physically rough with the resident are not acceptable actions.
The hardest thing in the world is to control your reactions when people are rude or mean. I know I don't always succeed. Still, striving for the highest ideals will get you closer than lowering yourself to the other person's level.