def _check_agent_token_prior_to_agent_reboot(driver_internal_info):
    """Removes the agent token if it was not pregenerated.

    Removal of the agent token in cases where it is not pregenerated
    is a vital action prior to rebooting the agent, as without doing
    so the agent will be unable to establish communication with
    the ironic API after the reboot. Effectively locking itself out
    as in cases where the value is not pregenerated, it is not
    already included in the payload and must be generated again
    upon lookup.

    :param driver_internal_info: The driver_interal_info dict object
                                 from a Node object.
    """
    if not driver_internal_info.get('agent_secret_token_pregenerated', False):
        driver_internal_info.pop('agent_secret_token', None)
