Pattern guide

Guardrails, hallucination and accuracy control

You will not stop a language model being wrong. You can decide in advance what happens when it is.

ways these programmes stall
5
steps in how we would address it
7
questions answered in full
7
In one paragraph

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.

James Rooney, Founder

Updated

Our approach

We have not delivered this at enterprise scale, and here is exactly what we are drawing on

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.

So what should you do about it

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.

Why this matters now

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.

Ask a technical questionanswers from all 12 guides
Ask anything technical about guardrails, hallucination and accuracy control and I will answer from this guide, and tell you first whether this is work we have delivered or an approach we would be taking.

Prefer to talk it through? Ask us on a discovery call →

Diagnosis

Where these programmes actually stall

Not the risks a vendor lists. The ones that stop the work.

01

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.

02

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.

03

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.

04

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.

05

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.

Prescription

How we would address it

Grounded in The Tenhaw Way and the engagements written up in our case studies.

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. 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.
Where this usually starts

Agentic Design Team

A pair who design the agentic systems, and the infrastructure to run them at scale. £35k–£55k / month · 2–4 months.

What that engagement covers

Guardrails, hallucination and accuracy control: your questions

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 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 specifics beyond this are a conversation under NDA rather than a web page.

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.

Sources

Where the checkable claims came from

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.

  1. 01
    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.

  2. 02
    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.

  3. 03
    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.

  4. 04
    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.

  5. 05
    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.

  6. 06
    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.

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.

30 minutesWith James personallyNo obligation

Most organisations start with a fixed-price Agent-Readiness Audit · £30k–£90k · 6–8 weeks