I recommend to do the discover at the place where you run the agent.
Here it is Ok, but in some other places humans are likely to miss some tricky logic, and nodes list may change before we run the agent. To avoid this - simplest way - make a wrapper, pass agent and nodes, which would make sure that required step is not missed - it would parse nodes for uids, run discover, and run agent itself.
I didn't research more, but that's just my 2 cents for you to look at.