Lesson 64.5 · 5 of 11 · 4 min read · Reviewed 24 Nov 2026
Approval gates for risky actions
By the end, you can
- Design approval gates for risky actions.
- Decide what makes an action need approval.
Chapter 45.2 introduced human checkpoints. At scale you need clear rules for which actions need them.
A simple risk score
Gate an action when any of these hold:
- Irreversible: deletes, payments, sent messages.
- Costly: above an amount or resource threshold.
- External: visible to customers, partners or the public.
- Unusual: far outside this user’s or agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done.’s normal pattern.
Good approval UX
- One card per action, with the exact inputs and effect.
- Approve, reject, or edit then approve.
- A time-out with a safe default (usually reject).
- Every decision logged with the approver.
Not only people
Some gates can be automated: a second, stricter model check, or a rules engine for low-value cases, with people for the rest. Keep humans for the decisions that matter, or approvals become rubber stamps.
Key points
- Approval gates pause an action until a person (or a stricter system) says yes.
- Gate actions that are irreversible, costly, external or unusual for this user.
- Show the reviewer the exact action and its effect, and log who approved it.
Build an approval gate with a timeout
Pause irreversible, external or costly actions for a person, and default to reject on time-out.
You will have: A needs_gate() rule, a run() function with simulated reviewer answers, and an audit log.
Steps
- Run the starter: the payment runs with no approval.
- Write needs_gate() to return the reasons an action is risky.
- Run gated actions only on an explicit approve; treat no answer as a reject.
- Log every decision with who made it.
Done when
- pay_supplier is not run, and the log says it timed out.
- send_email runs after approval; the two internal actions run without a gate.
- The output shows 'gated: 2 of 4'.
Open in the Playground No API key needed.
Starter code (Python)
# An approval gate: risky actions wait for a person, with a safe default on time-out.
ACTIONS = [
{"tool": "get_invoice", "irreversible": False, "external": False, "amount": 0},
{"tool": "send_email", "irreversible": True, "external": True, "amount": 0},
{"tool": "pay_supplier", "irreversible": True, "external": True, "amount": 2500},
{"tool": "update_note", "irreversible": False, "external": False, "amount": 0},
]
# Simulated reviewer answers: None means nobody answered before the time-out.
ANSWERS = {"send_email": "approve", "pay_supplier": None}
AUDIT = []
def needs_gate(a, threshold=1000):
# TODO: gate if irreversible, external or above the amount threshold
return False
def run(a):
# TODO: if gated, look up the answer; approve runs it, reject or time-out does not; log who decided
return "ran"
for a in ACTIONS:
print(a["tool"], "->", run(a))
print("audit:", AUDIT)
Show a solution
ACTIONS = [
{"tool": "get_invoice", "irreversible": False, "external": False, "amount": 0},
{"tool": "send_email", "irreversible": True, "external": True, "amount": 0},
{"tool": "pay_supplier", "irreversible": True, "external": True, "amount": 2500},
{"tool": "update_note", "irreversible": False, "external": False, "amount": 0},
]
ANSWERS = {"send_email": "approve", "pay_supplier": None}
AUDIT = []
def needs_gate(a, threshold=1000):
reasons = [k for k in ("irreversible", "external") if a[k]]
if a["amount"] > threshold:
reasons.append("costly")
return reasons
def run(a):
reasons = needs_gate(a)
if not reasons:
AUDIT.append((a["tool"], "auto"))
return "ran"
answer = ANSWERS.get(a["tool"])
decision = answer if answer in ("approve", "reject") else "timeout"
AUDIT.append((a["tool"], decision, "reviewer-1" if answer else "nobody"))
if decision == "approve":
return f"ran after approval ({', '.join(reasons)})"
return f"not run: {decision} ({', '.join(reasons)})"
for a in ACTIONS:
print(a["tool"], "->", run(a))
print("audit:", AUDIT)
print("gated:", sum(1 for x in AUDIT if x[1] != "auto"), "of", len(ACTIONS))