Skip to content

Courses / Agentic AI / Module 9

Module 9: Human-in-the-loop: approvals, interrupts, escalation

8 h · theory 2 · hands-on 3 · project 2 · revision 1

You will be able to

  • Require approval for actions that change systems
  • Show the reviewer what will happen and why
  • Escalate when the agent is unsure
  • Log who approved what, and when

Capstone increment: Approval gate for every change, with an audit log.

Job-description skills: Human-in-the-loop and approvals · Lab tools: langgraph, fastapi

1. Autonomy is a dial

An agent that can change production systems needs a person in the loop for the actions that matter. The skill is choosing which ones: gate too little and the agent eventually does damage; gate everything and reviewers approve without reading, which is worse than no gate.

The pattern: the agent proposes, your code classifies the action, the run pauses with its state saved, a reviewer sees exactly what will happen and why, and the run resumes executing exactly what was approved. Every decision is logged.

Proposed actiontool + argsClassifyblast radius, riskPause runinterrupt + checkpointReviewerdiff, evidence, whyResumeexecute exactly thisReadsrun immediatelyRejectedreason → agentAudit logwho, what, whenCode decides what needs a humanOther outcomesread onlyreject
Approve the exact action, not a description of it. If the arguments change after approval, ask again.

2. Gate by blast radius, decided in code

Classify every tool by blast radius in code you control: reads run freely; reversible changes may run automatically within limits; irreversible actions (deleting data, sending messages to customers, moving money, rotating credentials) always wait. Add a risk signal on top for reversible changes that are dangerous in context, such as a restart at peak hour.

Never let the model’s own opinion of its risk be the only gate. Use the tool below to see why.

Which actions wait for a human?18 proposed actions; 5 would have caused harm. Reads always run. Pick a gating rule and keep reviewers’ load bearable.

Approvals requested 4 · ran automatically 14 · harmful actions that ran without a human 2 of 5

ActionBlast radiusModel’s riskRoute
Read the last 500 API error logs read0.05ran
Query p95 latency for checkout read0.05ran
List deploys in the last 24 hours read0.08ran
Read the payments runbook read0.04ran
Search open incidents for 'timeout' read0.06ran
Restart one staging pod reversible0.20ran
Add one replica to the checkout service reversible0.30ran
Open a ticket for the DB team reversible0.15ran
Raise the DB connection pool from 50 to 80 reversible0.45ran
Roll back checkout to v2.2 reversible0.55ran
Restart the production database at peak hour ⚠ harmfulreversible0.72waits for approval
Scale the payments service to 0 replicas ⚠ harmfulreversible0.64waits for approval
Post the incident summary to #status irreversible0.40ran
Email the customer list about the outage ⚠ harmfulirreversible0.50ran: caused harm
Drop the sessions table to clear stuck locks ⚠ harmfulirreversible0.25ran: caused harm
Delete last month's log bucket to free space ⚠ harmfulirreversible0.90waits for approval
Rotate the payments API key irreversible0.60waits for approval
Page the on-call DBA irreversible0.30ran
Guided experiments
  1. Gate on the model’s risk score at 0.60. Which harmful actions ran? Why did the model rate dropping a table as low risk?
  2. Lower the threshold until nothing harmful slips through. How many approvals is that? What happens to reviewers who get that many requests a day?
  3. Try “only irreversible actions”. What does it miss, and why is “reversible” not the same as “safe” at peak hour?
  4. Use “irreversible, or risk ≥ threshold”. Find the threshold that catches all five with the fewest approvals. Which rule is decided by your code, and which by the model?
Common misconception: “The agent will ask when it’s unsure.” Models are often confidently wrong about exactly the actions that hurt most. The gate must not depend on the model choosing to use it.

3. Show reviewers what will happen

An approval request should let a reviewer decide in under a minute: the exact action as a diff or the exact arguments, the evidence that led to it, the expected effect and risk, how to undo it, and when the request expires. Approve the exact call: hash the tool and arguments at review time and refuse to execute anything different.

Keep the volume low enough that each request gets real attention. If reviewers see dozens a day, move safe classes of change to automatic with limits, or batch them, rather than training people to click Approve.

4. Escalate when the agent is unsure

Some situations call for handing the task to a person rather than asking for a yes: conflicting evidence, repeated tool failures, a budget nearly spent, or an incident outside the agent’s known scenarios. Define these triggers in code and route escalations to the right on-call person with a summary of what was found and tried.

An escalation is a success, not a failure, if it arrives early with good context. Track how often it happens and why; the reasons point at the next tools, runbooks or evals to build.

5. Audit everything

Log every approval request and decision: who, what (tool and arguments), why, when, the outcome and the run it belonged to. Make the log append-only and keep it with the run’s trace. You will need it for incident reviews, for compliance and for answering “why did the agent do that?”.

Watch the numbers: approvals requested per day, approval rate, time to decision, and changes rejected or rolled back. A rising rejection rate means the agent’s proposals need work; a near-100% approval rate with seconds per decision means the gate has become a rubber stamp.

In production: Approval links in chat tools must authenticate the reviewer and check that they may approve this action. A forwarded link must not let anyone approve.

Hands-on: coding window

The coding window and the full VS Code lab are available after you sign in.

Sign in to code

Labs

Lab 9.1: Interrupt-based approvals

Classify capstone tools by blast radius; on a change, call interrupt() with the request; expose GET /approvals and POST /approvals/{id} with approve or reject and a reason.

Expected: Changes wait; rejections reach the agent as a tool result; approvals resume the thread.

Lab 9.2: A reviewer card

Render each request as a diff with evidence, risk, undo and expiry, delivered to a web page or a chat webhook with authenticated approve and reject.

Expected: A reviewer can decide without opening the trace.

Lab 9.3: Audit and metrics (capstone increment)

Write every request and decision to an append-only audit table with the args hash, and add approval metrics to the dashboard.

Expected: The audit log answers who approved what and when; the dashboard shows rate and time to decision.

Go deeper

Videos

Further reading

  • Docs Interrupts · LangGraph docs. Pause a graph for approval or edits and resume it with the human's answer.
  • Paper Levels of Autonomy for AI Agents · Feng, McDonald and Zhang, 2025. Five levels defined by the user's role, from operator to observer: a vocabulary for the autonomy dial.
  • Article Building effective agents · Anthropic. The clearest guide to when you need an agent at all, and the workflow patterns to try first.

GitHub repositories

  • humanlayer/humanlayer: Approval and human-contact primitives for agents, including channel integrations.
  • langchain-ai/langgraph: The human-in-the-loop docs: interrupt(), Command(resume=…) and review patterns.
  • fastapi/fastapi: Security dependencies for authenticating reviewers on approval endpoints.

Checkpoint quiz

1. Who should decide that an action needs approval?
2. Why hash the tool and arguments at review time?
3. Reviewers approve 99% of requests in 3 seconds. What does it suggest?
4. When should an agent escalate rather than ask for approval?
5. Which is irreversible?

Interview questions

  1. How do you decide which agent actions need human approval?
  2. Design the approval flow for an agent that changes production config.
  3. How do you keep approvals meaningful instead of a rubber stamp?
  4. What do you log for each approval, and why?
  5. When should an agent escalate to a person, and what should it hand over?

Ask the professor

Sign in to ask questions about this module.

Discussion

Community discussion appears here once giscus is configured (see README).