Zero Trust for AI Agents: The Architecture Work Before Autonomy
AI coding agents can speed up delivery, but production teams need bounded permissions, short-lived credentials, policy gates, sandboxing and audit logs before giving agents real access.
Kyluke McDougall
Software Architect & Founder
Table of Contents
- Why this is hot now
- Why this matters to product teams
- Least agency beats blind autonomy
- Bounded tools matter more than clever prompts
- Short-lived credentials should be the default
- Policy gates should sit in the workflow
- Sandboxing is not optional
- Auditability is part of the product architecture
- Evals and harness reliability are security controls
- A practical rollout plan
- 1. Start with read-only repository work
- 2. Move to branch-limited implementation
- 3. Add bounded tools
- 4. Introduce short-lived credentials
- 5. Add policy gates for sensitive areas
- 6. Build harness evals
- 7. Keep an audit trail by default
- The recommendation
AI coding agents are moving into the parts of software delivery that used to be reserved for trusted humans.
They read repositories. They edit files. They run tests. They open pull requests. They inspect logs. They call tools. Some teams are already experimenting with agents that touch CI, cloud environments, databases and deployment workflows.
That is useful.
It is also the point where the old question, “Is the model good enough?”, becomes too small.
For production teams, the better question is: what can this agent do when it is wrong, confused or overconfident?
That is why Zero Trust is the right framing for AI agents. Not because every agent is malicious. Because no production system should depend on perfect judgement from a tool that can act faster than a reviewer can read.
Why this is hot now
The current discussion around AI agents has become more practical.
Anthropic’s Zero Trust guidance for AI agents puts the security conversation into language executives and engineering leaders already understand: least privilege, explicit trust boundaries, compartmentalisation, monitoring and policy enforcement.
At the same time, the tooling market is pushing toward more capable agents. GitHub is turning one-off prompts into custom agents and repeatable workflows in Copilot CLI. Teams want agents that can do real work, not just suggest snippets.
There is also a reliability thread running underneath the security conversation. Armin Ronacher’s “Better Models: Worse Tools” post called out a problem many builders recognise: tool calling and schema discipline can regress even when the model feels smarter in normal chat. Simon Willison amplified the same point. If tool calls become less predictable, the surrounding harness matters more, not less.
Add reports of companies restricting specific coding agents over trust concerns, and the pattern is clear: autonomy is arriving before most teams have the operating model for it.
Why this matters to product teams
For founders, CTOs and Mittelstand teams, this is not a niche security topic.
An agent with repository access can change business logic. An agent with CI access can influence what ships. An agent with cloud credentials can alter infrastructure. An agent with database credentials can change product state. An agent with access to internal documentation can leak sensitive context into places it should not go.
The risk is not only “bad code”.
The risk is uncontrolled agency.
A human developer makes mistakes too. The difference is that an agent can chain actions quickly: inspect a failure, infer a cause, run a command, read the output, change files, run another command and continue. That loop is exactly why agents are powerful. It is also why teams need boundaries before they connect agents to real systems.
Good agent security is not a prompt. It is architecture.
Least agency beats blind autonomy
Least privilege is the familiar security principle: give a user only the permissions they need.
For agents, the stronger version is least agency.
An agent should not only have limited access. It should have limited ability to act. A research task does not need write access to the repository. A code-editing task does not need production secrets. A test-writing task does not need deployment rights. A migration-drafting task does not need permission to apply the migration against production.
This sounds obvious until convenience enters the workflow.
The fastest setup is usually to give the agent a developer shell, the repository, environment variables and enough credentials to make the task work. That may be fine for a disposable prototype. It is not a production operating model.
For serious teams, agent modes should be explicit:
- read-only analysis;
- branch-limited code editing;
- test execution in a sandbox;
- pull request preparation;
- production-adjacent diagnostics;
- deployment or remediation with human approval.
Each mode should have different permissions, not just different wording in the prompt.
Bounded tools matter more than clever prompts
Most agent failures become dangerous through tools.
The model can think something wrong. That is annoying. The tool call is what turns the mistake into a file change, a deleted resource, a leaked secret or a failed deployment.
Tool design therefore becomes part of the security architecture.
A good tool surface should be narrow, typed and difficult to misuse. It should expose the operation the team actually wants, not a raw escape hatch to everything. “Create a preview database branch” is safer than “run any database command”. “Open a pull request” is safer than “push directly to develop”. “Read production logs for this service and time range” is safer than “use cloud admin credentials”.
Tool schemas also need discipline. If a model calls tools with weak arguments, ambiguous IDs or malformed payloads, the harness should reject the call. It should not quietly guess.
That is the practical lesson from the recent tool-calling reliability debate. Better language ability does not remove the need for strict tool contracts. It increases the value of them.
Short-lived credentials should be the default
Long-lived credentials are already risky with humans. With agents, they are worse.
Agents work through prompts, context windows, tool traces, local files, CI logs and sometimes third-party orchestration layers. A static token that can deploy, read production data or mutate cloud resources should not be casually available in that environment.
The better pattern is temporary access:
- task-scoped tokens;
- short expiry windows;
- narrowly defined roles;
- environment-specific credentials;
- automatic revocation when the task finishes;
- no production secrets in normal development contexts.
This does not need to slow teams down. In a mature setup, requesting a scoped token should be easier than copy-pasting a permanent one.
If the agent cannot complete a task without broad credentials, that is usually a design smell. The workflow needs a narrower tool, a safer environment or a human approval step.
Policy gates should sit in the workflow
Prompts are helpful, but they are not enough.
A prompt can say “never deploy without approval”. A CI policy can enforce it. A prompt can say “do not edit infrastructure files”. A repository rule can require review from the platform owner. A prompt can say “avoid destructive commands”. A shell wrapper can block them unless a human explicitly unlocks the task.
Policy gates should cover the moments where agent work becomes business risk:
- changing infrastructure-as-code;
- modifying authentication or authorization logic;
- touching payment, billing or customer data flows;
- adding dependencies;
- running migrations;
- changing CI or deployment configuration;
- accessing production logs or secrets;
- merging or deploying.
The point is not to make agents useless. The point is to make risky work visible at the right moment.
Sandboxing is not optional
Every agent needs somewhere safe to be wrong.
For coding work, that means isolated branches, disposable worktrees, containers, preview environments, seeded test databases and cloud sandboxes. The agent should be able to run tests, inspect failures and iterate without carrying production-level risk.
This is especially important because agents learn through action. A good agent workflow often involves running commands, reading errors and adjusting the implementation. If the environment is safe, that loop is productive. If the environment is connected to real systems, the same loop becomes dangerous.
Sandboxing should include the file system, network access, credentials, environment variables and external tools. A sandbox that still contains production secrets is not a sandbox. It is a production credential with better branding.
Auditability is part of the product architecture
When an agent changes something, the team should be able to reconstruct what happened.
That means keeping records of:
- the task or ticket that started the work;
- the agent and model used;
- the tools the agent called;
- the commands that ran;
- the files that changed;
- the credentials or roles granted;
- the tests and checks executed;
- the reviewer and approval path;
- the deployment or rollback action.
This information should not live only in a chat transcript. It belongs in pull requests, CI logs, deployment records, tickets and security logs.
Auditability is not bureaucracy. It is how a team debugs decisions.
If a production issue appears three weeks later, “the agent did it” is not an explanation. The team needs to know which assumption changed, which control passed, which check failed and how the system can be repaired.
Evals and harness reliability are security controls
Agent security is not only about access control.
It is also about whether the agent follows the harness correctly.
Can it call tools with valid arguments? Does it respect the allowed action set? Does it stop when a policy gate returns “needs approval”? Does it handle tool errors without inventing success? Does it confuse staging and production identifiers? Does it keep operating after a destructive command is blocked?
These behaviours should be tested.
Teams evaluating agent workflows should run small, realistic harness evals before giving agents broader access. Include cases where tools fail, schemas reject calls, permissions are missing, logs are ambiguous and the safest answer is to stop.
This is where many AI adoption plans are still too shallow. They test whether the agent can complete a happy-path coding task. They do not test whether it behaves safely when the environment pushes back.
A practical rollout plan
Most teams do not need a giant governance programme before using AI coding agents.
They do need a staged rollout.
1. Start with read-only repository work
Let agents explain code, map dependencies, identify risk areas, draft refactoring plans and write implementation notes. No write access. No secrets. No external systems.
This builds familiarity without giving the agent a blast radius.
2. Move to branch-limited implementation
Allow agents to edit code only in isolated branches or worktrees. They can run local tests and prepare pull requests, but they cannot merge, deploy or change protected configuration.
The pull request remains the control surface.
3. Add bounded tools
Replace broad shell or cloud access with task-specific tools. Prefer typed operations with validation over raw command execution. Make dangerous operations impossible or approval-gated.
The agent should work through a harness, not around it.
4. Introduce short-lived credentials
If the agent needs access to external systems, issue credentials for that task, environment and time window. Log the grant. Revoke it automatically.
Default-deny is easier to trust than default-admin.
5. Add policy gates for sensitive areas
Require explicit approval for infrastructure, auth, payments, migrations, production data, CI configuration and deployment. Make those gates enforceable in repository rules, CI, wrappers or platform policy.
The model can request access. The system decides whether it gets it.
6. Build harness evals
Test unsafe and messy scenarios, not only success paths. Verify that the agent stops, escalates or asks for approval when the harness says no.
This turns “we think it is safe” into evidence.
7. Keep an audit trail by default
Make every meaningful agent action traceable. Store enough context that a future engineer can understand what happened without reading a private chat history.
Good logs make agent work reviewable, operable and reversible.
The recommendation
AI agents should not be banned from serious software work.
They should be treated like a new class of production actor.
That means no blanket trust, no permanent broad credentials, no raw access where a bounded tool would do, no silent production adjacency and no autonomy without logs.
The winning teams will not be the ones that give agents the most freedom first. They will be the teams that make agents useful inside clear operating boundaries.
Use the speed.
Architect the trust.