Skip to main content
Human-in-the-loop (HITL) workflows pause execution to wait for human approval, input, or decisions before continuing. This is essential for sensitive operations like financial transactions, data deletions, or any action requiring human oversight.

Basic suspend and resume

Use ctx.step.suspend() to pause workflow execution and wait for external input:
What happens:
  1. Agent creates a structured action plan
  2. Workflow suspends with plan details
  3. Worker suspends execution (no compute consumed)
  4. An event is emitted with suspend details
  5. Workflow waits indefinitely (or until timeout)
  6. When resume event arrives, workflow continues with the provided data

Suspend events

When a workflow suspends, Polos emits an event to a topic specific to that suspension: Topic format: {step_key}/{execution_id} Event:

Listening for suspend events

Stream workflow events to detect when a workflow suspends:

Resuming workflows

To resume a suspended workflow, emit a resume event to the same topic:
The workflow resumes immediately and continues with the provided data.

Complete example

Here’s a full approval workflow with suspend/resume:

Building approval UIs

The slack message has an approval URL of https://admin.example.com/approve/{execution_id}. When a human clicks the URL and makes a decision, your approval endpoint can call the Polos API to resume the workflow.

Timeouts

Suspensions can have timeouts to prevent workflows from waiting indefinitely:

Multiple approvals

Handle multi-stage approvals:

Key takeaways

  • ctx.step.suspend() pauses workflow execution and waits for external input
  • No compute consumed while suspended — workflows can wait hours or days
  • Detect suspension by streaming workflow events with events.stream_workflow()
  • Resume with client.resume() providing workflow ID, execution ID, step key, and decision data
  • Use timeouts to prevent indefinite waiting
  • Build approval UIs by listening to suspend events and calling resume API
  • Multi-stage approvals supported with multiple suspend steps