Factor shared logic for detecting direct-prompt vs trigger-phrase flags into a reusable helper function to reduce duplication.