# When Do You Add a Human in the Loop?

> When to make an AI agent wait for a person, how to build the pause, and how to stop approvals becoming a rubber stamp, explained for your AI interview.

**In short:** Add a human when an agent is about to do something hard to undo, costly, or visible outside your system, such as paying money or emailing a customer. Build it as a pause in code: the run stops, saves its state and waits for a person to approve, change or reject the exact action.

AI and LLM interview question Q172, Agents and tool use. Beginner, very common (our estimate). From Venkat R. Murty's free Interview Kit: https://designervenkat.online/interview/ai/human-in-the-loop-for-ai-agents

## Say it in 30 seconds

Add a human when an agent is about to do something hard to undo, like paying money, deleting data or emailing a customer. The agent proposes the action, and my code pauses the run. A person sees the exact action and can approve, change or reject it. Small, reversible steps go straight through, so people only see the risky ones. I also watch for approval fatigue, because someone who clicks yes all day stops really checking.

## Say it in 2 minutes

I start by sorting actions by how bad a mistake would be. Reading a file or drafting a reply can run on its own. Anything that pays money, deletes data or messages a customer waits for a person. OWASP's 2026 guidance on excessive agency makes the same split: easily reversible actions can be auto-approved, and high-consequence or irreversible ones route to human review.

Building the pause is the technical part. When the agent proposes a payout, the run saves its state and stops. The reviewer sees the exact amount and account, then approves, changes or rejects it. The run resumes only after that answer. The code that pays must be safe to retry, so a second run never pays twice.

The trade-offs are real. If people approve too many things, they click yes without reading, which OWASP calls approval fatigue. So I keep the gate narrow, log every decision and sample the rest. A person at the end can't judge a twenty-step plan the agent built alone, so checks belong in the middle of the run too.

In an interview I say a human is one safety layer. The code gate does most of the work, and the person handles the rare cases that need judgement.

## What is a human in the loop, in plain words?

A human in the loop is a person who checks, or says yes to, an AI agent's action before it happens. The agent does the routine work, and a person steps in at the moves that are hard to undo or that touch money, private data or customers.

Think of a bank clerk who answers most customer questions alone, but needs a manager's signature before a transfer above a set limit. The clerk stays fast on everyday work, and the manager guards the big moves. An agent that handles insurance claims works the same way. It can read a claim, ask for photos and draft a reply, but a payout to a bank account changed last week waits for a claims handler.

- **Human in the loop:** A person approves or changes an action before the agent carries it out. LangGraph's docs call it HITL.
- **Approval gate:** Code that stops an action until a person says yes. The model can ask, but the gate decides.
- **Checkpoint:** A saved point in a run, so the agent can stop and pick up later without losing its place.
- **Tool call:** The model asking your code to run a function, such as sending a payout.

## When should a person approve an action?

Sort every action by how bad a mistake would be and whether it can be undone. OWASP's 2026 list puts this risk under LLM03, Excessive Agency, and its advice is: "A graduated enforcement policy (audit, warn, block, escalate) permits low-consequence or easily reversible actions to auto-approve, while high-consequence or irreversible ones route to human review."

*Diagram, Who approves the action?: The agent proposes an action, and the first question is whether it is small and easy to reverse. Those go straight through. Anything irreversible or external waits for a person, who sees the exact action before it runs.*
1. Small, easy to undo steps are checked first.
2. Anything that moves money, mail or data outside goes to a person.
3. Code logs the action and checks the limits, then the agent runs it.
4. The person sees the exact action before anything runs.

Take a motor insurer's claims agent. It reads each claim, asks for photos and can pay out up to $500 on its own. Here are two of its claims.

- **Claim CL-1041: $240 to a known account.** The agent pays on its own. The amount is small, inside its limit, and the account has been used for years.
- **Claim CL-1043: $310 to an account changed last week.** The agent can't pay on its own. A recent change of bank details is a reason to slow down, because the account may not belong to the claimant.

