only set agent if it is set