Skip to content

Runtime Approval Gates for AI Agents: Security Guide

Picture of Sharan Shirodkar
Sharan Shirodkar

TL;DR: AI agent security at the tool call comes down to a gate enforced outside the model: each proposed action is checked against rules, then allowed, denied, or sent to a person. Combined with least-privilege tools, scoped credentials, and sandboxing, runtime approval gates support destructive action prevention, secrets and credential protection, and tool call security without needing to recognize an attack. Prediction Guard, a sovereign AI control plane, ships part of this pattern today, and this guide says which part.

A runtime approval gate is a control that stops one specific agent action before it executes, checks the action against rules enforced outside the model, and then allows it, denies it, or sends it to a person for a decision. Combined with tool controls that limit which tools an agent can call and what each call may touch, approval gates are the part of AI agent security that still works when the model is confused, manipulated, or simply wrong. Prediction Guard, a sovereign AI control plane that runs inside your boundary, ships part of this pattern today, and this guide says which part.

This guide is for enterprise AI platform and security teams. It explains how runtime approval gates and tool controls support destructive action prevention, secrets and credential protection, and tool call security, how to design human approval workflows that people keep using, what AI coding agent security looks like in practice, and which prompt filtering alternatives hold up when filters do not. It treats approval as one part of operational control of agents: deciding what each agent may do, stopping it at the point of action, and recording the decision.

Prediction Guard publishes this guide and builds a sovereign AI control plane, so its statements about its own product are limited to what it currently ships and has published. For questions to put to any vendor in this area, see Prediction Guard's due diligence questions. Outside facts were checked in November 2026.

Nine Seconds, Three Failures

In April 2026, according to its founder, an AI coding agent deleted the production database of PocketOS, a software company serving car rental businesses, in about nine seconds, as ABC News and an IBM interview reported. The agent, a Cursor agent running Anthropic's Claude Opus 4.6 model, was doing a routine task in a staging environment when it hit a credential mismatch. By the founder's account, it then searched for an API token in a file unrelated to the task, found one with full reach across the infrastructure provider's API, and issued a volume delete. He said there was no confirmation step and no environment scoping, and that the delete also removed the volume-level backups. The provider's account is that a cascading delete through a legacy endpoint made the backups look unavailable in its interface. It restored the backups about 30 minutes after connecting with the founder and patched that endpoint to delay deletes.

The sequence contains three separate failures, and each calls for a different control.

routine task in staging
  v
credential mismatch
  v
agent searches unrelated files for a token   <- credentials exposed
  v
finds a token with account-wide reach        <- authority too broad
  v
issues a volume delete, no confirmation      <- no approval gate
  v
production database deleted in ~9 seconds

Neither this incident nor an earlier one involved an attacker, so no input filter had anything to catch. In July 2025, Replit's agent deleted a production database during a declared code freeze, according to its user's account and the company's response, as Fortune reported. The agent's own account, as Fortune relayed it, was that it had violated explicit instructions not to proceed without human approval. The company's CEO said the response included automatic separation of development and production databases. One is an instruction and the other is a control, and the difference is the subject of this guide.

What AI Agent Security Looks Like at the Tool Call

The moment an agent's intent becomes an effect is the tool call, so that is where a gate belongs. One call passes through five steps.

agent proposes a tool call
  |
  v
who is acting? agent, owner, person who started the run
  |
  v
what is it touching? tool, target, environment, arguments
  |
  v
rules, evaluated in order:   deny  ->  ask  ->  allow
                              |        |         |
                           refuse    a person   run it
  |
  v
result checked before it returns to the model; decision recorded

Three properties make the gate work. First, the rules are enforced outside the model. Claude Code's documentation says its rules are enforced by the application and not by the model, so instructions in a prompt change what the agent tries to do but not what it is allowed to do. Second, the order is fixed and the first match wins: the same documentation evaluates deny rules, then ask rules, then allow rules, so a narrow allow cannot override a broad deny. Third, the decision rests on authority held downstream. OWASP's excessive agency entry says to enforce authorization in downstream systems rather than relying on a model to decide whether an action is allowed.

