Table of Contents
- 1. Claude Code hooks: the gate inside the agent
- 2. OpenAI Agents SDK: approvals as interruptions
- 3. LangChain middleware: approve, edit, reject, respond
- 4. A runtime that is still alive to be asked
- 5. A chat relay so the request reaches your phone
- 6. Pattern rules, so you are not asked about everything
- 7. Unattended mode and the trade it makes explicit
- 8. An audit trail for actions that get questioned later
- At a glance
- How to choose and in what order to build
- Frequently asked questions
- Conclusion
AI agent approval gates are checkpoints that pause an autonomous agent before a risky tool call — a shell command, a file write, a payment — and require a human decision before execution resumes. Approval gates combine a policy that classifies the action, a pause-and-resume mechanism that survives the wait, and a channel that reaches the reviewer.
Most published guidance on human-in-the-loop agents stops at the SDK surface: mark a tool, catch an interrupt, resume the run. That leaves out everything that decides whether the gate works at 2am — where the request is delivered, which calls skip the prompt, what happens to a paused run when the host restarts, and what you substitute when nobody is awake. The eight components below are the operational layers, each tied to a tool or document you can read.
1. Claude Code hooks: the gate inside the agent

The cheapest place to put an approval gate is inside the agent runtime that is already deciding whether to run a tool. Claude Code exposes this through hooks: user-defined shell commands, HTTP endpoints, or LLM prompts that fire at named points in a session. The reference groups events into three cadences — once per session (SessionStart, SessionEnd), once per turn (UserPromptSubmit, Stop), and once per tool call inside the agentic loop (PreToolUse and PostToolUse).
PreToolUse is the gate. It fires before a tool call executes, receives JSON context about the event — on stdin for command hooks, as the POST body for HTTP hooks — and can return a decision. That decision is what makes a hook an approval gate rather than a logger: it can allow the call, deny it, or hand it back to the normal permission prompt.
Two details matter when you build on this. First, the docs are explicit that permission rules are enforced by Claude Code, not by the model — instructions in a prompt or CLAUDE.md shape what the agent tries to do, not what it is allowed to do. Second, the interaction between a hook’s allow decision and configured deny rules has been contested in the issue tracker, so if you are gating genuinely destructive commands, test your precedence assumptions against the version you run rather than against the prose.
2. OpenAI Agents SDK: approvals as interruptions

If the agent is something you wrote rather than a CLI you installed, the gate belongs in the framework. The OpenAI Agents SDK models this as an interruption flow: a tool is marked with needs_approval, the run pauses when that tool is called, pending approvals surface on the run result as interruptions, and a RunState object serialises the paused run so it can be stored and resumed after a decision arrives.
needs_approval takes either True for always-ask, or an async callable that decides per call. The callable receives the run context, the parsed tool parameters, and the tool call ID, which is enough to write rules like “approve refunds under a threshold, escalate the rest”.
The behaviour worth copying even if you never use this SDK is what happens when the rule cannot be evaluated. The docs state that callable approval rules fail closed: if the arguments are missing, empty, whitespace-only, malformed JSON, valid JSON that is not an object, or contain non-standard constants such as NaN or Infinity, the callable is not invoked at all and the call requires manual approval. A policy that throws an exception and gets swallowed is worse than no policy. The approval surface is also run-wide: interruptions raised inside a handoff or a nested Agent.as_tool() call still surface on the outer run, so there is one place to review.
3. LangChain middleware: approve, edit, reject, respond

Approval is usually described as a yes/no, which is why so many homegrown gates end up annoying. LangChain’s human-in-the-loop middleware is useful mainly as a vocabulary lesson: it defines four ways a reviewer can answer an interrupt. approve runs the tool with the arguments the model proposed. edit modifies the arguments first — change the recipient before the email goes out. reject skips the call entirely and returns rejection feedback to the agent. respond returns the human’s message as a synthetic tool result for “ask user” style tools.
The middleware checks each tool call against a configurable policy set by interrupt_on, and when intervention is needed it issues an interrupt that halts execution. Graph state is saved through LangGraph’s persistence layer, which is what allows the pause to be safe rather than a held-open process waiting on a socket.
Two operational rules come straight from the docs. When several tool calls are paused at once, each one needs its own decision, and decisions must be supplied in the same order the actions appear in the interrupt request — an off-by-one here approves the wrong action. And respond is not a denial: the docs are explicit that it should be used only when the human is acting as the tool, with reject reserved for actually refusing a side-effecting call. Conflating the two teaches the agent that “no” means “here is your answer”.
4. A runtime that is still alive to be asked

