Added null checks to BaseAgent constructor