esc
  • WorkflowsPages
  • Case studiesPages
  • Machine Learning FoundationsLearn
  • AI EngineeringLearn
  • AI Guardrails & Red TeamingLearn
  • UI/UXLearn
  • Design SystemsLearn
  • Production System DesignLearn
  • AI papersPages
  • Interview KitPages
  • Book a callContact
  • Download ResumeContact
Let’s talk

I’ll build the agent for it.

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.

12 min readBeginnerVery common · estimateFacts checked 26 November 2026

Say it out loud

Read it once, then say it without looking. Start with the short one; use the long one when they ask you to go deeper.

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.

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.

Key words

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."

Who approves the action?

Agent wants to act

sends, pays, deletes or changes

Small and reversible?

inside the agent's limit

Irreversible or external?

payouts, customer emails, deletes

Agent goes ahead

logged, inside its limits

Human approves first

sees the exact action

  1. 1Small, easy to undo steps are checked first.
  2. 2Anything that moves money, mail or data outside goes to a person.
  3. 3Code logs the action and checks the limits, then the agent runs it.
  4. 4The person sees the exact action before anything runs.
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.

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. 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. 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. 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. 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.

The pause and the resume

Agent proposes a payout

the model only asks, code decides

Code pauses the run

saves state and waits

Reviewer approves

pays exactly this, logged

Reviewer says no

stops the run

Payout made

with the approver's name

Nothing paid

the agent is told why

  1. 1The run pauses here, before any money moves.
  2. 2The reviewer sees the exact payout and decides.
  3. 3A reviewer who says no ends the run.
  4. 4Code pays the exact amount and records who approved.
  5. 5Nothing moves, and the agent gets the reason.
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.

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

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."

    BetterReviewers stop reading. Gate the risky steps and let the routine ones run inside set limits.

  • Trap"A human at the end checks everything."

    BetterA 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."

    BetterA 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?

Quick check

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

Can you answer these from memory?

Flash cards · tap a card to flip it

1 / 6

What will they ask next?

  1. Q173How do you stop endless agent loops?11 min
  2. Q174What are common agent failure modes?12 min
  3. Q179Excessive agency and least privilege?11 min
  4. Q181How do you evaluate agents?11 min
  5. Q186What is tool-result poisoning?13 min

Learn it in depth

Last updated on 26 November 2026

Building an agent that can spend money or send mail?

I design and build AI agents, the interface and the system behind them, including the approval steps and the logs. Book a short call and tell me what your agent needs to do.