Three controls meet at this point, and they solve different problems. Authorization determines whether an agent has the authority to request an action at all. A deny rule prevents actions that should never proceed, whoever might be willing to approve them. An approval gate adds a decision point when an otherwise authorized action carries additional risk. Authorization limits what is possible, deny rules remove what is unacceptable, and approval gates cover what is permissible but consequential. A gate is not a substitute for the other two: an approval prompt on an action the agent should never have been able to request only moves the failure to the person approving it.

Prompt Filtering Alternatives: Controls That Do Not Depend on Spotting the Attack

Prompt and input filtering ask a classifier to recognize hostile text. That is useful, and it is also a bet that the attacker's text looks like what the classifier was trained on. Posted in October 2025, the paper The Attacker Moves Second, by researchers including authors from OpenAI, Anthropic, and Google DeepMind, tested 12 recent defenses built on prompting, training, filtering models, and secret knowledge. Its authors used adaptive attacks, which change strategy to counter each defense, built from gradient descent, reinforcement learning, random search, and human-guided exploration. They reported attack success rates above 90% for most defenses, where the majority had originally reported near-zero. That is the authors' result under strong attacks, and not a claim that every filter fails against every attacker.

Meta's Agents Rule of Two draws the practical conclusion. Until detection of prompt injection is reliable, an agent in one session should have no more than two of three properties: processing untrusted input, reaching sensitive systems or data, and changing state or communicating externally. If a task needs all three, the agent should not run autonomously, and at a minimum it needs supervision, through human approval or another reliable means of validation. Meta also cautions that designs satisfying the rule can still fail, for example when a user blindly confirms a warning, and that the rule supplements least privilege and does not replace it. Five controls work on that principle because none of them needs to recognize the attack.

Alternative What it removes Why it does not need detection
Least-privilege tools Capabilities the task never needs A tool that is not offered cannot be called, however the request is phrased
Scoped credentials Authority beyond the task A credential cannot do what it was not issued to do
Approval gates Autonomous high-impact actions A rule or a person decides at the action, whatever caused it
Sandboxing and network limits What a compromised agent can touch Containment holds whether or not the attack was recognized
Deterministic argument checks Out-of-scope and malformed calls Rules compare values and do not interpret intent

Filtering still has a place. Detectors for prompt injection and sensitive data catch real attempts and produce useful signals. The argument is that they cannot be the only control, and that applies to Prediction Guard's own safeguards, which are detection controls.

Tool Call Security: What to Decide Before a Call Runs

Tool call security means making a decision on each call from facts the model cannot talk its way around: who is acting, which tool, which target, which environment, which arguments, and whether the session has already processed untrusted input. The Model Context Protocol specification sets the baseline, and it separates requirements from recommendations. Servers must validate all tool inputs, enforce authorization, rate limit calls, and sanitize outputs. Clients should prompt for confirmation on sensitive operations, show tool inputs to the user before a call to guard against exfiltration, and validate results before passing them to the model.

A rule set makes this concrete. The example below is illustrative and is not any product's configuration.

# Illustrative rule set. Evaluated deny, then ask, then allow.
deny   delete_*      where environment = production
deny   read_file     where path matches ".env" or "*.pem"
ask    write_file    where path is outside the task workspace
ask    send_message  where recipient is external
ask    run_command   where command matches "git push" or "rm -r"
allow  read_file     where path is inside the task workspace
allow  search_*      always
default: deny

Three cautions apply. First, results are an input too: instructions can arrive inside a tool result, so check results before they reach the model. Second, do not trust a tool's description of itself. OpenAI's Codex documentation says destructive app and MCP tool calls always require approval when the tool advertises a destructive annotation, unless the tool also advertises a read annotation, which takes priority. Either way the gate depends on what the tool says about itself, and the MCP specification tells clients to treat tool annotations as untrusted unless they come from trusted servers. For servers you do not control, classify the tools yourself. Third, rules that match command text are easy to sidestep. Claude Code's documentation notes that a deny rule on a command such as rm covers the form the agent usually writes but not the same program invoked by full path or through a shell wrapper, and it points to sandboxing for enforcement that does not depend on command text. The rule set above is a first layer, and the sandbox is the second.

