Human in the loop AI agents: when a person should review the output

For agent builders4 min read

With human in the loop AI agents, a person checks or approves what the agent does at chosen points. The skill is picking the points: before actions that cannot be undone, and on a sample of everything else. This post covers where to place reviews, how to make them consistent, and a small routing function.

Human in the loop AI agents: two kinds of review

A gate stops the agent until a person decides. A sample lets the agent finish and a person checks a share of the results afterwards. Use gates where a mistake is costly or cannot be undone. Use samples to learn how the agent is doing overall.

Frameworks build this in. LangGraph's overview lists human-in-the-loop as a core feature, letting you inspect and modify agent state at any point. AgentOven's docs describe human gate steps in a recipe, which pause the run until someone approves or rejects. Anthropic's article on building agents also recommends human checkpoints, along with stopping conditions, to keep control of an agent.

Source: LangGraph overview(opens in a new tab)

Source: Recipes (AgentOven docs)(opens in a new tab)

Source: Building effective agents(opens in a new tab)

Where to put the gates

ActionReviewed how
Reads data, drafts a replySampled after the fact
Sends a message to a customerGate at first, then sample as trust grows
Spends money or changes a recordGate every time
Deletes anythingGate every time, with the target shown

The reviewer must see what the agent will do as well as what it says. A good approval screen shows the exact action, its arguments and the evidence behind it. An approve button next to a vague summary trains people to click yes.

A routing function

The function below decides what happens to each proposed action. It gates anything irreversible or uncertain, and picks a random tenth of the rest for later review. The threshold and the rate are numbers you set from your own data.

Python
import random def route(action, sample_rate=0.1, min_confidence=0.6, rng=random):    if action["irreversible"]:        return "approve_first"    if action.get("confidence", 0.0) < min_confidence:        return "approve_first"    if rng.random() < sample_rate:        return "review_later"    return "auto" rng = random.Random(3)print(route({"irreversible": True}, rng=rng))print(route({"irreversible": False, "confidence": 0.4}, rng=rng))print([route({"irreversible": False, "confidence": 0.9}, rng=rng)       for _ in range(5)])

Model-reported confidence is a weak signal. Use it only if you have checked it against reviewer decisions. Rules about the action itself, like irreversible or over a spending limit, are safer.

Make reviewers agree

Anthropic's eval guide lists human graders as the standard for quality and the way to calibrate model-based graders, but they are slow and expensive. It also names inter-annotator agreement as a way to check that people are applying the same standard.

Source: Demystifying evals for AI agents(opens in a new tab)

Write a rubric of three to five yes or no questions, such as: did the action match the request, were the arguments correct, did the answer use the tool result, was anything unsupported added. Have two people score the same fifty outputs and compare.

Python
def agreement(a, b):    same = sum(x == y for x, y in zip(a, b))    return same / len(a) reviewer_1 = [1, 1, 0, 1, 0, 1, 1, 0]reviewer_2 = [1, 1, 0, 0, 0, 1, 1, 1]print(agreement(reviewer_1, reviewer_2))   # 0.75

Plain percent agreement is crude, since two people can agree by chance, but it is enough to show whether the rubric works. If agreement is low, the rubric is vague. Discuss the cases where they split, and rewrite the question that caused it.

Keep reviewers effective

Review quality drops when reviewers are tired or rushed. Keep batches short, show the task and the evidence together on one screen, and let reviewers mark an item as unclear instead of forcing a yes or no. Unclear items are a signal about the task or the rubric, and they should go back to whoever wrote them.

Track how long approvals take and how often reviewers reject. A gate that approves ninety-nine of a hundred actions in two seconds each is probably not being read. Either the gate is in the wrong place, or the screen does not show enough to decide.

Use reviews to improve the agent

Each rejected action is a test case. Save it with the reviewer's reason in a short written form, then add it to your eval set. A reason such as the wrong customer account was used is more useful than a bare reject, because it names the failure to fix.

Curatrain's experts work on labelled data with written reasons and on reference answers with rubrics, which is the shape of review described here.