Suspend and Resume
In AgentScope AI, workflows can be suspended and resumed to allow for asynchronous processing, waiting for external events, or handling long-running tasks. This capability ensures that workflows remain efficient and responsive without blocking execution resources.
Suspending a Workflow
A workflow can be suspended when it needs to wait for an external condition, such as a user input, an API response, or a time-based trigger. When suspended, the workflow state is saved so it can be resumed later.
Example: Suspending for User Input
In this example, the workflow suspends at the first step, waiting for a user_approval
event. If the event is received, the workflow resumes. If the timeout expires, it can be handled separately.
Resuming a Workflow
A suspended workflow can be resumed when the expected event occurs. This is typically done through an external trigger, such as an API call or an event listener.
Example: Resuming a Workflow
Here, resumeWorkflow
reactivates the workflow that was previously suspended.
Handling Timeouts
If a workflow is suspended with a timeout, it will automatically fail or execute a fallback step when the timeout expires.
Example: Handling Timeout
If no event is received within 3600 seconds, handleTimeout
executes to ensure the workflow doesn’t stall indefinitely.
Last updated