Modelling collective motion based on the principle of agency