consolidate agent code into one action that also filters
fix missed update of principal -> impersonatedPrincipal