Destructive Action Prevention

Destructive action prevention covers anything that deletes, overwrites, forces, revokes, or cannot be undone before someone notices: dropping a database, a force push, an external payment, a production schema change. Five measures work in this order of strength.

  1. Do not offer the tool. OWASP lists excessive functionality as a root cause. If a task only needs to read documents, a tool that can also delete them should not be in the agent's reach.
  2. Scope credentials to one environment. A staging credential that cannot touch production limits the damage a confused agent can do.
  3. Gate by consequence. Deny the action in production, and ask elsewhere, with a confirmation the agent cannot complete for itself.
  4. Make deletion reversible. Delayed or soft deletes, and backups kept apart from the data they protect, limit the cost of a mistake that does get through.
  5. Limit the rate. OWASP notes rate limiting does not prevent excessive agency, but it limits damage and buys time to notice.

The PocketOS sequence shows why these measures need to be independent. Three controls would each have interrupted it, and none of them depended on the agent behaving. Credential scope: a token limited to the task would not have had the reach to delete a volume. Environment isolation: a staging task that could not reach production could not have deleted production data, whatever the token allowed. An approval gate: a decision point before the delete would have put the target, a production volume, in front of a person or a rule. The incident needed all three to be missing at once. The founder also told IBM the project was configured with explicit rules, so written instructions were present and nothing enforced them.

The lesson is to build each control so that one failure does not decide the outcome, and not to let the gate stand in for the other two. Meta's caution applies here: approval can fail when people confirm without reading, which is a reason to shrink what reaches the gate.

Secrets and Credential Protection

Secrets and credential protection starts from a measured problem. GitGuardian's 2026 report counted 28.65 million new hardcoded secrets in public GitHub commits in 2025, up 34%. Commits assisted by Claude Code leaked secrets at 3.2%, against a 1.5% baseline across public commits, though GitGuardian cautions against reading the gap as a simple tool failure, since developers remain in control of what is accepted and pushed and the leak still happens through a human workflow. It also found 24,008 unique secrets in MCP-related configuration files, 2,117 of them valid, and notes that some MCP setup guides recommend putting keys directly in configuration. PocketOS adds the operational version: the credential that did the damage was a token the agent found for itself. Defaults matter too. Claude Code's sandboxing documentation notes that its default read behavior still allows reading credential files such as the AWS credentials file and the SSH directory, and that sandboxed commands inherit credentials from the parent environment unless you add credential rules to block reads, remove variables, or mask values.

Four measures follow.

  • The agent does not hold standing credentials. The tool layer attaches a scoped, short-lived credential at call time, so there is nothing for the agent to find or repeat.
  • Secret paths are denied. Claude Code's settings examples show a deny rule for the project's environment file, and the rule set above does the same.
  • Secrets are scrubbed and masked. Remove credentials from tool results before they reach the model, and mask keys embedded in MCP URLs and configuration.
  • Exposure triggers rotation. An exposed token is treated as compromised and replaced, not just removed.

Human Approval Workflows That People Keep Using

The MCP specification recommends that applications keep a human in the loop with the ability to deny tool invocations, and that they present confirmation prompts. That is guidance for applications that host clients, not a requirement on servers, and the specification says the protocol itself does not mandate any particular interaction model. OWASP says to require a person to approve high-impact actions. The risk in practice is approval that turns into reflex. Meta's post warns that designs can still fail when a user blindly confirms a warning, and IBM's article on PocketOS separates box-checking sign-off from real control points over what a person can change or stop. Claude Code's sandbox documentation describes one response: define boundaries up front so most commands run without a prompt. Human approval workflows work when the prompts are rare, specific, and hard to approve by reflex.

