What is human-in-the-loop (HITL) for AI agents?

Also called HITL, human approval, tool approval

Definition

Human-in-the-loop (HITL) is an agent design in which the run pauses at defined checkpoints, such as before a sensitive tool call, so a person can approve, edit, or reject the action.

Human-in-the-loop (HITL) is an agent design in which the run pauses at defined checkpoints so a person can approve, edit, or reject what the agent is about to do. The usual checkpoint sits before a tool call with side effects, such as a refund, a file deletion, or an outbound email. Because the action cannot run until a person agrees, HITL limits the damage when a model misreads a task or follows instructions planted through prompt injection.

How human-in-the-loop works#

Human-in-the-loop works by splitting an agent run at a checkpoint. When the model proposes a gated action, the runtime saves the run state, shows the call and its arguments to a person, and waits. The decision goes back into the run: an approval executes the call, an edit changes its arguments, and a rejection returns an error to the model.

Agent frameworks ship this as a primitive:

  • LangGraph. Calling interrupt() pauses graph execution, saves state through a checkpointer, and waits indefinitely. The application resumes the same thread with Command(resume=...), and the value it passes becomes the return value of interrupt().
  • OpenAI Agents SDK. A function tool marked needs_approval pauses the run and lists the pending call in result.interruptions. The application converts the result to a RunState, calls approve() or reject(), and runs it again. The state serializes to JSON, so the decision can arrive hours later.

A blocking approval callback works in a script. A web application instead persists the run, returns a pending status, and resumes when the approver responds, which is why durable state and HITL tend to ship together in agent frameworks.

Human-in-the-loop in MCP#

The Model Context Protocol assigns approval to the host application, not to the server. The current tools specification says there should always be "a human in the loop with the ability to deny tool invocations." Clients should show which tools are exposed, display tool inputs before calling the server, and ask for confirmation on sensitive operations.

The same page says clients must treat tool annotations as untrusted unless they come from a trusted server. A host can use annotations as a hint for which calls to gate, but a server can describe its tools however it likes, so the final list of gated tools belongs in host policy.

Choosing which actions to gate#

Gate actions by their consequences. Reads rarely need a person; payments, deletions, outbound messages, and permission changes usually do. Anthropic's computer use documentation gives a workable rule: ask a human to confirm decisions with meaningful real-world consequences and any task that needs affirmative consent, such as a financial transaction or agreeing to terms of service.

Enforce the gate in code, outside the prompt. A model that never sees the approval flag cannot argue its way past it. Actions that run without a person still need an agent sandbox and guardrails, and every approval or denial should land in the run's trace so reviewers can see who allowed what.

The guide to building an AI agent writes an approval gate in Python and tests the denied-approval path.

Cite this definition

The AI Engineering Editors. "What is human-in-the-loop (HITL) for AI agents?" The AI Engineering, updated Nov 06, 2026. https://theaiengineering.com/glossary/human-in-the-loop

Title
What is human-in-the-loop (HITL) for AI agents?
Author
The AI Engineering Editors
Publisher
The AI Engineering
Updated
View as Markdown

Part of the AI agents hub · Updated