An approval gate is a promise that nothing happens without you. The quieter half of that promise is that the work resumes once you answer, and that depends entirely on the process still existing. A paused run holds state — RunState, a LangGraph checkpoint, a hook waiting on a reply — and a laptop that sleeps on a train platform, a container that is reclaimed after idling, or a session tied to one terminal tab all break the gate in the same unhelpful direction: the agent stops, your approval lands nowhere, and the task has to be restarted from the top.
This is the layer SetupYourClaw covers. It is managed deployment for AI agents: the agent runs on infrastructure somebody else keeps up, connected to the channels it needs, without you provisioning a VPS, writing service files, and re-pairing tokens after every restart. For an approval workflow specifically, the thing being bought is uptime between the request and the answer — the gap where a self-managed box most often fails.
It is not the only shape this can take. Running the agent on hardware you control is a legitimate choice with different trade-offs, and our comparison of self-hosted AI agent platforms covers what you take on when you own the box. The decision to make deliberately is which side of that line your approval gate sits on, because an unsupervised agent on an unreliable host is the worst of both.
5. A chat relay so the request reaches your phone

A gate that only renders in a terminal you are not looking at is a stop, not an approval. The relay layer forwards the pending decision to wherever you actually are. probelabs/afk is a compact example for Claude Code: install the npm package, run afk setup to create a Telegram bot, then afk to install the hooks and switch on remote mode. From there Claude Code’s approval requests arrive as Telegram messages with Approve and Deny buttons — approve and the run continues, deny and the agent stops and asks for guidance.
Design points worth noting: the project describes itself as zero-dependency, built on Node 18+ built-ins, with no cloud service in the middle — your bot, your token, local state only. It integrates with Claude Code’s existing permission system rather than replacing it, handles multiple projects, auto-approves operations it considers safe, and has timeout protection so an unanswered request does not hang forever. The README also documents calling the binary from any AI system, which makes it usable as a generic approval primitive from Python or bash.
Telegram is a common choice here because bot setup is self-service and messages carry inline buttons, and our roundup of Telegram AI bot platforms covers that ecosystem. Slack is the better surface when the reviewer is a team rather than one person; see Slack AI agent integration for the components involved.
6. Pattern rules, so you are not asked about everything

Every approval system fails the same way: it asks too often, you start tapping Approve without reading, and the gate becomes a formality. The fix is a policy that auto-approves the boring majority. owl-afk is built around this. It sends Claude Code tool calls to Telegram with inline buttons, but its headline feature is smart pattern rules — expressions like Bash(git *) or Edit(*.py) that approve matching calls without a prompt, plus project-scoped rules that auto-approve edits only inside named projects.
The more interesting work is in what it refuses to treat as a single decision. A bash chain such as git add . && git commit -m "msg" gets per-command approval rather than one blanket yes. It detects wrapper commands — SSH, Docker, sudo — and expands inner chains into individually approvable steps, so ssh host 'cd /tmp && rm foo' surfaces the rm instead of hiding it behind an innocuous-looking SSH invocation. That is the specific hole most hand-rolled allowlists have: a rule that trusts ssh trusts everything reachable over ssh.
It also forwards context that is not a decision at all: subagent completions, session start and end, context compaction, and optionally the tool output after approval. Separating notifications from approvals matters, because a channel where every message demands action trains you to ignore it.
7. Unattended mode and the trade it makes explicit

At some point the honest answer is that nobody will be awake to approve anything, and the design has to change rather than pretend. Agent AFK’s unattended-runs guide is a clear statement of that trade. Its afk daemon mode runs a headless session with no REPL and no interactive prompts, and the docs say bypass permissions are enabled by default, specifically so that no tool prompt can wedge the session.
Read that carefully, because it is the opposite of a gate. The guide is open about it: the permission dialog is removed on purpose, and safety is reconstructed from four other pieces — the daemon’s bounded task, Telegram supervision, spend limits, and scheduled tasks. Supervision here is after the fact. A send_telegram built-in is available to every session and the daemon calls it when work reaches a terminal state, with recipients gated by an allowlist environment variable. afk daemon --once --task "..." runs a single bounded task and exits, which is the shape you want under cron or CI.
The pattern to copy is the substitution, not the bypass. If you remove the per-call gate, you owe the system something in its place: a narrow task definition, a spend cap, an allowlisted notification channel, and a bounded run that cannot loop forever. Unattended autonomy with none of those is not a faster workflow, just an unmonitored one.
8. An audit trail for actions that get questioned later

