Fix nullpointer in agent