Setting agent to run once in foreground before launching in the background