We use cookies

We use cookies to ensure you get the best experience on our website. For more information on how we use cookies, please see our cookie policy.

By clicking "Accept", you agree to our use of cookies.
Learn more.

CookbooksHuman-in-the-Loop

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

PatternDescription
Content moderationAgent flags content; human approves or rejects before publish
Financial approvalsAgent proposes payment or transfer; human approves via dashboard
Customer support escalationAgent drafts response; human reviews and sends, or edits before sending
LLM output reviewAgent 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.

Next Steps