The Automation Engine will check if the agent is active when a job is started . If the agent is not active the job will show as 'Waiting for host'. The job will keep this status until the agent is active again. This can cause some problems if you are evaluating the ending status of a job.
The following script will check if the host is active and if not change the status to 'ENDED_NOT_OK - aborted'
:PSET &RETURN# = SYS_HOST_ALIVE(&$AGENT#)
:IF &RETURN# = 'N'
: EXIT 1
:ENDIF