← All questions
AgentsMedium· Agent Planning & Reasoning

How do you implement Human-in-the-Loop for a production...

The gating question for HITL isn’t “is this task hard” — it’s “can this be undone.” An agent that’s very confident about sending an email or processing a payment still needs a pause before doing it, because a mistake there can’t be walked back; an agent uncertain about a read-only lookup doesn’t need a human at all, because getting it wrong costs nothing to retry.

In practice this becomes tiered thresholds rather than a single approve/deny gate:

  • Below a low-stakes threshold (a $50 refund with a verified reason), proceed automatically.
  • Above that, pause and route to a human approver with the proposed action shown explicitly — not just “approve this step” but “here is exactly what will happen if you say yes.”
  • Past a second, higher threshold, require more than one approver, or route to a different team entirely (finance, legal) rather than the same approval path used for routine cases.
  • Certain categories — anything touching medical or legal advice, for instance — always escalate regardless of confidence or amount, because the stakes aren’t captured by a dollar threshold.

The implementation detail that actually matters is state persistence across the pause: the agent has to serialize its state, wait for a response that might take hours, and resume from exactly where it left off — not restart the task once the human responds.

Code playground (Python)