Human-in-the-Loop Overview
Between an agent proposing an action and executing it sits a risk assessment that routes high-impact actions to a human for approval — the architectural control that makes autonomous systems deployable.
You have not marked these as done yet. Read on anyway if they feel familiar; come back to them if something here does not land.
Key points
- The gate is code in the executor, not instructions in the prompt.
- Gate actions whose wrong execution costs far more than a pause: communications, money, deletion, publishing, production.
- Read-only actions usually run free; data exposure is the exception.
- Calibrate thresholds from approval and reversal rates, not guesses.
- Paused runs must be durable across restarts.
- The gate holds even when the model is manipulated by injected content.
Approval gate simulator
In-the-loop: a human approves before execution. On-the-loop: it executes and a human can intervene or roll back. Escalation: when no approver responds within the SLA, fail closed for irreversible actions.
The gate
An agent that can send email, move money, delete data, publish content or change production will eventually do one of those wrongly. Prompting it to "be careful" is not a control. The control is a gate in the execution path: the agent proposes an action, code classifies its risk, and above a threshold the action waits for a human decision before anything runs.
The gate lives in the tool-execution layer, not in the model. The model emits send_email(to, subject, body) exactly as before; the executor intercepts, computes a risk class, and either runs it, asks, or refuses. This means the control holds even under Prompt Injection — an injected instruction can make the model *propose* a transfer, but cannot skip the gate.
Which actions
The classic set: sending communications (email, Slack, SMS — reputational, unrecallable), moving money (refunds, payouts, purchases), deleting or overwriting data, publishing content (public pages, app store listings), and modifying production (deploys, config, IAM). What they share is that the cost of a wrong action is far higher than the cost of a 30-second pause.
Read-only actions almost never need a gate; the exception is reading data whose exposure is itself the harm (PII exports), which Tool Misuse and Data Exfiltration covers.
- Draft the email, show it, send on click — the approval is the send, not the draft.
- Refund under 20 EUR: auto; 20–500 EUR: approval; over 500 EUR: two approvers (Approval Gates and Risk Classes).
DELETEandDROPare gated regardless of who asked;SELECTis not.
Cost of the gate
Gates add latency (human response time — minutes to hours) and require a UI, a queue, timeouts and escalation (In-the-Loop vs On-the-Loop and Escalation). If every action needs approval, the agent is a slow form; if none does, it is a liability. Calibrate by measuring: what fraction of approvals are rubber-stamped? Those can move to auto-with-audit. Which auto actions were later reverted? Those need a gate.
Persist the agent's state while it waits. A run paused for approval must survive a process restart, which is why workflow graphs with checkpointing (Workflow State Graph) pair naturally with HITL.
When to use — and when not to
- Any agent with tools that have external side effects.
- Early deployment of a new agent, before evals prove its action accuracy.
- Regulated domains where a human must be accountable for the decision.
- Purely read-only or advisory agents — an approval on a summary is theatre.
- Batch tasks with thousands of low-risk actions — gate the batch, not each item.
- As a substitute for fixing an agent that proposes bad actions 30% of the time.
Failure modes
Reference · showHide
- Gate implemented as a prompt instruction; bypassed by injection.
- Approval fatigue: humans click approve without reading (Approval Gates and Risk Classes on UI design).
- No timeout — runs pile up waiting for someone who is off shift.
- State lost on restart; approved action executes twice or never.
- Risk classifier keyed on tool name only, missing a high-risk argument (
amount=50000).
Tradeoffs
Latency is dominated by human response time; reliability rating reflects prevented incidents, not throughput.
Check yourself
Answer out loud or on paper first, then compare. These come from the interview questions linked to this lesson.
How would you prevent an agent from calling a destructive tool incorrectly?
Show a strong answerHide the answer
The prompt is a suggestion, not a control. Controls live in code around the tool. First, schema and validation: the tool takes typed, narrow arguments (a specific resource id, not a free-form query), and the handler validates them against reality before acting, e.g. the id exists and belongs to the current user. See Argument Validation and Tool Schemas.
Second, least privilege: the agent gets a credential scoped to what the task needs; a "summarise tickets" agent has no delete permission at all. Third, an approval gate for irreversible actions: the tool returns a pending action that a human or a deterministic policy confirms, and the confirmation step is outside the model's control. See Tool Permissions and Least Privilege and Approval Gates and Risk Classes.
Fourth, safe execution: idempotency keys so retries cannot repeat the action, dry-run or soft-delete modes, and rate limits on destructive calls. Finally, tracing and alerting on every destructive call so misuse is visible within minutes.
Full interview question, with follow-ups and red flags →How do you apply least privilege to an agent's tools, and why is it harder than for a normal service?
Show a strong answerHide the answer
Least privilege means the agent can only do what this task for this user requires. Mechanisms: expose a per-task subset of tools rather than the whole catalogue; back tools with credentials scoped to the user's own permissions (the agent acts as the user, not as an admin); split read and write tools so read-only tasks never carry write capability; and constrain arguments (tenant id injected by the tool handler, not supplied by the model). See Tool Permissions and Least Privilege and Permissions, Authentication and Authorisation.
It is harder than for a service because the caller is a model that decides at runtime what to call with what arguments, influenced by content it reads. A service calls the database the way its code says; an agent may call
deletebecause a document told it to. So the permission boundary must be enforced in the tool layer and the backend, never by the prompt, and should assume adversarial arguments.Operationally: credentials stay in the tool server, short-lived tokens per run, audit logs of every tool call with arguments, and alerts on calls outside the task's expected set.
Full interview question, with follow-ups and red flags →The human approval gate gets 500 requests a day. What happens?
Show a strong answerHide the answer
Approval fatigue; batch low-risk items, auto-approve by deterministic rules, gate only above a risk threshold, and audit samples.
Full interview question, with follow-ups and red flags →