Fix bug in Agent initialization