Guardrails, hallucination and accuracy control
You will not stop a language model being wrong. You can decide in advance what happens when it is.
A hallucination is a fluent, plausible statement that is not true, and it is not a defect that gets patched out in the next release: recent work argues models produce them because training and evaluation reward a confident guess over an admission of uncertainty. Guardrails are the runtime controls placed around a model to bound what it can say and do, covering input, retrieval, output and action. Accuracy control in an enterprise is therefore a design problem rather than a model-selection problem, and the question that decides the architecture is not how often the system is wrong. It is what happens on the occasion that it is, who finds out, and how quickly.
This is our approach, not a programme we have already run.
We have built accuracy controls into delivered proofs of concept and we have never run a guardrail stack against live customer traffic. On a live engagement in the London insurance market we scored confidence from the provenance of each extracted field, combined with model certainty and an independent search-based cross-check, and routed records for human review on that basis. That is real and it is narrow: batch document work, internal users, no customer in the loop. We have not operated input and output rails on a customer-facing channel, the flagship agentic build is a regulated-estate proof of concept now being productionised, and where this guide describes a layered rail stack it is describing method rather than a system we have run.
The demand signal
The research has moved from treating hallucination as a mystery to treating it as an incentive problem, which is far more actionable. A 2025 paper argues that models hallucinate because the training and evaluation procedures reward guessing over acknowledging uncertainty, and that part of the fix is changing how existing benchmarks score an admission of not knowing rather than adding more hallucination tests. Independently, the OWASP risk list for language model applications now carries misinformation as its own entry, alongside prompt injection, excessive agency and system prompt leakage. Both point the same way: an organisation planning to eliminate wrong answers is planning for something that will not happen, and an organisation planning for them is doing engineering.
Why it stalls
5 failure modes we keep meeting
The programme is trying to eliminate hallucination rather than bound it
Every week spent hunting a model that does not make things up is a week not spent designing what happens when one does. The incentives that produce a confident guess sit in how models are trained and scored, so the mitigation available to you is architectural: constrain what the system can say, make it cite where each claim came from, give it a supported way to decline, and route by consequence. Programmes that treat this as a procurement question, solvable by the next model, are still having the same conversation two quarters later with a larger bill.
A guardrail product was bought and the policy it enforces was never written
Runtime rails are programmable by design: the published toolkits describe rails as a way of controlling output, keeping to a dialogue path, staying off certain topics, and they operate outside the model so they stay inspectable. That is the useful property and it is also the catch. Somebody has to write the rules, in your language, about your business, and a toolkit with no policy behind it is a dependency rather than a control. This is the single most common thing we would expect to find when asked to review an existing stack.
The only guardrail is the system prompt
Instructions in a prompt are advisory, and they sit in the same channel as the input trying to override them. Prompt injection is the first entry on the OWASP risk list and system prompt leakage is an entry of its own, which between them describe both halves of the problem: the instruction can be overridden and it can be read. A control that a paragraph of user text can talk its way past is not a control, and it is the one most often presented to a risk committee as though it were.
There is no way for the system to say that it does not know
If the only supported output is an answer, the system will produce an answer. Abstention has to be a first-class result with a route attached, a person, a fallback, or a plainly worded decline, or the accuracy target is being enforced by optimism. This is also why buying a model on a benchmark score can mislead: a benchmark that scores a guess and an admission of uncertainty identically rewards the behaviour you are trying to design out.
Red teaming happened once, before launch, run by the people who built it
The published work treats adversarial testing as a scaled, continuing activity: one study released a dataset of 38,961 red team attacks and reported that models trained with human feedback became harder to attack as they grew, which is a result you only obtain by doing it at volume and over time. An afternoon workshop the week before go-live is not that, and it is what most programmes have. It is also the activity most obviously compromised by being run by the team whose release depends on the outcome.
How we approach it
7 moves, in order
- 01
Write the accuracy contract first: never, escalate, tolerate
Three lists, agreed with the business owner and the second line before anything is built. What must never happen, which becomes a hard constraint enforced outside the model wherever possible. What must be escalated, which becomes the routing design and the resourcing question. What is merely undesirable, which becomes a metric rather than a gate. Almost every argument later in the build is settled by pointing at this document, and its absence is why those arguments do not end.
- 02
Prefer constraint to correction
A model required to return output matching a schema cannot invent a field. A model answering only from retrieved passages with a citation can be checked by the reader. A model with no tool for an action cannot take it. Each of those removes a class of failure, where an output filter only catches instances of one. Design out first, filter second, and treat the filter as the weaker control of the two.
- 03
Layer the rails, and know what each layer is actually for
Four places, four different jobs. Input: what may be asked, and what may be pasted in. Retrieval: what may be fetched, and whether the person asking is entitled to see it. Output: what may be said, in what shape, with what attribution. Action: what may be done, by whom, and with what confirmation. Programmable runtime rails of the kind the published toolkits describe sit outside the model and remain interpretable, which matters mainly because a risk function can read them and form its own view.
- 04
Make abstention first class, and measure it
Declining is an outcome the system is designed to produce, not a failure state. Measure how often it happens and split it in two: correct refusals, where the system genuinely could not answer safely, and wasteful refusals, where it could have. A system that never abstains is not safe, it is unmeasured, and the ratio between those two numbers is one of the more informative things you can put in front of an operations team.
- 05
Score confidence from provenance rather than from the model's own certainty
On our insurance engagement, confidence was derived from which third-party source a value came from, combined with model certainty and an independent search-based cross-check, rather than from the model's self-reported score alone. Provenance is what makes a routing decision explainable to the person who owns the outcome, and explainable routing is what allows a business to accept an accuracy figure it would otherwise reject.
- 06
Use a model as a judge, and know precisely where it lies to you
Model-graded evaluation is genuinely useful: the published work reports over 80% agreement with human preference, about the rate at which humans agree with each other. The same work names position, verbosity and self-enhancement biases, which is why we would use a judge for triage and regression detection and keep human judgement on the release gate. Two further habits worth adopting: check what happens when the judge and the system under test come from the same family, and keep a human-scored sample every cycle so you can tell when the judge itself has drifted.
- 07
Red team continuously, and not with the build team
A standing adversarial set that grows with every incident and near miss, refreshed on every model upgrade, and owned by someone who does not benefit from the release. That set is the cheapest insurance in the programme, because each entry is a failure you only pay for once. It also gives your risk function something concrete to inspect rather than a paragraph asserting that testing was thorough.
What is merely undesirable, which becomes a metric rather than a gate.
Write the accuracy contract before you shop for a guardrail product. Three lists: what must never happen, what must be escalated to a person, and what is merely undesirable. Most teams find while writing it that the second list is where all the money is, and that a good part of the first list is enforceable in the data layer or in a tool permission rather than by a model at all. That is a week of work with the business owner and your risk function, it does not need us, and it makes every later tooling decision obvious. Where we help is building the rails and the evaluation that shows they hold, and handing both to your own reviewers to test rather than reporting on our own work.
Prefer to talk it through? Ask us on a discovery call →
Sources
Every source below was opened and read before it was attached. Where nothing survived that check, the claim on this page was softened rather than given a plausible-looking link.
Kalai, Nachum, Vempala and Zhang, Why Language Models Hallucinate (2025)Argues hallucinations persist because training and evaluation reward guessing over acknowledging uncertainty, and recommends changing how existing benchmarks score uncertainty rather than adding more hallucination evaluations.OWASP Top 10 for Large Language Model Applications (2025)LLM01 Prompt Injection, LLM07 System Prompt Leakage and LLM09 Misinformation are the entries behind the arguments above.Rebedea et al., NeMo Guardrails: a toolkit for controllable and safe LLM applications with programmable rails (2023)Source of the description of rails as runtime, programmable and independent of the underlying model. Cited as an example of the category, not as a tooling recommendation.Zheng et al., Judging LLM-as-a-Judge with MT-Bench and Chatbot Arena (2023)Over 80% agreement with human preference, plus the position, verbosity and self-enhancement biases that make a model judge useful for triage and unsafe as a release gate.Ganguli et al., Red Teaming Language Models to Reduce Harms (2022)Released a dataset of 38,961 red team attacks and reported that models trained with human feedback became harder to red team as they scaled. The evidence that adversarial testing is a volume activity rather than a workshop.Greshake et al., Not what you've signed up for: compromising real-world LLM-integrated applications with indirect prompt injection (2023)Why a system prompt is not a control: instructions planted in retrieved content were used to steer real deployed applications.Questions this guide answers
How do you stop an AI agent hallucinating?
You do not stop it, you bound it, and the difference is the whole design. Recent work argues models produce confident false statements because training and evaluation reward guessing over admitting uncertainty, so the lever available to you is architectural rather than a better model. Four things do most of the work. Constrain the output, so a schema or a required citation makes whole classes of invention impossible. Ground the answer in retrieved passages the reader can open, so a wrong answer is checkable rather than merely fluent. Give the system a supported way to say it does not know, and measure how often it uses it. And route by consequence, so the cases where being wrong is expensive reach a person. Accuracy improvements help at the margin; those four change what a wrong answer costs.
What are AI guardrails?
Runtime controls placed around a model to bound what it can be asked, what it can retrieve, what it can say and what it can do. They sit outside the model rather than inside its training, which is what makes them changeable without retraining and inspectable by someone who is not an engineer. In practice a serious stack has four layers: input, retrieval, output and action. The important thing to understand about them is that a guardrail toolkit is programmable, so it enforces whatever policy you write and nothing else. Buying one without writing the policy is buying a dependency.
Is a system prompt a guardrail?
No, and treating one as though it were is a common way to mislead a risk committee without meaning to. A system prompt is an instruction in the same channel as the input that may be trying to override it, which is why prompt injection is the first entry on the OWASP risk list for language model applications, and why system prompt leakage is an entry in its own right. A prompt is a useful way to shape behaviour and a poor way to prevent it. Anything that must never happen belongs in a schema, a permission, a filter outside the model, or a system that is simply not reachable.
What is prompt injection, and how do you defend against it?
Prompt injection is text that reaches the model as an instruction when it was meant to be read as data, either typed by the person using the system or planted in content the system later retrieves. It is the first entry on the OWASP risk list for language model applications, and it works for the reason above: instructions in a prompt are advisory and sit in the same channel as the input trying to override them, so a control a paragraph of text can talk its way past is not a control. The defence is architectural and it is layered. Prefer constraint to correction, because a model required to return output matching a schema cannot invent a field, a model answering only from retrieved passages with a citation can be checked by the reader, and a model with no tool for an action cannot take it. Handle retrieved passages as data rather than as instructions. Scope the tools and permissions the agent can reach so that a successful injection cannot do much, which is the control that still holds when the others fail. And carry adversarial documents in the evaluation set alongside the ordinary ones, because in an enterprise corpus the injected text does not have to come from an attacker: a well-meant instruction in a document template will do it.
What accuracy should we ask a supplier to commit to?
Be careful of anyone who answers that with a number before seeing your data, because the answer depends on what the exception path costs. Ask instead for four commitments that are checkable. A named evaluation set built from your cases, with the definition of a correct answer agreed by the person who owns the decision. A threshold per case type rather than one headline figure, since the easy cases will otherwise carry the average. A stated abstention behaviour, so you know what the system does when it should not answer. And the trajectory measures, cost, latency and override rate, alongside accuracy. A supplier willing to be held to those is a better sign than one quoting 95%.
Can you use one language model to check another?
Yes, for the right job. The published work on model-graded evaluation found strong judges reaching over 80% agreement with human preference, which is roughly the agreement rate between humans, so it is a reasonable way to score at a volume no human panel could. It also identified position, verbosity and self-enhancement biases, meaning a judge can prefer the first answer it sees, the longer answer, and answers resembling its own. So use it for triage, regression detection and ranking, not as the gate. Keep a human-scored sample every cycle to detect drift in the judge, and be deliberate about whether the judge and the system share a model family.
What actually breaks after week two?
The long tail and the disagreements, in that order, and neither is a model problem. Week one and two are the happy path, which is where a demo lives. What surfaces afterwards is the document that is a scan of a fax, the record with a field the specification never mentioned, the case where two experienced people give different correct answers, and the tool that returns success while doing nothing. On our insurance engagement the gap-and-contradiction pass over the requirement corpus surfaced ambiguities the business had not realised were ambiguous, and resolving them took a conversation rather than a rebuild, which is the cheap version of finding out. The limit of that answer: our agentic work is proofs of concept rather than production systems, so we can speak to weeks three to eight of a build, and month fourteen of a live agentic service is outside our own experience. The client engagement is confidential, so the specifics stay unpublished.
Will a newer model fix our accuracy problem?
Sometimes, at the margin, and it will not change the shape of the problem. A stronger model typically improves the average and leaves you with the same questions: what happens on the cases it still gets wrong, how you would know, and who is accountable when it does. It also resets your evaluation, because behaviour changes in both directions on an upgrade and prompts tuned to the old model frequently perform worse on the new one. The organisations that get value from upgrades are the ones with an evaluation set to run them against, which is an argument for building that first rather than an argument against upgrading.
The closest guides to this one
Nearest first, then the rest. Each one carries the same label: written from delivery, or the method we would bring. All 13 are on the hub.
Retrieval, RAG and permission-aware knowledge access
Answering from your own knowledge, without answering from documents the person asking is not allowed to see.
Our approachMCP, tool calling and integrating agents with your systems
The moment an agent can call your systems, integration stops being plumbing and becomes an access decision.
Our approachRAG, fine-tuning or prompting: how to choose
Sorting the requirement into knowledge, behaviour and cost, so the decision survives a finance review.
DeliveredDocument intelligence to business intelligence
Getting information out of PDFs and into something the business can decide with.
Our approachAgent evaluation and assurance
Why AI pilots never reach production, and what it takes to get one through the gate.
Our approachAI governance and regulatory evidence
Building the evidence as a by-product of the work, rather than assembling it under deadline.
Talk to us about guardrails, hallucination and accuracy control.
A 30-minute call with James Rooney. We'll tell you honestly which parts of this we have done before and which we would be doing for the first time, and you'll leave with a rough scope either way.
most start with a fixed-price AI Readiness Audit · £30k–£90k · 6–8 weeks
Calendar not loading? Open it on cal.com or email hello@tenhaw.com.