Download this article as a PDF
When an agent fails, the instinct is to wait for a better model. Usually that is the wrong fix. The model is probabilistic by design. It reasons well because it is not a rulebook, and for the same reason it will not do the same thing every time. So the best practices for AI agents don’t just polish the model. They wrap it in a harness: the code around the model that decides what it can touch, checks what it produces, and records what it did. A good harness pays off twice: a more reliable agent and a safer one, from the same work.
- Build the harness before you buy a better model. Failures stack up. If each step in a ten-step job succeeds 95 percent of the time, the odds that all ten succeed in a row are only about 60 percent. At 90 percent a step, it is about one in three. A model upgrade does not fix that. The harness does. Checkpoints let a failed step resume instead of restarting; bounded retries recover from a bad step without looping forever. One coding agent climbed from about 53 to 66 on a standard benchmark by changing only the harness, not the model.
- Put the rules in code, not in the prompt. A rule in the prompt is a suggestion the model may or may not follow. A rule in the harness is a constraint. When an action must always happen a certain way, hand it to deterministic code: the model decides what to do, the code does it the same way every time. Check the model’s output against a fixed format before anything acts on it, and put approvals, spending limits and the kill switch in code, where a wrong answer cannot override them. The agent does the right thing every run, and it cannot reach what it should not.
- Give the agent less: fewer tools, less context, a narrower job. In one benchmark, a model handed every available tool description picked the right tool about 14 percent of the time. Retrieving only the relevant tools first raised that to about 43 percent. Context works the same way, so clear the context window on a schedule and keep each agent on one narrow job. The security payoff comes with it: an agent with few tools and least privilege has a small blast radius when it gets something wrong.
- Design as if the capability rating is wrong. In July, two frontier models in a cyber benchmark went after the answer key on Hugging Face’s servers instead, and reached a real production database before they were caught. The lab that built them did not expect it. So build the harness as if the rating is wrong: an owner and an identity for every agent, no standing credentials, no reach beyond the task, and a kill switch somebody has tested. When clients ask me about agent gateways, I tell them a gateway is one layer. Containment and policy still have to live behind it.
- Break what you couldn’t lock down. Some of what you want from an agent, like judging which of two reasonable answers is better, cannot be written as a rule for code to check. For the rest, you earn trust by trying to break the agent on purpose: run it under load, feed it odd inputs, try to make it step outside its scope. Find the step that fails and the door that opens in testing, before a customer or an attacker finds them in production.
Key points
- A rule in the prompt is a suggestion. A rule in the harness is a constraint.
- Fewer tools, less context and a narrower job make an agent more accurate and safer at the same time.
- The harness you build for reliability is the same place you govern the agent.
- Ask before the next model upgrade: if the model got it wrong, what in the harness would stop it?
Sources: Temporal: AI reliability is a decade-old problem; rmax.ai: Harness engineering is the primary lever for agent reliability; arXiv: RAG-MCP, mitigating prompt bloat in LLM tool selection; Microsoft Security: Four priorities for AI-powered identity and network access security in 2026; Fortune: OpenAI says AI models escaped control, hacked Hugging Face.
RationalAI helps organizations turn ideas like this into results: AI strategy and advisory services. Previous article: Jon Stone Will Be Teaching Healthcare Cyber Risk at UT Austin This Fall


