You should be able to spawn it out. Spawn will allow you to call an async function (the loop with sleep) and not be necessarily tied down to the passing of the agent reference.
See this video at the 12:20 mark:
I really thanks to you for helping me!!