check if agent is undefined