That's why I don't take companions into buildings, caves, etc, same as Fallout 3. In passive mode, if an enemy detects you and becomes hostile, your companions will magically know this and go after that enemy. Give the moders time and I'm sure we'll have an NPC AI overhaul.