APPROVAL REQUIRED
Agent:       billing-reconciler  (owner: finance-platform)
Started by:  a.nguyen
Action:      delete_volume
Target:      prod-db-main  (production)
Why asked:   destructive action in production
Expires:     10 minutes, then denied
[Approve once]   [Deny]

That card shows what an approver needs: the exact action and target, the environment, who started the run, why the gate fired, and what happens if nobody answers. Four design rules sit behind it. Gate by consequence and not by tool, so only destructive, external, or out-of-scope actions ask. Approve one call at a time and not a whole session. Default to deny when no one answers. And make sure an agent cannot approve its own request or complete a confirmation itself. Record who approved what, and when.

Some tools now route approvals to an automated reviewer instead of a person. Claude Code's auto mode uses a classifier to review actions, and Codex offers an optional Auto-review that sends eligible approval requests to a reviewer agent, while its default routes them to the user. These can cut prompts, but they are automated review and not human approval, so keep the person for actions no automated reviewer should decide, such as production changes.

AI Coding Agent Security

Coding agents are the hardest case because they combine all three Rule of Two properties in one session: untrusted input from repositories, issues, and web pages, reach into source code and secrets, and the ability to run commands, push code, and deploy. The two most documented products use the same two-layer answer.

Claude Code pairs approval rules with sandboxing. Allow, ask, and deny rules decide which actions run, prompt, or are refused, and the sandbox sets boundaries on which directories and network hosts the agent can touch so that routine commands do not need approval. Codex describes the same split: the sandbox mode sets what the agent can technically do, and its approval policy setting sets when it must ask. Locally, in the CLI and IDE extension, its defaults turn network off and limit writes to the workspace, it asks before editing outside the workspace or running commands that need the network, and it warns that enabling network or web search lets prompt injection make the agent fetch and follow untrusted instructions.

A sensible baseline for a coding agent follows from both: sandbox on, network off, writes confined to the task workspace, secret paths denied, production credentials never present, and approval required for pushes, installs, outside-workspace writes, and anything destructive. Prediction Guard's agent sandboxing guide and its piece on agents that execute code cover the infrastructure layer in more depth.

Where Prediction Guard, a Sovereign AI Control Plane, Fits

A sovereign AI control plane is the architecture that identifies, authorizes, enforces, meters, records, and contains agent actions, running inside your own boundary. Runtime approval is one of the decisions it makes at the tool call, and what Prediction Guard ships for it today is narrower than the full pattern in this guide.

Operators can review sensitive workspace actions. In Agent Forge, agents can read, write, edit, and search workspace files, and administrators set each of those tools to Allow, Ask, or Deny. The Sessions API can approve tool calls, so an application or an operator console can present the decision.

Agents operate within the authority of their keys and the people who start them. A run is limited to what the key, the agent, and the person who started it can all reach, including when one agent calls another. Keys are scoped to agents, knowledge bases, and skills.

Sensitive information can be detected or blocked. Safeguards check for PII, prompt injection, and credentials, and can block or only detect. A Tool Content control extends PII, prompt-injection, and secrets checks to the results that tools send back to the model. Credential scrubbing is part of the OWASP and NIST baselines and turns on when a baseline is applied, and keys embedded in MCP URLs are masked in the Console, the API, and the AI Bill of Materials.

Administrators can contain agents that should no longer run. Administrators can quarantine or disable an agent, and removing an agent revokes its keys automatically.

Teams can investigate blocked runs and agent activity. The Console keeps a live audit log, and blocked-run messages name the safeguard that fired.

It does not establish everything. It enforces on traffic routed through it. Per-invocation authorization at the tool server and human-in-the-loop approval gates with workflow automation are not yet generally available, so approval today is the Ask setting on workspace file tools and the Sessions API, as Prediction Guard's runtime platforms comparison and blast radius guide both state. The classification of which actions count as destructive, and the approval experience around them, remain decisions for your own teams. Safeguards that detect are one layer and not a substitute for the controls above. Its emergency shutdown guide covers stopping an agent that should no longer run.

