Kaseya currently has a time limit of 2 hours on Agent Procedures because procedures run synchronously on each machine, and a running procedures will block the execution of subsequent procedures until it finishes. If a procedures takes longer than 2 hours, Kaseya will force the procedures to time out.
How do I design a Agent Procedures that initiates an action that could take longer than two hours so that it won't block other procedures from running?
You should end up writing two Agent Procedures:
Agent Procedure A initiates the action (such as defrag.exe) that takes a long time using the Execute File command, and either Execute as system and continue immediately, or Execute as user and continue immediately. It then executes Agent Procedure B in 15 minutes time.
Agent Procedure B checks whether the application (defrag.exe in the example) is still running. If it is, the Then step is used to Execute Agent Procedure B again in 15 minutes time. If it is not running, then the Else step should be used to complete whatever actions are required after the application has finished.
All VSA Versions