Sub topic 9
Human approval for irreversible or high-impact actions
This chapter assumes you know how LLM tool calling works, can read short Python and JSON snippets, and understand roles and permissions. Earlier chapters covered tool allowlists, authorization in code, and argument constraints. Those controls decide what an agent may do. Human approval decides which permitted actions still need a person to say yes before they run.
Why approval belongs in a least-privilege design
Some actions are allowed for the task but are costly when wrong. Sending an email to a customer, deleting a record, and issuing a refund all fit this description. Scoping tools and validating arguments narrows the damage, but it cannot prove that a legitimate-looking call is the call the user wanted.
Prompt injection makes this concrete. An agent that summarizes a web page may read hidden text telling it to email a file to an outside address. If send_email is on the allowlist and the address passes format checks, code alone cannot tell that the intent is wrong. A person looking at "send this file to this address" often can.
Approval is the control for the gap between "permitted" and "intended". It also addresses the autonomy part of excessive agency: the agent takes consequential steps with no one checking.
Deciding what needs approval
Approval costs time and attention. If you ask for it on every call, people click "approve" without reading. If you never ask, one bad call is final. Pick actions by their consequences.
Ask these questions about each tool:
- Reversible? Can the effect be undone cheaply? Reading a file can. Sending an email cannot be recalled.
- Who is affected? Only the user, or other people and systems?
- How large is the worst case? One record, or every record?
- Does it leave your boundary? Messages, payments, and public posts reach outside systems.
- Is the input trustworthy? Was the call influenced by untrusted content such as web pages or inbound email?
A simple tiering works well in practice.
| Tier | Examples | Handling |
|---|---|---|
| Read-only, low sensitivity | `search_docs`, `read_file` in a workspace | Run automatically |
| Reversible writes | Create a draft, add a label | Run automatically, log the call |
| Irreversible or external | `send_email`, `delete_record`, payments | Require approval for the exact arguments |
| Administrative | Change permissions, rotate credentials | Require approval, or keep out of the agent entirely |
The last row matters. Some actions should not be available to the agent even with approval, because a person under time pressure may approve a request they do not understand. Removing the tool is stronger than gating it.
A minimal approval gate
The runtime sits between the model and the tools. It marks some tools as high risk and calls an approval function before running them. This is the pattern from the chapter's example code.
HIGH_RISK = {"send_email", "delete_record"}
def execute_with_approval(name, args, tools, approve):
if name in HIGH_RISK and not approve(name, args):
return {"status": "denied", "tool": name}
return {"status": "ok", "result": tools[name](**args)}The approve callback could show a dialog, post to a chat channel, or open a ticket. The important properties are these:
- The gate is ordinary code. The model cannot talk its way past it, because the check happens outside the model.
- The approver sees the exact arguments. Approving "send an email" is meaningless. Approving "send
q3-report.pdfto[email protected]" is a real decision. - A denial returns a result the agent can handle. The model receives
deniedand can explain it to the user or choose another path.
Here is a runnable version with a console approver and stub tools.
def send_email(to: str, subject: str, body: str) -> str:
return f"sent to {to}"
def delete_record(record_id: str) -> str:
return f"deleted {record_id}"
def search_docs(query: str) -> str:
return f"results for {query}"
TOOLS = {
"send_email": send_email,
"delete_record": delete_record,
"search_docs": search_docs,
}
HIGH_RISK = {"send_email", "delete_record"}
def console_approve(name, args) -> bool:
print(f"Agent wants to call {name} with {args}")
return input("Approve? [y/N] ").strip().lower() == "y"
def execute_with_approval(name, args, tools, approve):
if name in HIGH_RISK and not approve(name, args):
return {"status": "denied", "tool": name}
return {"status": "ok", "result": tools[name](**args)}
print(execute_with_approval("search_docs", {"query": "refund policy"}, TOOLS, console_approve))
print(execute_with_approval(
"send_email",
{"to": "[email protected]", "subject": "Report", "body": "Attached."},
TOOLS,
console_approve,
))The first call runs without a prompt. The second pauses and waits for a person. Any answer other than y counts as a denial, so the default is safe.
The approval flow
The flow has more steps than the single if suggests. The runtime must pause, present, wait, and then either run or refuse.
Note the order. The allowlist and argument checks run first, so a person is never asked to approve a call that code would have rejected anyway. This keeps the approval queue small and meaningful.
Making approval effective
Approval fails in predictable ways. Most are about the human, not the code.
Approval fatigue
When people see dozens of prompts a day, they stop reading them. Reduce volume by approving only the real high-risk tier and by letting low-risk calls run. Track the approval rate. A rate near 100% with very fast response times is a warning that the gate has become a formality.
Show what matters
A good prompt shows the action in plain language, the exact arguments, and the reason the agent gave. Highlight values that cross a boundary, such as an external recipient domain or the number of records a delete affects. Show the real value, not a model-written summary of it, because a manipulated model can describe a harmful call in harmless words.
Bind approval to the exact call
An approval should apply to one call with one set of arguments. If the runtime approves send_email once and then lets the model change the recipient, the approval is worthless. Compare what was approved with what runs.
import hashlib
import json
def call_fingerprint(name: str, args: dict) -> str:
payload = json.dumps({"name": name, "args": args}, sort_keys=True)
return hashlib.sha256(payload.encode()).hexdigest()
approved: set[str] = set()
def grant(name: str, args: dict) -> None:
approved.add(call_fingerprint(name, args))
def run_if_granted(name: str, args: dict, tools: dict):
fingerprint = call_fingerprint(name, args)
if fingerprint not in approved:
raise PermissionError("call was not approved")
approved.discard(fingerprint) # single use
return tools[name](**args)The fingerprint covers the tool name and every argument. Removing it after use makes each approval single use, so it cannot be replayed later.
Approve before, not after
Approval must come before the side effect. Asking "was that okay?" after an email is sent only produces a record of the damage. For actions that take time, such as a bulk delete, consider a preview step: run the operation in dry-run mode, show what would change, then ask.
Expire stale requests
A pending request that waits for hours may no longer match reality. Give each request a time limit and treat a timeout as a denial.
Approval as one layer
Human approval does not replace the other controls. Combine it with them.
- Credentials still matter. An approved call should run with scoped, short-lived credentials. If the approver makes a mistake, the credentials limit the harm. For example, an agent that only reads reports should hold an IAM policy that allows only that.
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::example-reports-bucket/public-summaries/*"
}
]
}- Argument constraints still apply. Restrict recipients to an approved domain list so the approver is not the only barrier.
- Logging records the decision. Store who approved, when, and what the arguments were. The audit chapter covers this in detail.
Known limits
Approval is weak against some threats. A person can be socially engineered through a well-written justification. A prompt may hide the dangerous part of a long argument, such as a body of text that contains a leaked secret. A rushed approver may miss a lookalike domain. Treat approval as a strong control for rare, high-impact actions, and rely on structural controls such as data-flow separation for the rest.
Choosing between approval, denial, and automation
Use this as a decision guide for each tool.
- If the action is never needed for the task, remove the tool.
- If it is needed, reversible, and low impact, automate it and log it.
- If it is irreversible or leaves your boundary, require approval of the exact arguments.
- If the damage from a mistaken approval would still be severe, add argument constraints, scoped credentials, or a second approver.
Summary
Human approval covers permitted actions that are irreversible or high-impact. Choose them by reversibility, reach, and worst-case size. Enforce the gate in code, show the exact arguments, bind each approval to one call, and approve before the action. Keep the approval queue short enough that people still read it, and pair it with scoped credentials, argument constraints, and logs.
Exercise
An agent has a post_to_slack tool that posts to a public channel. The runtime asks the user "Allow the agent to post to Slack?" once at the start of the session and then lets every later post run. Name two problems with this design and describe a fix.
Show answer
First, the approval is not tied to the exact call, so after one "yes" the agent can post any content, including text steered by prompt injection or a leaked secret. Second, the approver never sees the arguments, so the decision is uninformed. A fix is to require approval per call, show the channel and full message text, and bind the approval to a fingerprint of those arguments so it is single use. Optionally add an argument constraint that limits which channels the tool can target.
Exercise
Sort these tools into "automate", "approve", or "remove from the agent" for a customer-support agent that drafts replies: search_kb, create_draft_reply, send_reply_to_customer, grant_admin_role. Give one reason for each.
Show answer
search_kb is automated, because it is read-only. create_draft_reply is automated, because a draft is reversible and nothing leaves the system. send_reply_to_customer needs approval, because the message cannot be recalled and reaches an outside party. grant_admin_role should be removed from the agent, because a permission change is administrative, and a hurried approval of a misleading request would be hard to recover from.
Exercise
In the run_if_granted example, why does the code call approved.discard(fingerprint) after the check?
Show answer
It makes each approval single use. Without it, the same approved call could be replayed any number of times, for example if the model repeats the request later in the session.