Thanks for the report. While digging into it I found and fixed a real bug in 3.4.1: the companion's attack search never ran, because its laser was not recognised in the equipment grid, so it never moved toward enemies on its own or held position while fighting. I could not reproduce the endless back-and-forth after a fight, even with the attack search working again (damaged or full-health companion, enemies 15 to 50 tiles away, several targets, walking player). If it still happens with 3.4.1, could you tell me whether your companion was below 70% health, whether you have a personal roboport, whether there were ghosts or damaged buildings nearby, and send a log or a save? That would let me fix it for good.