Most agent security conversations start with the model. Can it be jailbroken? Will it follow an instruction buried in a scraped web page? Those are real questions. They are also the wrong place to stop.
An agent's risk is shaped by what it can do, not only by what it decides. The model picks a tool. The tool carries the authority. If you only review the first half of that sentence, you are reviewing the part you control least.
The demo vs. production gap
In the demo, the agent has three tools: search_docs, get_weather, summarize. Nothing it calls can hurt anyone.
In production, the tool list grows one PR at a time. Someone adds create_ticket. Someone else adds run_sql "for internal analytics". A third person swaps the read-only GitHub token for one with full repo scope because the agent needs to open PRs now. None of these changes touched a route file, so none of them got the review a new public endpoint would get.
That's the gap. The tool registry is API surface. It just doesn't look like it.
Four questions for every tool
For each tool the agent can call, answer these:
- What kind of action is it? Read, write, execute, or trigger something external (email, payment, webhook, deploy). These are different risk classes and should be labeled that way.
- Whose identity does it run as? The end user's delegated identity? A shared service account? The agent's own credential with org-wide scope?
- What data can it reach? Not what it's meant to reach. What the credential and the query surface actually allow.
- Where is approval required? Is there a human-in-the-loop step, and is it enforced in the tool layer, or only suggested in the system prompt?
If the answer to #4 lives only in the prompt, you don't have an approval step. You have a polite request for one.
Failure mode 1: the read tool that reads everything
(Illustrative scenario, not a real incident.) A support agent gets a lookup_customer(query) tool. It's labeled read-only, and that's true. Under the hood it calls an internal admin endpoint that accepts arbitrary filters. "Read-only" holds. "Scoped to the customer in this ticket" does not. One injected instruction in a ticket body and the agent is paginating through every account in the system.
The model did nothing exotic. It used the tool exactly as designed. The design granted too much.
Failure mode 2: the side effect nobody listed
(Illustrative.) update_order_status looks like a single row write. It also fires a webhook that emails the customer and, when the status is "cancelled", kicks off a refund workflow. The tool description mentions neither. Reviewers approved a database write. They shipped a refund button.
Side effects belong in the tool's contract, the same way you'd document them on a public endpoint.
Failure mode 3: identity drift
(Illustrative.) The agent's credential started as a read-scoped token. Over six months it picked up write access on two repos, admin on a Slack workspace, and a cloud role someone attached while debugging an incident and never removed. No single change looked alarming. The sum is an over-privileged service account that takes instructions in natural language.
Make authority visible in the diff
One practical fix: have every tool definition declare its authority explicitly, so a change in authority shows up as a change in the diff.
@tool(
name="refund_order",
action="external", # read | write | execute | external
identity="user_delegated", # not "service_admin"
data_scope="order:{order_id}",
requires_approval=True,
)
def refund_order(order_id: str, amount_cents: int) -> RefundResult:
...
The decorator is pseudo-code, not a specific library. The point is that flipping requires_approval from True to False, or identity from user_delegated to service_admin, should be impossible to miss in review, and should be enforced at runtime by the tool layer rather than trusted to the model.
Then review it like any other API change:
- CODEOWNERS on the tool registry, so security sees permission changes.
- A CI check that fails when a tool's action class, identity, or approval flag changes without an explicit label.
- Tests that call each tool with out-of-scope arguments and assert the call is refused.
The reframe
"Can the model choose this tool?" is one question. The harder one is: "If it does, what authority does the tool grant?"
An agent is a natural-language client for whatever API you hand it. Review that API like one.
How does your team review tool additions today? Is anyone treating the tool registry as API surface, or does it still ride along in the same PRs as prompt tweaks?
Top comments (67)
Failure mode 3 is the one that quietly kills teams — no single credential change looks alarming, but six months of debugging grants add up to an over-privileged service account taking natural-language instructions. The decorator idea is the right fix: if flipping requires_approval doesn't show up in the diff, the review never happened. Do your CI checks also catch the slow drift, like a token that gained write scope three PRs ago, or only the changes in the current diff?
Good question. The diff check alone definitely isn't enough. I'd combine it with periodic checks against the actual permissions at the provider level, plus alerts when they drift from what's declared in the registry. The tricky part is making sure those checks don't become another dashboard everyone ignores.
Exactly — the check that becomes a dashboard nobody opens is just drift with extra steps. Tying the alert to detected drift rather than a standing green panel is the move; the registry only earns attention when it disagrees with the provider. Do you run the provider-level check on a schedule, or trigger it off registry changes?
I'd use both, but for different reasons. Triggering it on registry changes catches problems immediately, while scheduled checks catch changes made directly at the provider that never went through a PR. Relying on either one alone leaves a gap. Ideally, a detected mismatch should create an actionable alert with an owner rather than just show up as another monitoring metric.
Both is the honest answer — change-triggered for immediacy, scheduled for the drift that bypasses PRs entirely. The alert-with-an-owner line is the whole point: a mismatch as a metric is just the dashboard nobody opens, again with extra steps. How do you decide who owns the alert — the registry owner, or whoever last touched the provider side?
I'd make the registry owner accountable by default, since they're responsible for the declared authority and its boundaries. But I'd include whoever manages the provider credentials as a required participant when the drift is on their side. Otherwise you end up with two teams assuming the other one will fix it. One owner for driving resolution, both involved in understanding the mismatch.
The one-owner-driving, both-involved split is the right shape — accountability has to sit in one place or it diffuses across both teams, and the credential manager's participation keeps the fix from being a registry-side guess about a credential-side cause. The failure mode I'd still watch is the drift that isn't cleanly on either side — a scope the provider changed and the registry never re-declared. Who owns that one?
I'd still put the registry owner on the hook for closing the mismatch, even if neither side initiated it. They may need the provider team to investigate why the scope changed, but the declared authority is their responsibility. Until it's reconciled, I'd treat the broader permission as real and either restrict it or escalate it, rather than leave it sitting in an ownership gap.
Putting the registry owner on the hook even when neither side initiated the change is the right call — an ownership gap is where over-broad permissions go to live forever. Treating the broader permission as real until reconciled, rather than assumed harmless, is the safer default. The part I'm still curious about is detection: does anything snapshot the effective scope over time, or does a scope that crept up three PRs ago only surface when someone happens to look?
I'd snapshot the effective scope and keep a history of it, rather than rely on someone spotting it during a review. Comparing snapshots over time would show when a permission first appeared and how it changed, even if it happened outside the PR process. The scheduled provider check should compare against both the registry and the previous snapshot, so neither undeclared scope nor gradual expansion gets missed.
Snapshotting the effective scope is the piece I was missing — a review-time diff can only catch what passes through a PR, and drift by definition doesn't. Comparing against both the registry and the previous snapshot closes the two gaps at once. Do you keep those snapshots in the repo alongside the registry, or in a separate audit store?
The line that carries the piece for me is the question-4 test: if the approval answer lives only in the prompt, you don't have an approval step, you have a polite request for one. The update_order_status case is the same failure in the other direction — the contract said 'row write,' the tool shipped a refund button, and review can only catch what the contract declares. We learned the adjacent lesson pricing our own MCP server's third tool: we wrote all three candidate schemas and measured them before adding any, because once a tool is in the registry its cost and reach stop being reviewed at all. On your CI check — when a tool's action class or approval flag changes without the label, does the check block the merge outright, or route it to a named reviewer who has to apply the label themselves?
I'd make it block the merge outright for authority changes. A named reviewer should then be able to approve the change explicitly, ideally with a short justification. Otherwise the label risks becoming just another checkbox people add to get CI green. The whole point is to make authority changes deliberate, not just visible.
Block outright is the only version of that check I'd trust — a label is a request for attention, and attention is exactly what runs out. Our release gate works the same way: a failed check doesn't get a warning colour, it stops the publish, and the override has to be a deliberate act by a named person. The justification is the part that decides whether the block stays real six months in, though: a justification nobody ever re-reads becomes the checkbox in sentence form. Does the reviewer's justification stay attached to the tool's registry entry afterwards, so the next authority change on that same tool shows the last one and its reason?
That's a good point. I'd definitely keep the justification attached to the registry entry, ideally with the reviewer, timestamp, previous authority and the reason for the change. That way the next reviewer has context instead of starting from scratch. It also makes recurring permission expansions easier to spot. Otherwise we're just documenting individual approvals without ever seeing the bigger pattern.
The four fields are the right record — reviewer, timestamp, previous authority, and the reason — because the previous-authority field is what turns a pile of approvals into a diff a reviewer can actually read. The recurring-expansion point is the one we'd underline: on our release gate, no single check looks alarming on its own either; it's the history attached to the seal that shows whether a step has quietly grown. Do you review those expansions in aggregate on a schedule, or only one change at a time as each PR comes in?
I'd do both. Every PR needs its own review because that's where the immediate context and justification live. But I'd also periodically review the history in aggregate to spot patterns that aren't obvious when looking at individual changes. Several small expansions across different tools can add up to a much bigger shift in overall authority. That's the kind of thing a per-PR review can easily miss.
Both is the answer the justification record was built for — per-PR review carries the context, and the aggregate read is the only place "several small expansions adding up to a much bigger shift" becomes visible. One expansion at a time always looks reasonable; the pattern is the finding. That's the same reason we read a release back on the surface rather than trusting each step's success message: the individual steps can all be honest and the total still not be what anyone approved. Is your aggregate review on a schedule, or triggered after a set number of expansions lands?
I'd start with a scheduled review, probably quarterly, and add a trigger when a tool crosses a defined authority threshold. A fixed number of expansions can be misleading: one change might be much riskier than several small ones. The review should look at cumulative scope and actual provider permissions, not just count approvals.
Cumulative scope over count is the part I'd underline — that's exactly the failure a count-based trigger invites, where nine harmless expansions hide the one that quietly turned a read into a write. On our side the justification record we keep per expansion is what makes a cumulative review possible at all: without the stated reason attached to each step, a quarterly look-back is just a list of diffs with no way to tell drift from intent. The threshold trigger is the piece we don't have, and yours sounds right. How are you defining the authority threshold itself — as a permission-class crossing (read to write, internal to external), or as some cumulative score across the expansions since the last review?
I'd make permission-class crossings the hard triggers, especially read to write, internal to external, or any move to admin-level access. A cumulative score can help flag gradual expansion within a class, but it shouldn't be able to average away a high-risk permission. I'd use both: explicit gates for major changes and an aggregate score to decide when smaller changes deserve another look.
Both, with the score unable to average away a class crossing — that's the version I'd trust, and it's cleaner than what we have. The per-expansion justification record we keep is what would make your score auditable rather than vibes: each step carries its stated reason, so an aggregate review can tell drift from intent instead of just counting diffs. One mechanics question: after a class-crossing review fires and clears, does your cumulative score reset to zero, or does it keep accumulating across reviews? Ours would keep the history either way, but the trigger threshold has to pick one.
This framing landed for me because I coordinate a team of agents in production, and the failure mode that actually bit us was #3, identity drift. No single credential change looked alarming in review, but over a few months a read-scoped token had quietly grown into something that could trigger external actions. What I do differently now: every tool addition has to declare its action class, identity, and approval requirement in the same PR, and a change to any of those three needs a named reviewer from security, not just the feature owner. One thing I would add to your four questions is a fifth: what happens when this tool is called twice, or retried after a partial failure? The first call may be safe, but the retry is where side effects like duplicate tickets or double refunds show up. The CI check you propose is the part I would steal first, but I would pair it with a runtime test that calls each tool with out-of-scope arguments. The diff catches declared changes; the test catches the drift nobody declared.
That's a really good addition. Retry behavior is easy to overlook because we tend to review what a tool does on a successful call, not what happens when execution gets interrupted halfway through. I'd add idempotency and retry safety to the tool contract, especially for anything with external side effects. A duplicate refund or webhook is still an authority problem, just a different kind of failure.
Agreed, and framing it as part of the tool contract is the right move. In practice, the check that catches this is simulating the retry itself: interrupt the call after the side effect but before the response, then call again and see whether anything duplicates. An idempotency key at the tool boundary helps, but only if the registry records which tools actually honor it, otherwise the contract is just a promise. The approval angle matters too: a retry should not silently re-run an approved action with different arguments, so the approval probably needs to cover the exact call, not just the tool.
One thing
requires_approval=Trueneeds to spell out: what it does when nobody is there to approve. In my setup, scheduled jobs and voice requests go through a one-shot path where interactive approval is inert. The question can be asked, but nobody can answer it, so any protection on that path has to refuse in code. A related trap: sub-agents I start by delegation run without my system prompt and without my skills, so a "wait for approval" step placed after a delegation is never reached. If the flag's runtime meaning is "ask", it means nothing on unattended paths. It should mean "refuse unless someone actually approved".Agreed. I'd define
requires_approval=Trueas a hard runtime condition, not an instruction to ask someone. If there's no approval channel or nobody available to approve, the call should fail closed. Otherwise scheduled jobs and delegated agents create exactly the bypass you're describing. Approval needs to be enforced at the execution boundary, regardless of which surface invoked the tool.Ran into this exact issue in my self-hosted app store. AI actions there can come from a chat window, a voice companion, or another agent, and only the chat window can show an Allow/Decline card. So the other paths fail closed: the call doesn't run, and the model is told to ask again in the chat, where a person can answer. Silence never counts as a yes.
On question 1, the label the server ships is the weakest evidence you have. In GitHub's MCP server,
update_issue_labelswas marked non-destructive but replaced the issue's labels instead of adding to them. In the Kubernetes server,vm_clonewas marked idempotent though every call made a new clone. Both were found by calling the tools against throwaway data, not by reading them. For the CI check, I'd fail the build on the direction that matters: an annotation change that lets a client run a tool with less confirmation (readOnlyHint turning true, destructiveHint turning false). mcp-check's--comparedoes exactly that, if you want one off the shelf (I wrote it).That's a great example of why testing the actual behavior matters more than trusting annotations. A tool can look harmless in the schema and still have surprising semantics in practice. I also like the idea of failing on changes that reduce confirmation requirements rather than treating every annotation change equally. I'll check out mcp-check, thanks for sharing it.
One authority class I'd add to the four questions: does the tool execute code it did not ship with?
A tool called "install dependencies" or "open the project" reads like plumbing, but npm install runs lifecycle scripts from every package in the tree, and the repo itself can change what runs: a project .npmrc, or initializeCommand in devcontainer.json, which runs on the host before the container starts. In review I'd treat those like run_sql: arbitrary execution, limited only by the credential and network the process has.
Absolutely. That's a good distinction because the tool name can hide a lot of execution behavior. I'd classify tools based on what they actually trigger, including scripts and hooks loaded from the project, not just the top-level operation. If
npm installcan execute arbitrary package scripts with the agent's credentials and network access, it belongs much closer to execute than read.This is why "install app" in my self-hosted app store is admin-only. A one-click install is a git clone plus the app's own install scripts, so it's execute, not plumbing. Agents can use an installed app's tools, but only a person with the admin token can install one.
The CI check is the part I would steal first. A permission change that fails the build gets treated like a real endpoint change.
Exactly. And I'd go a step further and make the check specific to the kind of permission being changed. Changing a read scope is not the same as introducing an external action or granting admin access. They shouldn't all go through the same review path.
read scope versus admin is the split i'd want in the check. one rule for both is how the noisy reviews start.
Exactly. If every permission change triggers the same level of review, people eventually start treating all of them as routine. The review should scale with the authority being added. A read-scope expansion is one thing; granting admin access or introducing an external side effect should be a much harder gate.
review scaling with authority is the right shape. a read-scope bump and an admin grant should never cost the same review.
Exactly. And I'd make that distinction explicit in the policy rather than leave it to reviewers to interpret every time. Once the risk tiers are defined, CI can route changes consistently and reserve the heavier review process for changes that actually expand the blast radius.
Writing the tiers into the policy is the move. Reviewers interpret, CI routes.
Right, that separation also makes the policy easier to maintain. CI can enforce the defined thresholds, while reviewers focus on whether the change has been classified correctly and whether the justification holds up. Otherwise the policy just becomes another checklist people click through.
Really important perspective! One thing I'd add is that a tool's description and its actual permissions should never be treated as the same thing. Even if an agent is instructed to access only a specific customer's data, the backend should independently enforce that scope rather than trusting the arguments supplied by the model.
I'd also make authorization checks part of the execution layer, so even a perfectly valid tool call can be rejected when the user or agent doesn't have the required permissions.
This is especially important as AI agents move from answering questions to performing real business actions. How do you think teams can make these permission boundaries easier to test automatically?
I'd make the boundaries testable with negative cases, not just successful calls. For example, run the same tool with another customer's ID, a broader-than-authorized query, or a user lacking the required permission, and assert that the backend rejects it without returning data or causing side effects. Those tests should run in CI against the execution layer, not just validate the tool schema.
Treating an AI agent's tool registry as an API rather than simple configuration is an important distinction. Tool contracts, input validation, versioning, and access control all become critical when agents interact with real business systems.
As AI agents become more capable, the reliability of their tools will be just as important as the intelligence of the models behind them.
Agreed that the tool contract matters independently of the model. I’d put particular emphasis on input validation and authorization at execution time. A well-described tool with weak enforcement is still a weak boundary.
Your four questions do something most agent reviews skip: they treat "send an email" and "search the docs" as different risk classes before anyone asks how clever the model is. The point raised in the comments about authority drifting at the provider, outside any PR, is the part I would underline. A declared scope is only a claim until something compares it with what the token can actually do.
We drew a similar line when Ascendra Ventures built AML SoftServe for Australian firms that became regulated under the Tranche 2 rules. Customer due diligence, KYC and KYB checks, risk assessment and ongoing monitoring run as guided workflows in the browser. The action with consequences outside the system, a suspicious-matter report to AUSTRAC, is drafted by AI for a human to review rather than sent on its own. The checks could be guided; the external trigger kept a person in front of it.
Do you label the "trigger external" class in the registry itself, so a reviewer can see at a glance that a new tool reaches outside the system?
Yes, I'd flag it explicitly, though the label alone isn't enough. A tool that sends data externally should also declare the destination and whether it can execute without human approval. That gives reviewers something concrete to check against the actual provider permissions, rather than relying on the registry description being accurate.