If it's a big one, 6" or more, try to catch it & get it out of there. I've watched one attack one of my female seahorses (KIA)

I caught that sucker & made it pay but it was too late for the pony. I've also seen the big ones chow down on unattached mushrooms or damaged corals. Small ones are harmless & help keep your tank clean of uneated foods. Big suckers need to be disposed of. (just my experience)