Why use waits?
Waits enable workflows to:- Delay execution - Wait hours, days, or weeks between steps
- Coordinate with external systems - Wait for webhooks, approvals, or user actions
- Implement timeouts - Fail gracefully if events don’t arrive
- Save costs - No compute consumed while waiting
Types of waits
1. Time based: wait_for
Pause for a duration:
2. Timestamp-based: wait_until
Wait until a specific datetime
3. Event-based: wait_for_event
Wait for an external event:
Wait behavior
Worker suspension
When a workflow waits:- Worker suspends execution - Workflow state is saved
- No compute consumed - Worker is freed to handle other workflows
- Orchestrator tracks wait - Schedules resumption
- Workflow resumes - Worker picks up from where it stopped
Short vs long waits
Short waits (≤10 seconds):- Worker sleeps inline (doesn’t suspend)
- Slightly more efficient (no orchestrator round-trip)
- Configurable via
POLOS_WAIT_THRESHOLD_SECONDSenvironment variable
- Worker suspends and is freed
- Orchestrator schedules resumption
- Essential for hours/days/weeks