---
title: "What is human-in-the-loop (HITL) for AI agents?"
description: "Human-in-the-loop means an AI agent pauses so a person can approve, edit, or reject an action before it runs. See how approval gates work in MCP and frameworks."
type: "glossary-term"
canonical_url: "https://theaiengineering.com/glossary/human-in-the-loop"
markdown_url: "https://theaiengineering.com/glossary/human-in-the-loop.md"
topic: "AI agents"
author: "The AI Engineering Editors"
publisher: "The AI Engineering"
updated: "2026-11-06"
keywords: ["Human-in-the-loop","HITL","human approval","tool approval"]
citation: "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"
---

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

Also called HITL, human approval, tool approval.

> **Definition of Human-in-the-loop:** 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](https://theaiengineering.com/glossary/tool-calling) 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](https://theaiengineering.com/glossary/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()`](https://docs.langchain.com/oss/python/langgraph/interrupts) 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`](https://openai.github.io/openai-agents-python/human_in_the_loop/) 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](https://theaiengineering.com/glossary/model-context-protocol) assigns approval to the host application, not to the server. The [current tools specification](https://modelcontextprotocol.io/specification/2026-07-28/server/tools) 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](https://platform.claude.com/docs/en/agents-and-tools/tool-use/computer-use-tool) 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](https://theaiengineering.com/glossary/agent-sandbox) and [guardrails](https://theaiengineering.com/glossary/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](https://theaiengineering.com/articles/how-to-build-an-ai-agent) writes an approval gate in Python and tests the denied-approval path.

## Related terms

- [AI agent](https://theaiengineering.com/glossary/ai-agent): An AI agent is a software system in which a large language model runs in a loop, calling tools, reading their results, and repeating until the task is complete or a stop condition is reached.
- [Tool calling](https://theaiengineering.com/glossary/tool-calling): Tool calling is an LLM capability in which the model, given a list of tool definitions, outputs a structured request naming a tool and its arguments, which the application executes and returns.
- [Guardrails](https://theaiengineering.com/glossary/guardrails): Guardrails are programmatic checks placed around a large language model that validate, filter, or block inputs, outputs, and tool calls so an AI application stays within its safety, security, and policy limits.
- [Prompt injection](https://theaiengineering.com/glossary/prompt-injection): Prompt injection is an attack in which text supplied to a large language model, typed by a user or hidden in content the model reads, alters the application's intended behavior or output.
- [Model Context Protocol (MCP)](https://theaiengineering.com/glossary/model-context-protocol): Model Context Protocol (MCP) is an open protocol, introduced by Anthropic in November 2024, that standardizes how AI applications connect to external tools, data sources, and prompts through MCP servers.
- [Agent sandbox](https://theaiengineering.com/glossary/agent-sandbox): An agent sandbox is an isolated execution environment in which an AI agent runs code, shell commands, or a browser, with enforced limits on the files, network hosts, and credentials it can reach.

## Guides that cover human-in-the-loop

- [AI agent frameworks compared: LangGraph, CrewAI, ADK, and more](https://theaiengineering.com/articles/ai-agent-frameworks): An AI agent frameworks comparison of LangGraph, LangChain, CrewAI, the OpenAI, Claude, and Google SDKs, Pydantic AI, Mastra, and more, by language and license.
- [A2A protocol vs MCP: differences and when to use each](https://theaiengineering.com/articles/a2a-vs-mcp): A2A protocol vs MCP: A2A connects AI agents to other agents, and MCP connects an agent to tools and data. Compare agent cards, tasks, transports, and security.
- [How to build an AI agent: a step-by-step guide in Python](https://theaiengineering.com/articles/how-to-build-an-ai-agent): Learn how to build an AI agent from scratch in Python: when you need one, tool schemas, the agent loop, stop conditions, guardrails, evals, and tracing.
- [What is tool calling? How LLM function calling works](https://theaiengineering.com/articles/tool-calling): Tool calling lets an LLM request actions from your code through structured calls. Learn the request loop, parallel calls, structured outputs, security, and MCP.
- [What are AI agents? How agents work and when to use one](https://theaiengineering.com/articles/what-are-ai-agents): AI agents are LLM systems that call tools in a loop until a task is done. Learn how the loop works, agents vs agentic AI, examples, failure modes, and limits.
- [What is the Model Context Protocol (MCP)? How it works](https://theaiengineering.com/articles/what-is-model-context-protocol): The Model Context Protocol (MCP) is an open standard for connecting AI apps to tools and data. Learn its architecture, transports, tool calls, and security.
- [AI coding agents: how they work and how the major tools compare](https://theaiengineering.com/articles/ai-coding-agents): AI coding agents compared: how they differ from autocomplete, the four main categories, a comparison table of major tools, and how to evaluate and secure them.
- [Agentic workflows: five patterns and when to use each](https://theaiengineering.com/articles/agentic-workflows): Agentic workflows run LLM and tool calls through steps fixed in code. Learn five patterns, their cost and latency, failure modes, and when to use an agent.
- [Claude Code vs Cursor: how the two coding agents differ](https://theaiengineering.com/articles/claude-code-vs-cursor): Claude Code vs Cursor compared: terminal agent vs AI editor, models, subagents, hooks, rules files, code review, CI use, pricing, and enterprise controls.
- [How to build an MCP server: a Python and TypeScript tutorial](https://theaiengineering.com/articles/how-to-build-an-mcp-server): Learn how to build an MCP server with the official Python and TypeScript SDKs: tools, resources, transports, testing, client config, and production security.
- [AI agent evaluation: metrics, graders, and how to test agents](https://theaiengineering.com/articles/ai-agent-evaluation): AI agent evaluation guide: measure task success, tool use, safety, cost, and pass^k reliability with code graders, LLM judges, eval sets from traces, and CI.
- [AI engineer roadmap: skills, projects, and resources by stage](https://theaiengineering.com/articles/ai-engineer-roadmap): A practical AI engineer roadmap in seven stages, each with the skills to learn, a project to ship, and resources worth the time, from Python to production.

Part of the [AI agents](https://theaiengineering.com/topics/ai-agents) topic hub.

## 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: 2026-11-06
- URL: https://theaiengineering.com/glossary/human-in-the-loop
- Markdown: https://theaiengineering.com/glossary/human-in-the-loop.md