The rule lives in code, where it runs every time. A prompt can ask the model to pay only small claims, but a fooled or confused model may still ask for more. The gate checks the numbers, so a request above the limit is held whatever the model says.

For high-risk systems, the EU's AI Act asks for the same thing. Article 14 says high-risk AI systems must be designed so that they "can be effectively overseen by natural persons during the period in which they are in use".

## How do you build the pause?

The pause lives in the workflow itself, so the run really waits. LangGraph, a framework for building agent workflows, says that "One of the most common uses of interrupts is to pause before a critical action and ask for approval." When an interrupt is triggered, "LangGraph saves the graph state using its persistence layer and waits indefinitely until you resume execution."

1. **The agent proposes:** The model names the action and its inputs, such as a payout of $1,850. It does not run anything yet.
2. **Code pauses and saves:** Your code stops the run and saves its state to a database, so nothing is lost if the server restarts.
3. **A person decides:** The reviewer sees the exact amount and account, then approves, changes or rejects it. Anthropic's Agent SDK, a toolkit for building agents, offers the same choice to an app: 'Approve with changes: modify the input before execution (for example, sanitize paths, add constraints)'.
4. **Code resumes or stops:** An approval resumes the run. A rejection ends it and tells the agent why, so it doesn't retry the same payout.

*Diagram, The pause and the resume: One proposal, one pause and two outcomes. Code pays, never the model. The reviewer's choice decides which outcome happens, and the agent is told the reason when nothing is paid.*
1. The run pauses here, before any money moves.
2. The reviewer sees the exact payout and decides.
3. A reviewer who says no ends the run.
4. Code pays the exact amount and records who approved.
5. Nothing moves, and the agent gets the reason.

Here it is in plain Python. The model only proposes. The marked lines are the gate: they decide, and a person handles the held payouts.

```python
# A claims agent's payout gate. The model only proposes; this code decides.
AUTO_LIMIT = 500  # dollars the agent may pay on its own
CHANGED_RECENTLY = {"acct-9931"}  # bank details changed in the last 30 days

def gate(payout):
    if payout["account"] in CHANGED_RECENTLY:
        return "HOLD: new bank details, a handler must approve"
    if payout["amount"] > AUTO_LIMIT:
        return "HOLD: over $500, a handler must approve"
    return "PAY: inside the agent's limit"

def finish(payout, handler_says_yes):
    if handler_says_yes:
        return payout["id"] + " paid after handler approval"
    return payout["id"] + " stopped, handler said no"

claims = [
    {"id": "CL-1041", "amount": 240, "account": "acct-1187"},
    {"id": "CL-1042", "amount": 1850, "account": "acct-2204"},
    {"id": "CL-1043", "amount": 310, "account": "acct-9931"},
]
for claim in claims:
    print(claim["id"], gate(claim))
print(finish(claims[1], handler_says_yes=True))
print(finish(claims[2], handler_says_yes=False))
```

Output:

```text
CL-1041 PAY: inside the agent's limit
CL-1042 HOLD: over $500, a handler must approve
CL-1043 HOLD: new bank details, a handler must approve
CL-1042 paid after handler approval
CL-1043 stopped, handler said no
```

> **Tip:** Don't wrap the pause in a catch-all try/except (Python's way of catching errors). LangGraph's docs warn that "If you wrap the interrupt call in a try/except block, you will catch this exception and the interrupt will not be passed back to the graph." Catch only the specific errors you expect.

Actions that change the outside world, like a payment, need care too. If a payout is sent before the pause and the run restarts, it could pay twice. LangGraph's docs advise: "Use idempotent operations or deduplicate writes in the external system." Idempotent means running an action twice gives the same result as running it once.

### How would you stop approvals becoming a rubber stamp (a yes given without looking)?

If a reviewer approves three hundred items a day, most get a click without a proper look. OWASP's 2026 prompt-injection guidance warns that "approval fatigue degrades reviewer judgment at volume." The fix is fewer, clearer approvals.

