mediumAI Engineering

How do you design human-in-the-loop approval for agent actions?

705 views
01

Understand the problem

Approval gates that catch the risky 2% without drowning users in confirmation fatigue.

human-in-the-loopapprovalssafetyagents
02

Attempt it yourself

Sketch your approach before reading the solution — that's what interviews test.

Stuck? AI Nudge Available

Get a conceptual hint to guide your logic without spoiling the final implementation.

03

Study the solution

The solution is waiting

Give it an honest attempt first — then compare your thinking with the full walkthrough.

04

Read the code

Approval request with preview and scope
const decision = await approvals.request({
  action: "send_email",
  reason: agent.rationale,                     // why the agent wants this
  preview: { to: draft.to, subject: draft.subject, body: draft.body },
  editable: ["subject", "body"],               // human can fix, then approve
  scopeOffer: { kind: "session", pattern: "send_email:to=*@ourcompany.com" },
  approver: routeByAuthority(draft.to),        // account owner, not "anyone"
});

if (decision.status === "approved") await mailer.send(decision.finalPayload);
else agent.observe("Email rejected: " + decision.note);   // feedback, not silence
05

Join the discussion

Discussion (0)

Sign in to join the discussion.

No responses yet. Be the first to share what you think.