Rolling Out Gates in Three Stages

  1. Observe. Run the rules in record-only mode and see which calls would have been asked or denied. Fix the rules that would have fired constantly.
  2. Ask. Turn on approval for the actions with real consequences, and measure how often people approve without changes. A rate near 100% of approvals granted without changes may indicate that the gate is too broad or that its criteria need refinement.
  3. Deny. Move patterns that no one should approve, such as production deletes from an agent, to deny, and leave the rest as ask.

Gate the Action, Not the Prompt

Runtime approval gates are most effective when they operate alongside scoped credentials, least-privilege tools, sandboxing, and audit records. The goal is not to ask people to approve every action, but to give agents the authority they need while preventing consequential actions from proceeding unchecked. That is what operational control of agents means in practice, and it is something a team can demonstrate. To see how these controls fit together, read Prediction Guard's product overview.

How Prediction Guard Solves This

Prediction Guard gives regulated enterprises operational control of their AI agents: one sovereign AI control plane that identifies, authorizes, enforces, meters, records, and contains every action an agent takes, running inside the customer's own boundary. For AI agent security at the tool call, it ships Allow, Ask, and Deny settings on Agent Forge workspace file tools, Sessions API tool-call approval, runs limited to the authority of the key, the agent, and the person who started them, Safeguards and a Tool Content control for sensitive data and credentials, quarantine and disable controls, and a live audit log.

Its limits are the ones above. Per-invocation authorization at the tool server and human-in-the-loop approval gates with workflow automation are not yet generally available, so approval today is the Ask setting on workspace file tools and the Sessions API. It enforces on traffic routed through it, its safeguards that detect are one layer and not a substitute for the controls above, and classifying which actions are destructive and designing the approval experience remain decisions for your own teams.

FAQ: Runtime Approval Gates and AI Agent Security

1. What is a runtime approval gate?

A runtime approval gate is a control that pauses a specific agent action before it executes, checks it against rules enforced outside the model, and then allows it, denies it, or routes it to a person. It acts on the action and not on the prompt, so it works whatever caused the model to attempt it.

2. What is AI agent security?

AI agent security is the set of controls that decide what an AI agent may do, what it may reach, and what happens when it is wrong or manipulated. Its core pieces are identity and authority for each agent, checks at the tool call, protection for secrets, a way to stop the agent, and records of what happened.

3. Why is prompt filtering not enough?

Prompt filtering has to recognize the attack, and adaptive attackers keep changing it until it is not recognized: researchers bypassed 12 recent defenses with success rates above 90% for most. It also catches nothing when no attacker is involved, as in the PocketOS and Replit incidents. Prompt filtering alternatives such as scoped tools, scoped credentials, sandboxing, and approval gates do not depend on spotting anything.

4. What should require human approval?

Actions that are destructive, irreversible, external, or outside the task's scope should require human approval, and everything routine should not. Examples are deleting or overwriting data, pushing code, sending messages outside the organization, spending money, and any write outside the task workspace. Gate by consequence and not by tool name.

5. How do you avoid approval fatigue?

Avoid approval fatigue by asking rarely and specifically. Gate only consequential actions, contain routine work in a sandbox so it does not need a prompt, show the exact action and target, approve one call at a time, and track the share of approvals that are granted unchanged.

6. How do you protect secrets from AI coding agents?

Keep standing credentials away from the agent, deny reads of secret files, scrub secrets from tool results, mask keys embedded in configuration and MCP URLs, and rotate anything exposed. GitGuardian found 24,008 unique secrets in MCP-related configuration files on public GitHub in 2025, so treat configuration as a place secrets leak.

7. What is the difference between a sandbox and an approval gate?

A sandbox limits what an agent can technically do on its host, such as which files it can write and whether it can reach the network, while an approval gate decides when a specific action may proceed or needs a person. Coding agents from both Anthropic and OpenAI use the two together, because a sandbox cannot decide whether a permitted action is the right one.