Added an error if the agent ID is undefined