Safeguard
AI Security•

How do you right size AI agent permissions from usage logs?

Compare what an AI agent is granted with what it actually called over 30 to 90 days, then cut the difference. A step by step method and its limits.

Safeguard Security Team
3 min read

Pull the agent's tool call log for a fixed window, list which granted tools it never used, and remove or time box those. Then narrow the scopes of the tools it did use to the ranges it actually touched. Review the result with the owner before you apply it.

The idea

Permissions are usually granted from guesses at the start of a project. Logs show behavior. The gap between the two is unused authority, which is risk with no benefit. Cloud providers do this for human and service roles already. AWS describes IAM Access Analyzer reviewing CloudTrail logs and generating a policy template containing the permissions an entity used in a date range of up to 90 days, which you then review and refine.

You can apply the same approach to agent tool grants, even without a cloud feature, using your own tool call logs.

What the log must contain

FieldUse
Agent identityGroup calls per agent
Tool name and serverCompare with the manifest
Arguments summarySee scope actually used, such as which queue or folder
Result and errorsFind denied or failing calls
Timestamp and task IDSpot seasonal tasks

Steps

  1. Choose a window that covers a full work cycle. Thirty days misses a quarterly job, so check the calendar.
  2. List granted tools and count calls per tool in the window.
  3. Mark zero call tools as removal candidates. Ask the owner whether any belongs to a rare but real task.
  4. For used tools, look at argument ranges. If a file tool only ever read one folder, scope it to that folder.
  5. Apply changes in a lower environment first, then production.
  6. Watch for new denied calls for two weeks and keep a fast way to restore a grant.

Limits to know

Logs only show what happened, not what is needed. AWS notes its own tool does not capture action level detail for data events and says not to use policy generation for auditing, to use CloudTrail instead. The lesson carries over: a usage derived list is a starting point for review, and your audit log stays the source of truth.

Also remember that a prompt injected into an agent can make it call tools it never normally uses. Silence in the logs means the tool is unneeded or attackers have not tried yet. Both are reasons to remove it.

Make it routine

Repeat the exercise at each access review. Agents change as their prompts and tools change, so last quarter's right size becomes this quarter's drift.

Safeguard offers MCP Guardrail and agent identity for applying this kind of policy to agent tool calls, and you can run a free scan of your own repositories at gold.safeguard.sh/scan. Autonomous fix pull requests are off by default, and every category starts on Manual.

Quick check

How long a log window should I use?

Cover at least one full work cycle. For monthly or quarterly jobs, use 90 days or ask the owner about rare tasks.

Is it safe to remove a tool with zero calls?

Usually, after checking with the owner for rare tasks and keeping a quick way to restore it.

Sources

Last reviewed: 19 October 2026.

Never miss an update

Weekly insights on software supply chain security, delivered to your inbox.

Self-healing security runs on Safeguard.

Your first fix PR is minutes away.

No sales call required, even your agent can complete the purchase over MCP.