Design

Pattern 24 of 26

Human-in-the-Loop

Full autonomy sounds great until something gets deleted

I have run agents that behaved perfectly in staging and did something alarming in production. Human-in-the-loop patterns are checkpoints where the agent stops and waits, rather than deciding unilaterally. The question is not whether to have checkpoints, it is where to put them. That depends on how reversible the action is, and how much you have actually tested the agent, not how confident you feel about it.

Why it matters

Irreversibility is the thing that bites you. Drafting a document wrong is annoying. Deleting a branch, sending a mass email, pushing to production without review, those are a different category. Tight approval gates at the start are not a sign of distrust. They are how you build the evidence to loosen them later.

Deep Dive

The calibration question is: what happens if this step goes wrong? Low-risk, reversible actions can run without interruption. Searching the web, reading files, drafting text. Nobody needs to approve those. But some actions are hard or impossible to undo. Deleting records, sending emails, merging PRs, deploying to production. Those are the ones where a short pause is worth far more than the friction cost. The challenge is making the approval path fast enough that developers actually use it instead of working around it.

LangGraph added interrupt() in January 2025, which made the mechanics concrete. The graph pauses at a specific node, the pending state surfaces to a reviewer, and execution resumes on approval. The reviewer can also modify the state before resuming, so it is not just a binary yes or no. The agent's plan can be corrected mid-flight. HumanLayer takes a different approach: it routes approval requests to Slack or email, which means the decision happens in a tool the reviewer is already using rather than a separate interface they have to go check.

The direction the field is moving is toward human-on-the-loop rather than human-in-the-loop. In that model the agent runs autonomously and a person monitors for exceptions, rather than approving each action. Anthropic's December 2024 guidance is explicit that this is a destination you earn, not a default you start with. An agent that has completed 100 tasks correctly has built up a track record. An agent you deployed last week to a production environment it has never touched has not. Start tight. The data will tell you when to widen.

In the Wild

LangGraph interrupt()
HumanLayer (Slack/email/Discord)
CopilotKit pause execution
Rent a Human (MCP)

Go Deeper

ARTICLEMaking it Easier to Build Human-in-the-Loop Agents with interruptGUIDEBuilding Effective AgentsPAPERA Survey of Human-in-the-Loop for Machine LearningDOCSHumanLayer

Related Patterns