Companion AI has gotten better, but traps and floor damage (fire floors etc) still pose some challenges to how the game calculates path-finding.
I -- GENERALLY -- find it better to play with Companions set to Attack Only Enemies Very Near To Them. That tends to make their behavior more predictable and limits their exposure to traps. However, with that approach, sometimes there will be situations in which you will get attacked and your Companion will just stand by watching you die.