The intention wasn't to have this actually be a 5 second wait. In fact, it works just fine if the waitPeriod is 1 ns. Calling WaitAgentAlive was the way I was able to actually get the list of agents to be properly reflected.