In regulated work the question is rarely whether the agent paused. It is who approved what, when, and on what basis — six months later, to someone who was not there. Microsoft’s Agent Governance Toolkit includes a tutorial on human-in-the-loop approval workflows built for exactly this: high-risk actions such as large transfers, data exports, and admin operations pause execution and wait for explicit human approval before proceeding, with the tutorial aimed at regulated industries including financial services, healthcare, and legal.
What a governance framing adds over the relay tools above is the record. The approval request, the arguments as proposed, the identity of the approver, the decision, and the outcome are artefacts, not Telegram scrollback that ages out. If your agent touches money, personal data, or production infrastructure, assume you will have to reconstruct a decision you have forgotten, and store the gate’s output accordingly.
It also forces a classification step that the lighter tools let you skip. Deciding in advance which actions are high-risk — and writing that list down — is what turns an approval gate from a reflex into a policy. The toolkit positions this tutorial as intermediate with a prerequisite on its governance basics, which is a fair signal: this layer is worth adding once the gate works, not instead of building one.
At a glance
| Component | Layer | What it contributes to the gate |
|---|---|---|
| Claude Code hooks | Agent runtime | PreToolUse fires before every tool call and can return allow, deny, or defer to the prompt |
| OpenAI Agents SDK | Framework | needs_approval raises interruptions; RunState serialises and resumes the paused run |
| LangChain HITL middleware | Framework | Four decision types — approve, edit, reject, respond — with LangGraph persistence |
| SetupYourClaw | Runtime hosting | Managed, always-on host so a paused run is still alive when the answer arrives |
| probelabs/afk | Relay | Telegram Approve/Deny buttons for Claude Code, no cloud service, timeout protection |
| owl-afk | Policy + relay | Pattern rules, per-command approval for bash chains, SSH/Docker wrapper expansion |
| Agent AFK daemon | Unattended mode | Bypasses prompts by design; substitutes bounded tasks, spend caps, Telegram supervision |
| Agent Governance Toolkit | Audit | Approval workflows for high-risk actions with a record suitable for regulated work |
How to choose and in what order to build
Build in this order. Start at the runtime: if the agent is a CLI, use its own hook or permission layer, because a gate the runtime enforces cannot be talked out of by a prompt. If the agent is your code, use the framework’s interruption flow so the pause survives a process restart rather than living in memory. Only then add a relay, and add the policy at the same time — a gate without auto-approval rules gets rubber-stamped within a week. Write the high-risk list down before you write the rules. Reach for unattended mode last, and when you do, replace the gate with bounded tasks and spend caps rather than deleting it.
Frequently asked questions
What is an AI agent approval gate?
An approval gate is a checkpoint that pauses an agent before it runs a tool call the policy classifies as risky, and waits for a human decision. In practice it has three parts: a rule that decides which calls stop, a mechanism that suspends and resumes the run, and a channel that delivers the request to a reviewer.
Should the gate live in the agent or in my own code?
Put it wherever enforcement is not advisory. Claude Code’s docs note that permission rules are enforced by the runtime rather than by the model, so prompt instructions do not substitute. If you wrote the agent, use the framework’s approval flow — the OpenAI Agents SDK and LangChain both serialise the paused run so a restart does not lose it.
How do I stop approval requests becoming noise?
Auto-approve the predictable majority with pattern rules, and keep notifications separate from decisions. owl-afk shows both: expressions like Bash(git *) approve routine calls silently, while subagent completions and session events arrive as information. A channel where every message demands a tap is one you will stop reading.
Can I allowlist a command like ssh safely?
Not as a single rule. A command that wraps other commands inherits everything they can do, which is why owl-afk expands inner chains in SSH, Docker, and sudo invocations into individually approvable steps. Allowlist the inner operation, not the wrapper, or the rule quietly approves anything reachable through it.
What should replace the gate for overnight runs?
If prompts are bypassed so the session cannot stall, substitute other limits. Agent AFK’s unattended guide pairs its daemon with a narrow task definition, spend caps, an allowlisted Telegram channel, and bounded single-task runs. Removing the per-call approval without adding those does not make the run faster, only unobserved.
Conclusion
Approval gates are assembled, not installed. The runtime decides what can be enforced, the framework decides whether a pause survives a restart, the policy decides how often you are asked, the relay decides whether you ever see the request, and the audit layer decides whether the decision can be explained later. Most gates fail at the dullest link: the agent was not running when the answer came back. If you would rather not maintain that host yourself, SetupYourClaw deploys and keeps the agent running and connected, so the pause-and-resume loop has something stable to pause on.
