Human-in-the-loop
Learn when AI agents need human approval gates, how to implement pause-and-resume in LangGraph, and how to calibrate the approval threshold to balance safety with autonomy.
TL;DR
- Agents make mistakes. Some mistakes are irreversible. Reversibility is the primary filter: irreversible actions always need an approval gate, reversible ones usually don't.
- Classify every action as reversible, partially reversible, or irreversible before designing your HITL strategy. This classification drives every downstream design decision.
- The approval gate pattern: agent builds a complete work plan, human reviews in plain English, human approves or edits, agent executes. One review per workflow, not one per action.
interrupt_beforein LangGraph pauses the graph, serializes state to the checkpointer, and returns without blocking any thread. Resume withinvoke(None, config)and the samethread_idon approval.- Progressive autonomy: start with approval on everything, track the false positive rate per action type, expand autonomy incrementally where the data justifies it.
- HITL is not a permanent safety crutch. It is a mechanism for building trust with evidence before removing oversight.
The problem it solves
A customer success agent processes 200 billing inquiries overnight. An edge case in the routing logic triggers a re-notification branch. By morning, 200 customers have each received a duplicate "Your invoice is overdue" email. Half of them already paid. Finance and customer success spend two days sending corrections, managing inbound complaints, and tracking down the root cause.
The direct cost was the duplicate emails. The real cost was the 40 hours of human remediation, the customer trust lost, and the compliance flag raised by a finance audit. None of this appeared in the demo run where the agent worked perfectly on the three test cases prepared for it.
This type of failure does not surface in controlled testing. It surfaces when the agent runs autonomously on real data with real edge cases, and when the action it takes has no undo button.
What is it?
Human-in-the-loop (HITL) is an architectural pattern where an AI agent pauses execution at defined checkpoints, presents its proposed actions to a human reviewer, and waits for explicit approval before continuing. Think of it like a surgeon requiring a second-surgeon sign-off before an irreversible procedure: the surgery proceeds with full speed and skill, but the point of no return requires a deliberate human decision.
The pattern is not about limiting agents. It is about placing the human decision point exactly where it provides maximum value: at the irreversible boundary.
How it works
Continue Reading with Premium
Unlock this article and every other in-depth system design guide on the platform with NotesFromSDE Premium.
Related Articles
Learn why production agents fail when demos succeed, how to reduce blast radius through sandboxing and cost limits, and what reliability patterns make AI agents safe to deploy.
Learn how LangGraph models agent state as a typed graph, how conditional edges enable complex branching workflows, and how persistent checkpointing lets agents survive crashes and support human approval gates.
Learn how the ReAct loop works, what tool use looks like under the hood, and why compound failure math is the central challenge every production agent team faces.
Learn how to structure multi-agent architectures with orchestrators and specialists, when parallel subagents save time, and how to handle failures when individual agents go wrong.