How to Control What Your AI Agent Can Spend, Send and Access
From the publisher’s feed, collected in the ZeroLabs newsroom.
An org chart for agents, in about 550 lines of Python and no dependencies.This weekend I ran a small script over my own Claude Code history. It reads the session logs the tool saves on your machine and lists the calls worth a second look.It found 17. Pushes to main, a few rm -rf, one DROP TABLE. Most were my own cleanup and tests, nothing sinister.What bothered me was a different number. Sixteen of the seventeen ran without me clicking yes. An allow rule or auto mode had approved them, some time ago, and I had forgotten it was there.I had a policy for my agent. I just couldn’t tell you what it was.Who decides?Coding agents are the easy case. Someone sits at a terminal and watches.Now take an agent that issues refunds, sends email to customers, or calls a paid API. Nobody is watching. Three questions come up quickly:How much can it spend, in one action and in one day?Who can it write to?What can it touch?In many setups the answers live in three places: a line in the prompt, a number hard-coded in a tool, and somebody’s memory. There is no single place to look, and nobody who can change it without a deploy.Companies already treat people this way. A new hire gets a spending limit, a manager who approves the big things, and access to the systems they need. Nobody puts “please don’t spend too much” in their onboarding doc and hopes.So I tried the same idea for software: an org chart for agents.The shapeAgents sit in a tree. An organisation has teams, and teams have agents:acme $500/day never: delete anything, email competitor.com├── support $300/day may email: acme.com, gmail.com│ ├── refund-bot $100/day max $50 per action, a person approves over $20│ └── triage-bot may only read and label tickets└── finance $200/day └── invoice-bot max $150 per action, a person approves over $100You can set limits on any node, and there are three kinds: what it can spend, who it can send to, and what it can access. In the file, the refund bot looks like this:{"id": "refund-bot", "type": "agent", "parent": "support", "limits": { "spend": {"per_action_usd": 50, "approval_over_usd": 20, "daily_usd": 100}, "send": {"max_per_day": 40}, "access": {"allow": ["crm:read", "payments:refund", "tickets:*"]}}}Two rules do most of the work.A child can only be stricter than its parents. The refund bot can’t be given more than the support team, and support can’t have more than the company. Every node on the path has to agree.Budgets are shared. The finance team has $200 a day, and that counts everything its agents spend, not each agent on its own. Here is what the invoice bot did in my demo:ALLOW invoice-bot spend $90 $90 is within every budget on the pathALLOW invoice-bot spend $90 $90 is within every budget on the pathDENY invoice-bot spend $90 finance daily budget: $180 spent of $200, this $90 would go overEach request is under the bot’s own $150 limit. The third one still fails, because the team ran out. The reason is in plain words, with the rule that decided it, so the person reading the log doesn’t need the code.Asking before actingBefore the agent does something, it asks. The request follows the shape of the OpenID AuthZEN access-evaluation API (a subject, an action, a resource), so it works from any language:curl -s localhost:8787/access/v1/evaluation -d '{ "subject": {"type": "agent", "id": "refund-bot"}, "action": {"name": "spend"}, "resource": {"type": "payment", "id": "pay_123", "properties": {"amount_usd": 35}}}'The answer is yes, no, or wait for a person:{"decision": false, "context": {"status": "needs_approval", "reason": "$35 is over the $20 approval threshold at refund-bot", "approval_id": "apr_..."}}A $35 refund is under the bot’s $50 cap but over its $20 comfort line. So the request waits in a queue, and a person sees it in a small control panel and clicks approve.The control panel: the org chart with live budget bars, an approvals queue, and a log of every decision.The part I care about most is what the approval covers. It is tied to that exact request: that agent, that payment, that amount. Approve “$35 to payment p2” and the agent still can’t spend $36, or touch p3. And it works once. Ask again and it goes back to waiting.That is deliberate. A standing yes is how I ended up with rules I’d forgotten about.Fail closedA few defaults, because the dangerous failures are the quiet ones:Deny always wins over allow.Nothing is allowed unless something grants it. No budget set means no spending. No allow list means no access.A malformed request, an unknown agent, or an internal error is a deny.If the agent can’t reach the policy server, the client denies. A broken guard that lets everything through is worse than no guard.Every decision is written to a log with the rule that decided it and the version of the policy at the time. When someone asks “why did the bot refuse that?”, the answer is one row.What this can’t doThis is the part I’d rather say plainly than have you find out later.It only works if the agent asks. What I built is a decision point, not a gateway. An agent that never calls it is not stopped. The real lock has to sit where the agent can’t skip it: in the tool server, the payment API, or a gateway in front of them. I tested that idea on coding agents in an earlier post, where a hook watching one tool was walked around through another. Same lesson here. The org chart tells the lock what to do. It is not the lock.Identity is only as good as your keys. Without a key set on an agent, anyone who can reach the server can claim to be that agent. Set keys for anything that matters.Spend is what the agent says it spent. The server trusts the amount. It does not check the bill.It’s a prototype. One process, SQLite, a panel that binds to localhost. Fine for trying out the idea, not for production.I also didn’t invent the space. Companies like Gravitee, Permit.io and Cerbos already sell serious versions of this, with real identity, Cedar or OPA policy engines and gateways in front. What I wanted was the small, readable version: one file of policy, one page of UI, something you can understand in an afternoon. The obvious next step is to put the same endpoint in front of those engines, rather than compete with them.So who is your agent’s manager?When a new person joins a team, you know who approves their spending. If you can’t say that about the agent you shipped last month, that is the gap. It isn’t a missing prompt. It is a missing owner, with a limit and a log.The code, the demo and the tests are in the ops-ai repo, in the agent-org folder. python demo.py plays through a day at the example company in a few seconds. If it's useful, a star helps other people find it.Code, demo and tests: https://github.com/tarunagarwal1981/ops-ai/tree/main/agent-orgHow to Control What Your AI Agent Can Spend, Send and Access was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.