Added an error if the agent ID is undefined

Is this ok? I normally would poop ternaries all over this. :hankey: