- Updated
- Reading
- 15 min
- By
- Anlyon Team
A permission control framework for AI agents: allow, limit, approve or forbid
A practical permission framework for AI agents: classify each action by risk and reversibility, then allow, limit, require approval or forbid. With TypeScript.
- guardrails
- permissions
- approvals
- policy
- impact limits
- receipts
- typescript
Short answer: a permission control framework for AI agents is a rule that says what an agent may do without asking. Classify every action by risk and reversibility, then give each class one of four decisions: allow, limit, require approval, or forbid. Enforce the rule outside the model, where a tool call becomes a real request.
This guide is the framework in seven steps, with a classification table, a TypeScript pattern you can use in any stack, and the standards that apply. The last section maps each step to Anlyon. The framework stands without it.
TL;DR
- List the actions your agent can take, as named operations.
- Classify each one: read, write, irreversible or destructive.
- Decide per class: allow, limit, require approval, forbid.
- Enforce outside the model, with the credential out of the agent's reach.
- Bind every approval to the exact request.
- Share limits across sessions and keys.
- Keep a receipt for every action, and separate who asks from who decides.
Why do AI agents need a permission framework?
A person with production access makes a few dozen changes a day and notices when something looks wrong. An agent makes thousands, reads text written by strangers, and repeats a mistake at machine speed. Three things follow.
- A prompt is not a permission. "Never refund more than $100" in a system prompt is a request. The model weighs it against everything else in its context, including an email an attacker wrote.
- A client prompt is not a control either. A confirmation dialog in the agent's own session can be switched off, as with Claude Code's permission flag, and after the fiftieth it gets approved without being read.
- Reviewing everything does not scale. If every call waits for a person, the reviewers stop reading. The framework exists to keep approvals few enough to mean something. See why approval prompts become a rubber stamp.
Step 1: what can the agent do?
Start with an inventory of actions, not systems. "The agent has Stripe access" cannot be classified. "The agent can refund a charge, up to the charge amount" can.
Replace general tools with named operations wherever you can:
| General tool | Named operations |
|---|---|
http_request(url, method, body) | refund-charge(charge, amount), get-invoice(id) |
run_sql(query) | cancel-subscription(customerId) |
| A whole MCP server | The four tools on it the agent needs |
A named operation has a fixed destination and a schema for its input. That makes it something a reviewer can reason about. There is more on this in AI agent tool permissions.
Step 2: how do you classify actions by risk and reversibility?
Ask two questions of each action. Can it be undone? How much can one call change, and how much can a loop of calls change?
| Class | Test | Examples |
|---|---|---|
| Read | Changes nothing | List issues, fetch an invoice, search contacts |
| Write | Changes something you can change back | Update a ticket's priority, add a label, edit a draft |
| Irreversible | Its effect cannot be taken back | Send an email, pay or refund, publish, merge |
| Destructive | Deletes or cancels | Delete a record, drop a table, cancel a subscription |
Three rules keep the classification honest:
- Classify by the worst case. A tool that can update one field or overwrite a whole record is as risky as the overwrite.
- Do not trust the tool's own label. A server can describe a tool that deletes data as harmless. The MCP specification says clients must treat tool annotations as untrusted unless they come from a trusted server. Read what the tool does.
- Reads are not free. A read that returns customer data to a model that also has a send tool is half of a leak. Classify by what the agent can do next, too.
Step 3: what should happen for each class?
Four decisions cover every case.
| Decision | Meaning | Use it when |
|---|---|---|
| Allow | Runs with no check beyond input validation | The action is a read, or a small write that is easy to change back |
| Limit | Runs until a count or an amount is used up | One call is fine and a thousand are not |
| Require approval | Waits for a person who sees the exact request | The action cannot be taken back, or the amount is large |
| Forbid | Never runs for this agent | No task this agent has needs it |
A starting matrix. Adjust the thresholds to your product, and keep the shape.
| Class | Default decision | Tighten when |
|---|---|---|
| Read | Allow | The data is sensitive: limit, or require approval for bulk exports |
| Write | Allow, under a limit | The write touches many records at once: require approval |
| Irreversible | Require approval above a threshold, limit below it | The recipient or the amount is outside what the task needs: forbid |
| Destructive | Require approval | The agent's tasks never need it: forbid |
Limits and approvals answer different questions. An approval asks "is this one call right?". A limit asks "how much, in total?". A refund agent needs both: small refunds run under a daily limit, and large ones wait for a person.
How do you write this as a tool authorization policy in TypeScript?
Keep the policy as data, and evaluate it in one place. This pattern has no dependencies and fits any agent framework.
type RiskClass = 'read' | 'write' | 'irreversible' | 'destructive';
type ToolCall = {
tool: string;
input: Record<string, unknown>;
/** Set by your server from its own session. Never taken from model output. */
userId: string;
};
type Decision =
| { effect: 'allow' }
| { effect: 'limit'; limitKey: string; amount: number }
| { effect: 'require_approval'; reason: string }
| { effect: 'forbid'; reason: string };
type Rule = {
risk: RiskClass;
decide?: (call: ToolCall) => Decision;
};
const DEFAULTS: Record<RiskClass, (call: ToolCall) => Decision> = {
read: () => ({ effect: 'allow' }),
write: (call) => ({ effect: 'limit', limitKey: `writes:${call.userId}`, amount: 1 }),
irreversible: () => ({ effect: 'require_approval', reason: 'Cannot be undone' }),
destructive: () => ({ effect: 'require_approval', reason: 'Deletes or cancels' }),
};
const POLICY: Record<string, Rule> = {
'get-invoice': { risk: 'read' },
'update-ticket-priority': { risk: 'write' },
'refund-charge': {
risk: 'irreversible',
decide: (call) => {
const amount = Number(call.input.amount);
if (!Number.isInteger(amount) || amount <= 0) {
return { effect: 'forbid', reason: 'Amount is not a positive integer' };
}
return amount <= 5_000
? { effect: 'limit', limitKey: 'refunds:usd', amount }
: { effect: 'require_approval', reason: 'Refund over $50' };
},
},
'delete-customer': { risk: 'destructive' },
};
export function authorize(call: ToolCall): Decision {
const rule = POLICY[call.tool];
// A tool nobody classified is forbidden, not allowed.
if (!rule) return { effect: 'forbid', reason: 'Unclassified tool' };
return (rule.decide ?? DEFAULTS[rule.risk])(call);
}
Five properties make this more than a switch statement:
- Default deny. A tool with no entry is forbidden. Adding a tool means classifying it.
- The decision is separate from the execution.
authorizereturns a decision and never calls the tool, so it is easy to test and to log. - The user comes from your server. No tool input can change whose limit or whose approval applies.
- A value the policy cannot evaluate does not pass. A malformed amount is refused, not waved through.
- The policy is one file. A reviewer can read it, and a change to it shows up in a diff.
What the function cannot do by itself is steps 4 to 7. It runs in your process, next to the agent. The enforcement has to live somewhere the agent cannot edit or skip.
Step 4: where do you enforce the decision?
Outside the model, and outside the process the model drives. If the agent's process holds the production credential, the policy is advisory: any code path that skips authorize, or any shell command, reaches the API directly.
The working arrangement has three parts:
- The credential lives with the enforcer. The agent asks for an operation by name. A separate service checks the policy, adds the credential and makes the call.
- The agent's own key can ask and cannot change. It may invoke actions. It may not define them, raise a limit, relax a rule or decide an approval.
- There is no second route. If the same token is also in a
.envfile the agent can read, the framework governs only the calls that choose to use it.
Step 5: how do you bind an approval to the exact request?
An approval of "refund-charge" is an approval of a tool name. The agent can ask, get a yes, and send a different amount. Bind the approval to the request itself:
- Freeze the request when approval is asked for: the action, its input, its target and the version of the action's definition.
- Compute a digest over that frozen request and store it with the approval.
- Show the approver the frozen request, not a summary the agent wrote.
- Before sending, recompute the digest. If anything differs, refuse.
- Give the approval an expiry, so a yes from last week cannot release a call today.
Two more rules belong here. The credential that asked for an approval must never be able to decide it. And an approval should be used once: a second attempt with the same approval is a replay, not a retry.
Step 6: why must limits be shared across sessions and keys?
A limit kept in the agent's memory, or counted per session, is reset by starting a new session. A limit per API key is doubled by creating a second key. An agent that retries in a loop, or ten agents working in parallel, will find either gap without meaning to.
A limit that holds has four properties:
- One counter for everyone. Every agent, session and key in the environment draws from the same limit.
- Reserved before the call. The amount is taken before the request is sent, so two concurrent calls cannot both spend the last of it.
- Counted in the unit that matters. Dollars refunded, emails sent, records changed. Not requests per minute, and not model tokens.
- Out of the agent's reach. The key that spends against a limit cannot raise it.
When your agent acts for your customers, add a scope: the same rule counted per user, so one customer's runaway loop stops at that customer's limit. See per-user limits and how to choose a limit's scope.
Step 7: what should a receipt record?
Every action should leave a record that answers five questions later, without the agent's cooperation:
- What exactly was requested, and for which user?
- Which rule matched, and was the call allowed, limited, approved or refused?
- Who approved it, if anyone?
- What did the destination answer?
- Is the outcome known?
The last question is the one most logs skip. A timeout does not mean the call failed. If a request may have reached the destination, record the outcome as unknown and do not send it again until someone has checked. Retrying an unknown refund is how a customer gets refunded twice. See what an unknown outcome is.
Add one control above all of this: a switch that stops the agent acting, for the hour when something is wrong and you do not yet know what.
Which standards apply to AI agent tooling?
No standard gives you the matrix in step 3. Several define the parts around it.
| Standard | What it covers | What it leaves to you |
|---|---|---|
| Model Context Protocol | How tools are described, listed and called. It says there should always be a human in the loop with the ability to deny tool invocations | Which calls need that human, and where the confirmation is enforced |
| MCP authorization, on OAuth 2.1 | How a client signs in to a remote tool server, and that a token is valid for one server only | What the signed-in client may do with each tool. See MCP OAuth |
| OWASP Top 10 for Agentic Applications | The risks: tool misuse, identity and privilege abuse, and eight more | The controls, in your code. We mapped each one in OWASP's agentic top 10, mapped to code |
| OWASP AI Agent Security Cheat Sheet | Practices for tool permissions and human oversight | The thresholds |
The EU AI Act's human-oversight and recordkeeping obligations point the same way for systems in its scope. Whether they apply depends on the deployment and your role in it.
How does Anlyon implement this framework?
Anlyon is one place to run steps 4 to 7 without building them. Each line below holds for actions routed through Anlyon. A tool your own code calls directly is not routed through Anlyon and is not governed by it.
| Step | In Anlyon |
|---|---|
| 1. Named operations | An action has a fixed host and an input schema. An action that carries a secret has a fixed host, so an input cannot choose where the credential is sent |
| 2. Classify | When you import an OpenAPI spec or register a remote MCP server, Anlyon suggests a class for each operation: read, write, irreversible or destructive. It is a suggestion, read from the spec or from what the server says, and applied only when a person accepts it |
| 3. Decide | A policy per action: auto_approve, require_approval or auto_deny, with a condition on the input. requiresApproval on an action is a floor. A policy that names the action can lower it and no other policy can |
| 4. Enforce outside the agent | Your agent names an action and passes input, and Anlyon resolves the credentials at dispatch and makes the request. The model never sees a credential |
| 5. Bound approvals | For a governed action, the approval is bound to a digest of the request, target, versions, preconditions and expiry, and Anlyon recomputes it before dispatch and refuses on any difference. The digest is SHA-256 over the canonical request. The credential that requested an approval can never be the one that decides it |
| 6. Shared limits | Every agent, session and key in the environment draws from the same limit, reserved before dispatch. A limit can count any unit you declare, such as emails, messages or rows, and can be counted per user |
| 7. Receipts | Every governed action returns a receipt with a grade. Halting an environment stops the agent acting and stops anything leaving the environment |
The step 3 matrix for a refund action, as two policies:
import { Client } from '@anlyonhq/sdk';
const ops = new Client({ apiKey: process.env.ANLYON_OPERATOR_KEY! });
await ops.approvalPolicies.create({
name: 'large-refunds-need-approval',
matchKind: 'action',
matchActionName: 'refund-order',
minAmount: 5000, // matches when the input's amount is 5000 or more
effect: 'require_approval',
requiredApprovals: 1,
priority: 10,
});
await ops.approvalPolicies.create({
name: 'small-refunds-auto',
matchKind: 'action',
matchActionName: 'refund-order',
effect: 'auto_approve',
priority: 20,
});
And the step 6 limit, counted for each of your users:
await ops.impactLimits.create({
name: 'CRM changes per user per day',
dimension: 'resource_mutations',
period: 'day',
amount: 20,
scope: 'end_user',
});
Creating a limit needs the impact-limits:write scope, which no key gets by default, so the agent cannot raise its own ceiling.
What the grades on a receipt mean:
confirmed: A read-back matched the request.acknowledged: The provider accepted the request. Nothing read it back.unknown: No usable response. Anlyon does not send it again. It stays unknown until a read-back or an operator settles it.failed: The provider rejected the request, or it never left Anlyon.refused: Anlyon refused it at dispatch.denied: The approval was denied.
What Anlyon does not do here
- It does not classify for you. A suggested class reads the spec or the server's own text, not the API's behaviour. A person accepts or changes it.
- A limit covers governed actions. An action with no declared impact draws on no limit. A tool adopted from an MCP server draws on a limit only when its first adoption, through the API, sets one.
- A limit holds within one environment, and an operator with
impact-limits:writecan raise it. - A halt stops new dispatch. A request another server already accepted is not recalled.
- A receipt is a database record with provider evidence. It is not signed and not tamper-evident.
- An approval is as good as its reviewer. Binding means that what was approved is what runs. It does not make a bad request good.
Read next
- AI agent tool permissions: least privilege for every tool call
- What a bound approval is and what an impact limit is
- How to put a remote MCP server behind Anlyon
- What an MCP gateway is, and how to choose one
- Official MCP servers and Security
- Docs: Approvals · Policy as code · Impact limits · Receipts and grades
Frequently asked questions
- What is an agentic AI permission control framework?
- It is a written rule for what an AI agent may do without asking. Each action the agent can take is classified by risk and reversibility, and each class gets one of four decisions: allow, limit, require approval or forbid. The rule is enforced outside the model, at the point where a tool call becomes a real request.
- How do you classify AI agent actions by risk?
- Ask two questions of each action: can it be undone, and how much can one call or a loop of calls change. That gives four classes. A read changes nothing. A write changes something you can change back. An irreversible action sends, pays, publishes or merges. A destructive action deletes or cancels.
- What standards exist for AI agent tooling?
- For how tools are described and called, the Model Context Protocol. For how a client signs in to a tool server, OAuth 2.1 as profiled by the MCP specification. For risks and controls, the OWASP Top 10 for Agentic Applications. None of them decides for you which actions need approval: that is your policy.
- How do you write a tool authorization policy for an AI agent in TypeScript?
- Keep the policy as data, not as conditions scattered through tool code. Give every tool a risk class, write a pure function from a call and its class to a decision, and run that function in the one place every call passes through. The function returns allow, limit, require approval or forbid, and never calls the tool itself.
- Should an AI agent be able to change its own permissions?
- No. The credential an agent holds should be able to ask for an action and nothing more. Defining actions, raising limits, relaxing approval rules and deciding approvals belong to other credentials, held by people or by a deploy pipeline.
