All posts

"Guardrails for agents that touch real systems"

Once an agent can act on production systems, the interesting question is no longer whether it will make a mistake, it will, but how far that mistake can travel. Scoped credentials, dry-run modes, action logs and spend ceilings are the four guardrails I refuse to ship without.

Agents5 min read3 September 2026by Ahmed
"Guardrails for agents that touch real systems"

The first time an agent does something wrong in a real system, you discover what your architecture actually was. Not the diagram, the reality. Did the mistake touch one record or a thousand? Was it caught in minutes or discovered in a month-end report? Could you reconstruct what happened, or are you reading tea leaves in application logs? Every one of those answers was decided before the incident, by guardrails you either built or did not. Agents will make mistakes; that is a property of the technology, not a bug you can fix. The engineering question is how far a mistake can travel before something stops it.

The first guardrail is scoped credentials, and it does the most work. An agent should authenticate as itself, its own service account, its own API keys, its own database role, never as you, and never with a credential shared across agents. The scope should be embarrassing in its narrowness: the tables it needs, the mailbox it needs, the one S3 bucket, read-only wherever read-only is enough. This is ordinary least-privilege thinking, but it matters more with agents because the caller is creative, OWASP's LLM Top 10 lists the failure it prevents as excessive agency, and it earned that place. A human with over-broad access mostly does not wander; a model given a working credential will cheerfully use every capability it grants if some chain of reasoning suggests it. The credential is the hard boundary that reasoning cannot argue its way past. Per-agent identity also buys you attribution for free: when something odd happens, you know which agent, which token, which scope.

The second is a dry-run mode, built in from day one rather than bolted on after a scare. Every action tool in my systems takes an execute flag; without it, the tool does everything except the side effect, validates the arguments, resolves the records, computes the change, and returns what it would have done. This gives you three things. A safe way to test the whole loop against production data without production consequences. A staging life for every new agent, where it runs for days in dry-run while you read its intentions. And a permanent diagnostic: when behaviour looks wrong, flip the flag off and watch what the agent wants to do, at zero risk. The systems I run for my own business operations all started life in dry-run, and several earned real execution rights only after weeks of proposing sensible actions.

"Guardrails for agents that touch real systems"

The third is an action log, append-only, structured, and separate from application logging. Every tool call an agent makes gets recorded: timestamp, agent identity, tool name, full arguments, the result, and which run it belonged to. Not a paraphrase, the verbatim call. This is the difference between "the agent did something to the CRM last Tuesday" and being able to replay exactly what happened and in what order. It is also, quietly, your compliance story, your debugging corpus, and the dataset you will later mine to decide which actions deserve automation and which need a human gate. Tracing tools such as Langfuse help with the model-side view, but the action log is about side effects, and I want it in my own store, under my own retention rules.

The fourth is ceilings, on spend, on volume, on rate. A per-run token budget, so a looping agent burns pennies rather than hundreds of pounds. A daily cap per agent on external actions: emails sent, records modified, API calls made. Rate limits that assume the agent might try to do a month of work in an hour, because occasionally one will decide that is a good idea. Ceilings are crude, and that is their virtue: they bind regardless of how plausible the agent's reasoning was. The model can be convinced of almost anything; the counter cannot.

None of these guardrails involves the model at all, which is rather the point. Prompting an agent to be careful is worth doing, but it is a request, not a control. The controls live in code and infrastructure, where injected text and confident hallucinations cannot reach them. My rule of thumb: anything you would genuinely mind happening must be prevented by something other than the prompt.

There is a temptation to see all this as overhead that slows the project down, and I want to push back on that honestly. The guardrails are what let you move fast later. With scoped credentials, dry-run, logs and ceilings in place, you can grant an agent a new capability on a Tuesday afternoon and sleep that night, because you know the failure is bounded, visible and reversible. Without them, every expansion of the agent's powers is a leap of faith, and teams either stall in permanent pilot mode or ship something they secretly fear. This matters double for smaller organisations: if there is no security team on call, the guardrails are the security team, and the four above are well within reach of one careful engineer.

Building this layer, the credentials, the dry-run plumbing, the action log, the ceilings, is a large part of the work I do when I take agent systems to production. If you have an agent that works in the demo and a production environment you care about, get in touch via the contact form.

Senior engineering roles — or production AI consulting?

I'm open to senior AI and software engineering roles and to selective consulting on agents, RAG, and LLM automation in production. If this post resonates — as a hiring manager or as someone shipping similar work — get in touch.

Get in touch

© 2026 Ahmed Fareed. All rights reserved.

LOADING