# Human-in-the-loop

The agent pauses before a risky action and waits for a person to approve it.

AI developers · Part 04: Agents · Card 11 of 11 · Last updated 2026-10-13

## Analogy

A required PR review before merge. The bot can propose; a human presses the button.

## In an agent

Use it for write actions: refunds, deletes, emails to customers.

## Practice

### Flashcards

- **What is human-in-the-loop?** The agent pauses for a person to approve an action before it runs.
- **Interview: four guardrails against harmful actions?** Step limits, Zod validation of arguments, least-privilege tools with approval for writes, and treating tool output as untrusted.

### Interview questions

**How do you stop an agent doing something harmful?**

- A maximum step limit.
- Zod validation of every tool argument.
- Least-privilege tools and human approval for write actions.
- Treat all tool output as untrusted data to defend against prompt injection.

## Questions people ask

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

The agent pauses before a risky action and waits for a person to approve it. The agent can propose a refund, a delete or an email to a customer, but a human presses the button. It is the agent version of a required code review before merging.

### How do I add an approval step to an agent?

Mark write tools as needing approval. When the model calls one, save the agent's state, show the proposed action to a person, and stop. When they approve, resume from the saved state and run the tool. LangGraph's interrupt function and a checkpointer handle this pause and resume for you.

## Related concepts

- [Guardrails](https://studyvisually.com/learn/tech/ai-developers/production/guardrails)
- [Least privilege](https://studyvisually.com/learn/tech/ai-developers/production/least-privilege)
- [Stop conditions](https://studyvisually.com/learn/tech/ai-developers/agents/stop-conditions)
- [interrupt()](https://studyvisually.com/learn/tech/ai-developers/langchain-langgraph/interrupt)

Web page: https://studyvisually.com/learn/tech/ai-developers/agents/human-in-the-loop
Study this card in the app: https://studyvisually.com/app/learn?category=ai-developers&card=human-in-the-loop
