> Friend-or-foe identification can boil down to "only targets shooting at me are hostile".
And those that shoot at allies. And those that haven't shot yet, but are aiming in the wrong direction. And those that are just reloading their mortar. And those that are setting up an explosive trap for the robot.
There are a lot of ways to be hostile that go beyond firing a weapon directly at the robot, and if it can't handle those, it will be exploited by humans pretending to be harmless.