There are two specific cases where companions can potentially stop following you around, until you perform an action such as sneaking to force a sanity check on them. They are not rare issues, and can happen very often.
For the dialogue issue, there is a conditional form controlling when the SQ_Followers_StandStillDuringDialogueScenes [00054B36] package is used.
This conditional form has a broken check of: (NULL).IsInDialogueWithPlayer = 1
Changing it to this fixes the issue: Subject.IsInDialogueWithPlayer = 1
For the issue with being in proximity to an alien creature, this behavior is caused by the Unknown 12 interrupt flag within the SQ_Followers_GroupFormation_FollowPlayer [002A9765] package. Disabling this flag stops this behavior from happening.
Since it's currently an unknown flag, it's hard to tell if this has any other side effects. However, I have been testing this change extensively with one other person, and have noticed no side effects at all. I strongly believe it only controls this behavior, and the fact that it's enabled in this package was most likely an oversight.
1.9.51.0
English (EN)
Yes
For the dialogue bug, simply enter dialogue with your current companion, exit dialogue, and walk away. There is a very high chance that they will not follow you (maybe 90%), until you perform an action such as sneaking.
For the "pull out gun and stare menacingly" bug, a good place to replicate this behavior is on Ixyll 2, with the small Spaceroach Filterer creatures around the Eleos Retreat. Lure a companion near some of these creatures, and they will likely stop following you to stand there and bully the local wildlife. Again, this happens maybe 90% of the time.