Lesson 45.2 · 2 of 4 · 5 min read · Reviewed 24 Nov 2026
Human-in-the-loop checkpoints
By the end, you can
- Place human approval checkpoints where actions are costly or irreversible.
- Design approvals that people can review quickly.
Some steps should never happen on the model’s say-so alone. A checkpoint pauses the agentAgent: A system where a model decides its own next steps, calling tools in a loop until the task is done. and asks a person.
Where to put checkpoints
Ask before actions that are:
- Irreversible: deleting data, sending a message, making a payment.
- Costly: large refunds, big cloud jobs, bulk changes.
- Visible: anything customers, the public or other teams will see.
Reading, searching and drafting are usually safe to run freely.
Make approvals easy to review
A good approval card names the tool, shows the exact inputs, and says what will happen: “Refund $640 to order 8812. This can’t be reversed.” A vague “Agent wants to use a tool” gets approved blindly.
Avoid approval fatigue
If every step needs a click, people stop reading. Let safe calls through, batch related approvals, and save the checkpoint for the moments that matter.
How to build it
In Claude CodeClaude Code: Anthropic’s agentic coding tool that works in your terminal, IDE and CI, reading and editing code and running commands., put the tool in the ask list, or return ask from a PreToolUse hookPreToolUse hook: A hook that runs before a tool call and can allow, deny or ask for approval.. In the SDK, canUseTool can wait for a person’s answer before returning.
Key points
- Put a person in the loop before actions that are irreversible, costly or visible to others.
- Show the reviewer exactly what will happen: the tool, the inputs and the expected effect.
- Too many approvals train people to click yes without reading, so ask only where it matters.
Gate only the risky calls
Place human approval only before irreversible, costly or visible actions, with cards people can read.
You will have: An approval rule and a card formatter, with a printout of which calls need a person.
Steps
- Run the starter: all 12 calls ask for approval with a vague card.
- Write needs_approval() using the three tests: irreversible, costly, visible.
- Write card() so it names the tool, the exact input and the effect.
- Add the warning for actions that can't be undone.
- Count how many clicks a reviewer saves per day if this agent makes 12 calls like these 30 times a day.
Done when
- Only 3 of 12 calls need approval: the refund, the bulk email and the delete.
- Each card names the tool and input and says what will happen.
- Irreversible actions say "This can't be undone."
Open in the Playground No API key needed.
Starter code (Python)
# Ask a person only where it matters, and make each approval easy to read.
CALLS = [
{"tool": "read_file", "input": "faq.md", "effect": "reads a file", "undo": True, "credits": 0, "audience": 0},
{"tool": "search_docs", "input": "refund policy", "effect": "searches the docs", "undo": True, "credits": 0, "audience": 0},
{"tool": "run_tests", "input": "unit", "effect": "runs the unit tests", "undo": True, "credits": 0, "audience": 0},
{"tool": "issue_refund", "input": "order 8812, 640 credits", "effect": "refunds 640 credits to order 8812", "undo": False, "credits": 640, "audience": 1},
{"tool": "read_file", "input": "orders.csv", "effect": "reads a file", "undo": True, "credits": 0, "audience": 0},
{"tool": "issue_voucher", "input": "order 7731, 20 credits", "effect": "adds a 20 credit voucher", "undo": True, "credits": 20, "audience": 1},
{"tool": "send_email", "input": "launch notice", "effect": "emails 4,000 customers", "undo": False, "credits": 0, "audience": 4000},
{"tool": "search_docs", "input": "shipping times", "effect": "searches the docs", "undo": True, "credits": 0, "audience": 0},
{"tool": "draft_reply", "input": "ticket 51", "effect": "writes a draft only", "undo": True, "credits": 0, "audience": 0},
{"tool": "delete_rows", "input": "table sessions, older than 2024", "effect": "deletes 12,000 rows", "undo": False, "credits": 0, "audience": 0},
{"tool": "run_tests", "input": "integration", "effect": "runs the integration tests", "undo": True, "credits": 0, "audience": 0},
{"tool": "read_file", "input": "policy.md", "effect": "reads a file", "undo": True, "credits": 0, "audience": 0},
]
def needs_approval(call):
# TODO: ask only when the call is irreversible, costly (200+ credits) or visible (10+ people)
return True
def card(call):
# TODO: name the tool, show the exact input, say the effect, and warn if it can't be undone
return "Agent wants to use a tool. Allow?"
asks = [c for c in CALLS if needs_approval(c)]
print(f"approvals needed: {len(asks)} of {len(CALLS)}")
for c in asks[:3]:
print(" -", card(c))
Show a solution
# Ask a person only where it matters, and make each approval easy to read.
CALLS = [
{"tool": "read_file", "input": "faq.md", "effect": "reads a file", "undo": True, "credits": 0, "audience": 0},
{"tool": "search_docs", "input": "refund policy", "effect": "searches the docs", "undo": True, "credits": 0, "audience": 0},
{"tool": "run_tests", "input": "unit", "effect": "runs the unit tests", "undo": True, "credits": 0, "audience": 0},
{"tool": "issue_refund", "input": "order 8812, 640 credits", "effect": "refunds 640 credits to order 8812", "undo": False, "credits": 640, "audience": 1},
{"tool": "read_file", "input": "orders.csv", "effect": "reads a file", "undo": True, "credits": 0, "audience": 0},
{"tool": "issue_voucher", "input": "order 7731, 20 credits", "effect": "adds a 20 credit voucher", "undo": True, "credits": 20, "audience": 1},
{"tool": "send_email", "input": "launch notice", "effect": "emails 4,000 customers", "undo": False, "credits": 0, "audience": 4000},
{"tool": "search_docs", "input": "shipping times", "effect": "searches the docs", "undo": True, "credits": 0, "audience": 0},
{"tool": "draft_reply", "input": "ticket 51", "effect": "writes a draft only", "undo": True, "credits": 0, "audience": 0},
{"tool": "delete_rows", "input": "table sessions, older than 2024", "effect": "deletes 12,000 rows", "undo": False, "credits": 0, "audience": 0},
{"tool": "run_tests", "input": "integration", "effect": "runs the integration tests", "undo": True, "credits": 0, "audience": 0},
{"tool": "read_file", "input": "policy.md", "effect": "reads a file", "undo": True, "credits": 0, "audience": 0},
]
def needs_approval(call):
return (not call["undo"]) or call["credits"] >= 200 or call["audience"] >= 10
def card(call):
text = f"{call['tool']}({call['input']}): {call['effect']}."
if not call["undo"]:
text += " This can't be undone."
return text
asks = [c for c in CALLS if needs_approval(c)]
print(f"approvals needed: {len(asks)} of {len(CALLS)}")
for c in asks[:3]:
print(" -", card(c))