Long-Running AOP Execution
This guide shows how to execute Agent Operating Procedures (AOPs) using the Python SDK with asynchronous execution and proper polling for completion. This is the recommended approach for production applications where AOPs may take minutes or longer to complete.
Why Async Execution? When you call execute_async(), it returns immediately with a thread_id. The AOP continues running in the background. You must poll threads.get_status() in a loop to know when execution finishes. Without polling, you have no way to know if the AOP completed, failed, or is still running.
Key features:
- Non-blocking execution -
execute_async()returns immediately with a thread ID - Polling-based completion tracking - Use
threads.get_status()in a loop to wait for results - Configurable timeouts - Set appropriate timeouts for your workflow complexity
- Production-ready patterns - Error handling, retries, and batch processing
execute_async() returns immediately with a thread_id and does not wait for completion.
You must implement a polling loop using threads.get_status() to wait for the AOP to finish.
Start Async Execution
Call execute_async() to start the AOP. This returns immediately with a thread_id you use to track progress.
At this point the AOP is running in the background. The response.status will indicate it has started, but the work is not done yet.
Poll for Completion
You must check threads.get_status() in a loop until the status is completed or failed.
