added check for missing agent token