Agents need permissions, not prompts

The system prompt is a suggestion. The policy layer is the contract. How to let agents act on behalf of real users without anyone having to trust the model.

A policy core with tools around it, some connections allowed and some blocked

Every agent demo starts the same way: a model, a list of tools, and a system prompt that says please only do what the user is allowed to do. It works on stage. It does not survive a real tenant with real data, real roles, and a security officer who reads your architecture document line by line.

Picture a typical enterprise assistant. It can search documents, draft and edit pages, open tickets, post in Slack and Teams, and call whatever connectors an organisation has enabled. Every one of those actions happens on behalf of a specific person, inside a specific organisation, against data that person may or may not be allowed to touch.

This post is about the layer that makes that safe. Not the model, not the prompt — the boring, deterministic code between the model and the world.

The prompt is not a boundary

A prompt is an instruction to a probabilistic system. It shapes behaviour; it does not constrain it. If the only thing stopping an assistant from reading another department's documents is a sentence in its context window, you don't have access control. You have a hope with a nice paragraph attached.

Here's how it usually goes wrong. A user in one department asks the assistant to "summarise everything we have on the procurement review". The retrieval layer is correct — it only returns documents that user can see. But one of the tools, a generic "fetch by URL" helper, has no idea who is asking. A document the user can see links to a document they can't. The model, being helpful, follows the link.

Nothing malicious happens. Nobody jailbreaks anything. The model does exactly what a helpful model does. That's the point: the failure isn't in the model's judgement, it's in the assumption that the model's judgement is a security control.

So move the boundary out of the model entirely. The rule became simple to state and annoying to implement: the model proposes, the platform decides. The model never holds credentials, never calls a tool directly, and never gets to argue its way past a denial.

What a tool call looks like on the wire

When the model wants to do something, it emits a tool call — a name and some arguments. In a naive setup that goes straight to a function. With a policy layer it becomes a request to it, enriched with everything the model doesn't know and shouldn't be trusted to supply.

A tool call moving through policy, approval, execution and auditOne tool call, end to end. The assistant only ever talks to policy; policy is the only thing that talks to tools.

The enrichment matters more than the decision. By the time the request reaches the policy engine it carries:

  • the actor — tenant, user, role, and every group they inherit, resolved by the platform from the session, never from the conversation
  • the resources — not just the tool name, but the concrete things the arguments touch: this document, that channel, this mailbox
  • the risk tier — declared in the tool's manifest by whoever built the connector, reviewed like any other code change
  • the context — which conversation, which step of a multi-step plan, and whether a human already approved something related

Resolving resources is where most of the work hides. A tool called share_file with arguments doc_id and group touches two things: the document and the group. The policy engine needs to know who owns both, whether the actor can see both, and whether sharing across those two is allowed in this tenant at all. That means every connector has to answer one question well: given these arguments, what will you touch?

connectors/files/share.py
python
from platform.tools import tool, Risk, Resource
 
@tool(
    risk=Risk.WRITE_SHARED,
    idempotent=True,
    description="Share a document with a group in the same tenant.",
)
def share_file(doc_id: str, group_id: str, *, creds) -> dict:
    return files.share(doc_id, group_id, creds=creds)
 
@share_file.resources
def _(args: dict, actor) -> list[Resource]:
    doc = files.get(args["doc_id"], as_user=actor)
    grp = directory.group(args["group_id"], tenant=actor.tenant)
    return [
        Resource("file", doc.id, owners=doc.owners, labels=doc.labels),
        Resource("group", grp.id, owners=grp.admins),
    ]

That as_user=actor is load-bearing. Every lookup a connector does while answering the "what will you touch" question happens with the actor's own permissions. If the actor can't see the document, resolution fails, and the call is denied before anyone asks whether sharing is allowed. You deny on what the actor can't see, not on what the model says.

Three answers: allow, deny, ask

The policy engine returns one of three decisions. Most calls are boring reads and go straight through. Writes to shared systems pause for the owner. Anything irreversible needs a named person to click yes. A tenant can tighten any tier for any tool; nobody can loosen a tier below what the manifest declares.

Risk tiers mapped to default decisions, with rough share of callsRisk tiers and the default decision for each. The distribution is what makes approvals tolerable: humans only see the few percent that matter.

The distribution on that chart is the reason the whole scheme is usable. If every action needed a click, people would click yes without reading — which is worse than no approval at all, because now there's a signature on it. Because roughly seven in ten calls are reads and another chunk are writes to the user's own space, humans only get pulled in for the handful that touch other people or the outside world.

The engine itself is deliberately dull. No machine learning, no scoring, no "confidence". Ordered rules, first match wins, and every decision carries the rule that produced it so the audit log can explain itself.

policy/authorize.py
python
def authorize(call: ToolCall, actor: Actor) -> Decision:
    tool = registry.get(call.tool)
    if tool is None or not actor.tenant.enabled(tool.name):
        return Decision.deny("tool not enabled for tenant", rule="T1")
 
    try:
        resources = tool.resources(call.args, actor)
    except NotVisible as e:
        return Decision.deny(f"actor cannot see {e.kind}", rule="R1")
 
    if any(r.labels & actor.tenant.restricted_labels for r in resources):
        return Decision.deny("restricted label", rule="R2")
 
    risk = max(tool.risk, actor.tenant.override(tool.name))
    if risk >= Risk.IRREVERSIBLE:
        return Decision.ask(approvers=[actor], named=True, rule="K3")
    if risk >= Risk.EXTERNAL:
        return Decision.ask(approvers=[actor], preview=True, rule="K2")
    if risk >= Risk.WRITE_SHARED and not actor.owns_all(resources):
        return Decision.ask(approvers=owners_of(resources), rule="K1")
    return Decision.allow(rule="A0")

Two details worth calling out. First, max(tool.risk, override) — the tenant can only push risk up. Second, the external tier asks the user themselves, with a preview of exactly what will be sent. That sounds redundant, since the user asked for it. It isn't. The user asked in natural language; the preview shows the literal email, recipients and attachments the model produced. A surprising number of approvals at that tier end in "no, not that group".

The life of a tool call

Once a call is authorized, the job isn't done. Models retry. Networks retry. Approval flows can take hours, and the user may have closed the tab. A multi-step plan might be three calls into five when something fails. Treat a tool call as a plain function invocation and you get duplicate emails, half-shared folders, and tickets opened twice.

So every tool call is a small state machine, persisted from the moment it's proposed.

State machine of a single tool call from proposed to committed, with failure pathsEvery state is written down before the next one starts, so a crash or a retry resumes rather than repeats.

The states that earn their keep:

  1. Reserved. After authorization and before execution, write an idempotency key derived from the conversation, the step, and the normalised arguments. If the same call arrives again — from a model retry, a reconnect, a double click — it finds the reservation and waits for the original instead of running twice.
  2. Awaiting. Approval requests live outside the conversation. The approver might see them in Teams, in the web app, or by email. They expire after a day by default, because an approval granted three weeks later is almost certainly approving something nobody remembers asking for.
  3. Compensated. Tools that can undo themselves declare a compensating action in the manifest. If step four of a plan fails, steps one to three are unwound in reverse order where possible, and the user is told plainly which ones couldn't be.
runtime/execute.ts
ts
export async function execute(call: AuthorizedCall): Promise<Receipt> {
  const key = idempotencyKey(call.conversationId, call.step, call.args);
  const existing = await calls.reserve(key, call);
  if (existing) return existing.wait();
 
  // Credentials are fetched here, per call, scoped to the actor.
  // The model never sees them and the token dies with the call.
  const creds = await vault.delegated(call.actor, call.tool.scopes);
  try {
    const result = await call.tool.run(call.args, creds);
    return calls.commit(key, result);
  } catch (err) {
    await calls.fail(key, err);
    await compensatePriorSteps(call.plan, call.step);
    throw err;
  } finally {
    creds.revoke();
  }
}

The credential handling in the highlighted lines took longer to get right than anything else in this file. Connectors get a delegated token for that actor, scoped to the tool's declared scopes, valid for one call. No long-lived service account that can do anything, no token in the model's context. In an air-gapped environment, where there's no external identity provider to lean on, the same tokens can come from an on-prem vault with the same shape, so connector code doesn't care where it's running.

Audit is a feature, not a log

I used to think of audit as compliance plumbing: write everything to a table, hope nobody ever needs it. Users changed my mind.

The first question people ask after an agent does something is why. Why did it share that? Who approved it? What did it actually send? If answering that requires a support ticket and someone with database access, trust erodes fast. So the audit trail became a screen. Every action the assistant took on your behalf, with the rule that allowed it, the approver if there was one, and the exact arguments — visible to you, and to your tenant admins for actions in their organisation.

QuestionWhere the answer comes from
What did it do?committed calls, with normalised arguments
Why was it allowed?decision rule id and the resources it matched
Who said yes?approver identity and timestamp, if the tier asked
What did it almost do?denied and expired calls, kept for 90 days
Can it be undone?compensating action, if the manifest declares one

The "almost did" row tends to be the most useful one. Denied calls are a map of where the model's intentions and the organisation's rules disagree. A cluster of denials on one tool usually means either a badly written tool description that confused the model, or a tenant setting that is stricter than anyone intended. Both are fixable once you can see them.

Things that are easy to get wrong

Idempotency matters more than you think. Without it, an approval that takes long enough for the model to retry means the approver receives two identical requests, approves both, and the file gets shared twice with two notifications. Harmless, embarrassing, and exactly the kind of thing that makes a security officer stop trusting the rest of your story.

Tool descriptions are part of the security surface. A vague description makes the model reach for the wrong tool, and the wrong tool is more likely to be denied, which looks like the assistant being broken. Review tool descriptions with the same care as the code, and keep an evaluation set of "which tool should it pick" cases per connector.

Approvals need context, not just a button. An approval card that says "Assistant wants to run share_file. Approve?" gives nobody enough to make a good decision. A useful one shows the requester, the plain-language request, the exact resources, and what happens if you say no. Expect approval rates to drop slightly and approval quality to rise a lot.

Multi-agent setups don't change the rules. When one agent delegates to another, the sub-agent inherits the original actor, never a broader identity. It's tempting to give an orchestrator a service account "to keep things simple". It is the single fastest way to end up with an agent that can do things no human in the organisation could.

MCP helps, but it isn't the policy layer. Exposing connectors over MCP gives tools a clean, standard shape and makes third-party integrations much easier. It doesn't decide who's allowed to call what. Put the policy engine in front of every MCP server, exactly as you would in front of your own connectors.

What I'd do differently

If I were starting a system like this, I'd build the resource resolution before the first tool, not after the tenth. Retrofitting "what will you touch" onto connectors written without it is slow, and every retrofit tends to find at least one argument that touches more than the author realised.

I'd also make the audit screen a day-one feature. It's easy to treat it as an afterthought for an enterprise review, and it ends up being the thing users trust most. People are remarkably comfortable with an agent acting for them once they can see, plainly, everything it did and why.

And I'd spend less time on clever prompt-level guardrails. They're useful for tone and for keeping the model on task. They are not where safety lives.

The model proposes. The platform decides. Keep those two jobs in different places, and keep the second one boring.

None of this is glamorous. It's ordered rules, state machines, scoped tokens and a big table of receipts. It's also the only reason a cautious organisation will let the thing anywhere near its documents.