2026-11-27

I put an enforce list on my AI agents. A shadow week found what I would have broken.

Before, any agent could call any tool and only the prompt said no. After, each agent run carries a name and key through gateway rules to only the tools it was granted. Rules have three modes: off, shadow, which logs would-be denies and blocks nothing, and enforce. A final note says to read the bad-identity rows, not just the denies, because the system own background calls had no key.

Any agent could call any tool. Adding per-agent rules was easy. Knowing which rules to write took a week of watching, and the biggest surprise was not an agent.

I run a few dozen AI agents, each with its own job. They reach outside services through one local gateway that exposes over a thousand tools from dozens of providers.

Before, any agent could call any tool. The only limit was which model backends an agent could use. Nothing controlled which tools it could reach. An agent built for one job could, in principle, use a tool meant for something else. What stopped it was its prompt, which is a polite request, not a control. I never saw it go wrong, but I had no way to know that.

The gateway now has per-agent allow rules: agent, provider, optionally a single tool, allow or deny. There are three modes. Off does no checks. Shadow logs what would be denied and blocks nothing. Enforce blocks it. Each agent run carries its name plus a key derived from a shared secret and that name, so an agent cannot pass as another one. When a call is refused, the app I use shows a switch under the reply, so I can grant it on the spot.

I could have gone straight to enforce and written the rules from memory. I would have been wrong. With this many agents, I do not know which ones quietly depend on what. So I ran shadow mode for a week and logged the decision every call would have gotten.

Thousands of calls would have been blocked, and almost all came from two callers. One agent doing repetitive work against a single service accounted for most of it. A coding agent made up much of the rest. Neither was misbehaving. They were real usage with no rule yet, so I granted what they actually used.

I did not revoke permissions that went unused. Many agents were idle that week, so “never called it” is weak evidence. That cleanup waits for more data.

The surprise was that the biggest key failures were not agents. They were the system’s own background calls: generating voice replies, and a fast classifier that runs before an agent does. Both ran under an agent’s name but carried no key. Under enforce, voice replies would have stopped working with no obvious error. I would have just had agents that went quiet. The fix was to make the system’s own calls identify as the system.

If you are doing this, four things:

  1. Run shadow mode before enforce. A week of real traffic beats a rule list written from memory.
  2. Read the bad-identity rows, not just the denies. Denies tell you about permissions. Bad identities tell you about your own plumbing.
  3. Do not revoke on thin evidence. Idle is not unused.
  4. Make granting cheap. A one-tap fix makes a wrong denial cost seconds.

Still open: short-lived helper sessions spawned by an agent have no rules of their own yet. They either inherit the parent’s or stay denied, and I have not decided which is right. Next step is switching to enforce once the identity fixes land.