A new mathematical formula tracks an AI's internal "compass needle" to flag undesirable outputs before they happen.