Human Approval Gates for AI Actions
An approval written into the prompt can be forgotten. A gate in code binds the exact action a person approved, runs it once, and expires.
5 min read / Updated / Last checked
- Format
- Architecture · Intermediate
- Who it is for
- Founders and the builders they hire
- You leave with
- Add an approval gate that holds refunds, deletions and outbound messages until a named person approves the exact action.
The problem
On February 23, 2026, Summer Yue, who works on AI alignment at Meta, described an OpenClaw agent deleting email from her real inbox. She had asked it to review the inbox, suggest what to archive or delete, and take no action until she said so [2]. The agent had behaved on a smaller test inbox. On the large real one, Yue believes the conversation grew big enough to trigger compaction, the step where an agent summarizes older messages to stay within its context window, and the instruction to wait did not survive. The agent ignored stop commands sent from her phone [1].
The approval rule lived in the conversation. To a model, an instruction like "ask before acting" is one more piece of text that can be summarized, outweighed or lost. A founder building an agent that refunds customers, deletes records or sends email faces the same failure with higher stakes, because those actions cannot be undone.
The opposite mistake is just as common. Teams that discover the risk put a confirmation on every tool call, people click "approve" all day, and the gate stops meaning anything. A useful gate is narrow, lives outside the model, and asks a person only about actions that are expensive to reverse.
How it works
An approval gate is a small piece of code between the agent and the real API of every high-impact tool. The agent never holds a credential that can perform those actions directly. It has five parts.
- Policy. A list of actions that need a person: moving money, deleting data, messaging customers or third parties, changing permissions. Reads and drafts pass through without approval.
- Proposal. When the agent calls a gated tool, the gate stores the action and its exact arguments, computes a digest (a fingerprint of action and arguments), and tells the agent the request is pending. Nothing runs yet.
- Review. A reviewer sees the action, the arguments, and the agent's stated reason, then approves. The approval is bound to the digest, so if the arguments change, the approval no longer covers them. Only accounts in the reviewer role can approve, and an agent identity is never one of them.
- Execution. Code runs the stored arguments, not new model output, exactly once, and only before the approval expires.
- Audit. Each record keeps who proposed, who approved, what ran and when.
Agent frameworks provide the pause. The OpenAI Agents SDK, for example, stops a run when a tool marked needs_approval is called and lets you approve or reject later from serialized state, which it says to load only from trusted storage [5]. A pause is not a gate. The policy, reviewer identity, digest binding, expiry and audit trail are still yours to build. OWASP's guidance on excessive agency says the same in one line: use human-in-the-loop control so a person approves high-impact actions before they are taken [6].
Fatigue is the second design constraint. Anthropic reports that Claude Code users accept 93% of manual permission prompts, and that sandboxing cut prompts by 84% in internal use [3][4]. Fewer, higher-stakes approvals get real attention.
How approvals fail, and the gate control that stops each failure
Fig. 01- Instruction to wait is lost in compactionGate in code, agent has no direct credential
- Arguments change after approvalApproval bound to a digest of action and arguments
- Agent approves its own requestOnly reviewer accounts can approve
- Retry or replay runs it twiceSingle-use claim before execution
- Old approval used days laterApproval expires after 15 minutes
- Reviewer approves everythingGate only irreversible, costly actions
By the numbers
- of manual permission prompts that Claude Code users accept, per Anthropic [3]
- 93%
- fewer permission prompts after Anthropic sandboxed Claude Code, in internal use [4]
- 84%
- false-negative rate of Anthropic's automated approver on real overeager actions, in a set of 52 [3]
- 17%
- consecutive or total denials after which Claude Code's auto mode stops and hands the session to a person [3]
- 3 or 20
| Action | Reversible? | Gate | Cheaper option that removes the need |
|---|---|---|---|
| Refund or payment | No | Always, or above a set amount | Lower per-transaction limit on the agent's key |
| Delete records | No | Always for hard delete | Soft delete with a restore window |
| Email or message a customer | No | Until the template is proven | Agent writes a draft, a person sends it |
| Change roles or permissions | Partly | Always | None, keep the gate |
| Read an order or a document | Yes | No | Scope the read to the current user |
| Create an internal ticket note | Yes | No | Log it, review in a weekly sample |
The 93% acceptance rate is the number to design around [3]. When people approve nearly everything, each prompt teaches them to approve faster. Anthropic's response in Claude Code was to sandbox safe actions and put a classifier in front of the rest [3][4]. Even that classifier missed 17% of real overeager actions in its evaluation set [3], which is why the rows marked "always" in the table stay with a person.
The table's last column often beats a gate. A draft that a person sends, or a soft delete with a restore window, keeps the agent fast and the outcome reversible. Spend reviewer attention on the rows that cannot be undone.
Implementation
The gate below uses SQLite to stay self-contained. In production the same table lives in your main database, and the reviewer screen is a page in your admin app or a message in a chat tool with an approve button.
"""Approval gate: the agent proposes, a person approves, code runs exactly what was approved."""
import hashlib, json, time, uuid
SCHEMA = """CREATE TABLE approvals (id TEXT PRIMARY KEY, action TEXT NOT NULL,
args TEXT NOT NULL, digest TEXT NOT NULL, proposed_by TEXT NOT NULL,
status TEXT NOT NULL, approved_by TEXT, expires_at REAL NOT NULL)"""
TTL_SECONDS = 15 * 60 # an approval left unused for 15 minutes expires
class GateError(Exception): pass
def digest(action: str, args: dict) -> str:
return hashlib.sha256(json.dumps([action, args], sort_keys=True).encode()).hexdigest()
def propose(db, agent_id: str, action: str, args: dict) -> str:
request_id = str(uuid.uuid4())
with db:
db.execute("INSERT INTO approvals VALUES (?, ?, ?, ?, ?, 'pending', NULL, ?)",
(request_id, action, json.dumps(args), digest(action, args),
agent_id, time.time() + TTL_SECONDS))
return request_id # the agent gets "pending", the reviewer sees action, args, digest
def approve(db, request_id: str, reviewer_id: str, shown_digest: str, reviewers: set) -> None:
if reviewer_id not in reviewers: # agent identities are never in this set
raise GateError("not an authorized reviewer")
with db:
cur = db.execute(
"UPDATE approvals SET status = 'approved', approved_by = ? WHERE id = ? AND"
" status = 'pending' AND digest = ? AND expires_at > ? AND proposed_by != ?",
(reviewer_id, request_id, shown_digest, time.time(), reviewer_id))
if cur.rowcount != 1:
raise GateError("no pending request with that digest, or it expired")
def execute(db, request_id: str, executors: dict):
with db: # claim first, so a retry or a second worker finds nothing to run
cur = db.execute("UPDATE approvals SET status = 'executed' WHERE id = ?"
" AND status = 'approved' AND expires_at > ?", (request_id, time.time()))
if cur.rowcount != 1:
raise GateError("no unexpired approval for this request")
action, args = db.execute("SELECT action, args FROM approvals WHERE id = ?",
(request_id,)).fetchone()
return executors[action](**json.loads(args)) # stored args, never fresh model outputWire it in three places. The agent's tool function for a gated action calls propose and returns "pending approval" to the model, which tells the customer a person will confirm. The reviewer screen shows action, arguments and digest, and its button calls approve with the digest it displayed, so a change between display and click fails. A worker or the approve handler then calls execute, which claims the row before running and uses only the stored arguments.
Keep the payment, deletion and email credentials in the executor's environment, not in the agent's. That is what turns "the agent should ask first" from a request into a fact.
Test it
The four tests cover the first five rows of the diagram: no run without approval, digest binding, reviewer identity, single use and expiry. Run them in CI.
import sqlite3, time
import pytest
from approvals import SCHEMA, GateError, approve, digest, execute, propose
REVIEWERS = {"maria@company.com"}
ARGS = {"order_id": "A-1", "amount_cents": 4900}
@pytest.fixture
def db():
conn = sqlite3.connect(":memory:")
conn.execute(SCHEMA)
return conn
@pytest.fixture
def refunds():
calls = []
return calls, {"refund": lambda order_id, amount_cents: calls.append((order_id, amount_cents))}
def test_nothing_runs_without_approval(db, refunds):
rid = propose(db, "agent:support", "refund", ARGS)
with pytest.raises(GateError):
execute(db, rid, refunds[1])
assert refunds[0] == []
def test_approval_covers_only_what_the_reviewer_saw(db):
rid = propose(db, "agent:support", "refund", ARGS)
with pytest.raises(GateError): # the reviewer was shown a different amount
approve(db, rid, "maria@company.com", digest("refund", {**ARGS, "amount_cents": 49000}), REVIEWERS)
def test_agent_cannot_approve_its_own_request(db):
rid = propose(db, "agent:support", "refund", ARGS)
with pytest.raises(GateError):
approve(db, rid, "agent:support", digest("refund", ARGS), REVIEWERS)
def test_approved_action_runs_once_and_expires(db, refunds, monkeypatch):
rid = propose(db, "agent:support", "refund", ARGS)
approve(db, rid, "maria@company.com", digest("refund", ARGS), REVIEWERS)
execute(db, rid, refunds[1])
with pytest.raises(GateError):
execute(db, rid, refunds[1]) # a retry or a replay
assert refunds[0] == [("A-1", 4900)]
late = propose(db, "agent:support", "refund", ARGS)
approve(db, late, "maria@company.com", digest("refund", ARGS), REVIEWERS)
monkeypatch.setattr(time, "time", lambda: 10**12) # long after the TTL
with pytest.raises(GateError):
execute(db, late, refunds[1])Expected: four passing tests. Then run three drills in staging:
- Compaction drill. Run a long agent session that pushes the context past its limit, then ask for a refund. Expected: the refund is still pending, because the gate never depended on the prompt.
- Credential check. List every secret in the agent process environment. Expected: no payment, deletion or outbound email credential appears.
- Fatigue check. After two weeks, count approvals and rejections per action type. If reviewers approve nearly every request for one action, apply that action's cheaper option from the table instead of keeping the prompt.
Decision
Add the gate before the agent gets its first tool that moves money, deletes data or contacts a customer. It is a day of work on top of an existing agent: one table, three functions, one reviewer screen.
- Gate irreversible actions only. Make everything else reversible or read-only.
- Bind each approval to the exact arguments, a named reviewer, one execution and a short expiry.
- Keep high-impact credentials out of the agent's process.
- Review the approval rate monthly and shrink the gate where people only click yes.
- For which framework does the pausing, see OpenAI Agents SDK vs. LangGraph vs. Mastra. For scoping what the agent can do without a gate, see Tool Permissions and Agent Identity.
Sources
- [1]A Meta AI security researcher said an OpenClaw agent ran amok on her inbox (opens in a new tab)TechCrunch, February 2026
- [2]A quote from Summer Yue (opens in a new tab)Simon Willison, February 2026
- [3]How we built Claude Code auto mode: a safer way to skip permissions (opens in a new tab)Anthropic, March 2026
- [4]Beyond permission prompts: making Claude Code more secure and autonomous (opens in a new tab)Anthropic, October 2025
- [5]Human-in-the-loop (opens in a new tab)OpenAI Agents SDK, November 2026
- [6]LLM06:2025 Excessive Agency (opens in a new tab)OWASP GenAI Security Project, 2025
Technical guidance, not legal or security certification.
Related resources
Need a technical review of an AI-built MVP?
Discuss your build