- **Gate only the risky actions:** Small, reversible steps stay automatic. Fewer approvals means each one gets read.
- **Show what matters:** Put the amount, the account change and the reason on one screen, so the reviewer sees the whole case.
- **Set thresholds that escalate:** OWASP suggests limits that halt, rate-limit or escalate for human review if those thresholds are exceeded. An agent that suddenly makes two hundred payouts in an hour stops.
- **Sample and audit the rest:** Check a random share of the automatic actions after they happen, and log every decision with its reason.

Measure it. Track how often reviewers reject, and how long they take. A reviewer who never rejects, or who approves in two seconds, is a sign that the gate is too wide.

## What does the interviewer want to hear?

**A strong answer covers**

- [ ] A plain rule: approve by how bad and how reversible an action is, written down in advance.
- [ ] What the pause is: the run stops, its state is saved, and a person answers.
- [ ] Approve, change or reject, and what each one does to the run.
- [ ] Why the gate lives in code, not in the prompt.
- [ ] Idempotent actions, so a resumed run never pays twice.
- [ ] Approval fatigue, and how you keep approvals rare and readable.

**Common traps**

- Trap: "Put a human on every step." Better: Reviewers stop reading. Gate the risky steps and let the routine ones run inside set limits.
- Trap: "A human at the end checks everything." Better: A person can't judge a long plan at the end. Add checks before each risky step, not only after.
- Trap: "The model can ask itself for approval." Better: A model judging its own action is the same mind that may have been fooled. Approval comes from a person or from code.

## Can you spot the missing approval?

**Spot the problem:** An agent on a hospital's supply team can reorder stock. Which action needs a person to approve it first?

A. Reordering 20 boxes of gauze from the usual supplier, within the set budget.
B. Changing the supplier's bank details, then sending a $42,000 order.
C. Writing a note to the team that summarises last week's stock counts.
D. Reading the shared inventory sheet before drafting the order list.

**Answer:** B. Changing payment details and sending a large order move money and are hard to undo, so a person approves them. The small reorder and the read-only steps can run on their own inside set limits.

**Quick check:** A claims agent wants to pay $1,850 to an account changed last week. What is the best design?

A. Let the model decide, since it read the claim.
B. A code gate holds the payout until a claims handler approves it.
C. Add a line to the system prompt saying not to pay large sums.
D. Pay it, then review the logs once a month.

**Answer:** B. The gate sits in code and stops the payout before it runs. A prompt line can be ignored by a fooled model, and a monthly review finds the money only after it has left.

## Can you answer these from memory?

**Flash cards**

- **When add a human?** Before actions that are hard to undo, cost money, or reach customers.
- **What about small, reversible steps?** Let the agent run them inside set limits, with a log of each one.
- **What saves the run during a pause?** A checkpoint: the state is saved, and the run waits until a person answers.
- **What can the reviewer do?** Approve, change or reject the exact action. Each choice changes the run.
- **Why keep the gate in code?** A fooled model can ignore a prompt rule. Code checks the numbers every time.
- **What is approval fatigue?** Reviewers click yes so often that they stop really checking.

## Likely follow-up questions

- Q173 How do you stop endless agent loops? https://designervenkat.online/interview/ai/how-do-you-stop-endless-agent-loops
- Q174 What are common agent failure modes? https://designervenkat.online/interview/ai/common-ai-agent-failure-modes
- Q179 Excessive agency and least privilege? https://designervenkat.online/interview/ai/excessive-agency-and-least-privilege
- Q181 How do you evaluate agents? https://designervenkat.online/interview/ai/how-to-evaluate-ai-agents
- Q186 What is tool-result poisoning? https://designervenkat.online/interview/ai/what-is-tool-result-poisoning

## Learn it in depth

- [AI Agents](https://designervenkat.online/learn/ai-engineering/ai-agents)
- [Agentic AI security](https://designervenkat.online/learn/ai-guardrails/agentic-ai-security)
