Human-in-the-Loop
Human-in-the-loop durable tasks pause for human review or approval before continuing. An AI agent proposes an action, a human approves or rejects it, and the workflow resumes with the decision. When the human responds, the task picks up exactly where it left off.
The task pauses on a durable event, freeing the worker slot until the approval arrives. If your workflow is a fixed DAG and the approval gate is known at definition time, Event Conditions are a simpler alternative. It is your responsibility to emit the event from a different part of your application to restore the task.
Step-by-step walkthrough
You’ll build a durable task that proposes an action, waits for a human to push an approval event, and resumes with the decision.
Write a wait-for-approval helper
Define a helper that calls WaitForEvent to pause execution until a human responds. The CEL expression filters on the workflow run ID so the event only matches the specific task that is waiting. Hatchet frees the worker slot while the task is suspended and resumes it when the matching event arrives.
Define the approval task
Create a durable task that proposes an action, calls the helper from Step 1, and branches on the result.
Push the approval event
When the human clicks Approve or Reject in your UI, your frontend or API pushes the event to Hatchet. Include the runId in the payload so the CEL expression in Step 1 matches it to the correct waiting task.
Run the worker
Register and start the worker. Use Branching to route on approve vs reject from the event payload.
Always set an execution timeout on the durable task itself so it does not wait indefinitely if a human never responds. See Timeouts for configuration.
Common Patterns
| Pattern | Description |
|---|---|
| Content moderation | Agent flags content; human approves or rejects before publish |
| Financial approvals | Agent proposes payment or transfer; human approves via dashboard |
| Customer support escalation | Agent drafts response; human reviews and sends, or edits before sending |
| LLM output review | Agent generates copy or code; human approves before it goes live |
For DAG workflows with a fixed approval gate, use Event Conditions. For agent loops where the decision to wait is dynamic, use a durable task with WaitForEvent.
Related Patterns
Pause workflows for external signals (events or sleep) without holding slots.
Long WaitsAgent workflows that may need human approval at decision points.
AI AgentsRoute workflow behavior based on approve vs reject from the event payload.
BranchingDeclare approval gates in DAG workflows when the wait is known at definition time.
Event ConditionsNext Steps
- Durable Events:
WaitForEventAPI and event filters - Pushing Events: push approval events from your frontend or API
- Event Conditions: approval gates in DAG workflows
- Long Waits: general pattern for durable pauses
- Branching: route on approve vs reject