No retrieval system can promise that a support bot never says something false. What you can do is make it answer only from your content, detect some of the cases where it didn't, and fall back to a safe reply. LayBuild does this with a few cheap, blunt checks. This post explains each one, what it catches, and what it lets through, in both directions. An earlier version of this post claimed hallucinations could be eliminated. That was wrong, and this version replaces it.
The path an answer takes
customer question
-> preflight guardrails: blocked terms, prompt-injection patterns, off-topic requests
-> Q&A pair match? -------------------------- yes -> your stored answer, no model call
-> hybrid retrieval: score floor 0.4, top 4 passages
-> nothing to ground on at all? -------------- yes -> fixed reply, no model call
-> generate with the strict knowledge-base prompt
-> under 25% stemmed overlap with sources? --- yes -> fixed reply
-> optional LLM fact-check (off by default)
-> output guardrails: PII redaction, 8,000-character capThe fixed reply is: "I do not have specific information about that in the knowledge base. Please contact {company} for further assistance, or ask about another topic."
Before the model: guardrails that refuse early
Before retrieval, LayBuild checks the message against your organization's blocked-terms list, roughly 25 prompt-injection patterns, and patterns for off-topic general-knowledge requests like maths problems, trivia, poems and translation. A match gets a fixed refusal and never reaches the model. This doesn't prevent hallucination directly, but it removes a category of question where the model would answer from its own training rather than your docs. These are regular expressions, so they miss rephrasings and occasionally catch legitimate questions that happen to contain a blocked word.
Strict knowledge-base mode
Strict mode is always on. The prompt tells the model to answer only from the knowledge supplied in that prompt: retrieved passages, pinned documents, and past interactions with this customer. Outside that, it may only exchange pleasantries. If the answer is missing or only partly there, it must not fill gaps; it has to start its reply with the fixed prefix and offer a human. Generation runs at temperature 0.2 with at most 384 output tokens, which keeps answers short and less inventive.
A prompt instruction is a request, not a control. Models follow it inconsistently, which is why the next two checks exist.
The no-retrieval short circuit, and why it fires less than you'd think
If retrieval returns nothing above the 0.4 floor, and there is also no customer memory and no pinned knowledge, LayBuild skips the model entirely and sends the fixed reply. No model call means no chance to invent anything, and no token cost.
In practice this path fires less often than that description suggests. Pinned documents and a digest of the agent's most recently updated Q&A pairs are added to every prompt for an agent that has them. A returning customer brings memory from earlier conversations. In any of those cases there is something in the prompt, so the model runs even when retrieval found nothing, and the prompt instruction and the overlap check below carry the weight.
The 25% stemmed-overlap check
After the model answers, LayBuild takes the distinct content words in the answer (stopwords removed, each reduced to its stem) and checks how many also appear in the grounding text: the retrieved passages, the pinned knowledge and the customer memory. If fewer than 25% do, the answer is replaced with the fixed reply.
Suppose an answer has 20 distinct content stems and 4 of them appear in the sources. That is 20%, so the answer is replaced. With 5 it is 25% and the answer goes out. This is a lexical check, not citation verification. It never asks whether a sentence is supported, only whether the answer uses the sources' words. That makes it cheap and predictable, and it fails in both directions.
Where it blocks correct answers
- Heavy paraphrase. A correct answer that explains a doc in different words can fall under 25%.
- Answers in another language. The model is told to reply in the customer's language. A correct Hindi or Spanish answer drawn from English docs shares very few stems with them, so it is likely to be replaced. If you serve non-English customers, this is the failure you will see most.
- Short answers. With few content words, one or two unmatched words swing the ratio. A three-word answer with no matching stem is replaced even if it is right.
- Answers that combine or calculate. "That comes to three seats" may share little vocabulary with the passages it was derived from.
Where it lets wrong answers through
- Wrong relations in the right words. If the source says "refunds are available within 14 days" and the model says "refunds are not available after purchase", most of the answer's stems appear in the source. The check passes.
- Swapped facts. If the sources list 5 seats for Starter and 15 for Pro, an answer saying Starter includes 15 seats uses only source words.
- Unsupported additions. Up to 75% of an answer's content words can be new, so a mostly grounded answer can carry an invented sentence.
- Memory as a source. Past conversations count as grounding text, so a customer's own earlier claim ("I was told I'd get a refund") can make an answer that repeats it look grounded.
We chose a lexical check because it is deterministic, adds no model call, and catches the failure it targets: an answer drawn from the model's general knowledge with no connection to your docs. It does not catch a model that misreads your docs.
Q&A pairs skip the model and the check
If a question matches one of your Q&A pairs exactly, or nearly (at least 80% of the shorter question's stemmed words appear in the longer one), LayBuild returns the stored answer directly. No model call, no overlap check. That is the most reliable path for questions you care about, and it is only as correct as the stored answer.
The auto-learning trade-off
After each AI reply, LayBuild checks whether the exchange is learnable: not a refusal, not the fixed reply, not a greeting, a question of at least 8 characters, an answer between 40 and 8,000 characters, and not a near-duplicate (80% overlap) of something already learned. If it is, the exchange is published as a knowledge document and a Q&A pair without human approval. If the customer rates that conversation 2 stars or lower, the learned knowledge is retracted.
The benefit is that answers to recurring questions become fast Q&A matches. The risk follows from the sections above. A wrong answer that passed the overlap check can be learned, and a learned Q&A pair is then served verbatim, skipping the model and the check, to later questions that match it. Retraction depends on a customer bothering to leave a low rating. An optional LLM evidence check can screen answers before they are learned, but it is off by default.
If accuracy matters more to you than coverage, review auto-learned Q&A pairs regularly. They are stored with the category "Learned" and the tag "auto-learned". Disable or correct any that are wrong.
Optional checks for self-hosted deployments
Two more checks can be turned on. RAG_ENABLE_REFLECTION adds a fact-check step: a second model call reads the question, answer and sources and replies "supported" or "unsupported", and an unsupported answer is replaced with the fixed reply. It catches some wrong-relation errors the lexical check misses, at the cost of one extra model call per answer and a judge that can itself be wrong. RAG_ENABLE_RERANKER adds an LLM reranking step before generation, and it also turns on the evidence check for auto-learning. Measure both on your own questions before keeping them.
What to measure
- The rate of fixed replies. A high rate means content gaps or correct answers being blocked. Read a sample to tell which.
- A weekly sample of answers that passed. Look for wrong-relation and swapped-fact errors, because nothing automatic catches them.
- Conversations rated 2 stars or lower, which also show you what auto-learning retracted.
Measuring CSAT in AI-driven channels covers the rating side.
Where to go next
Most wrong answers start with retrieval. Read how LayBuild runs hybrid search and writing help docs an AI agent can retrieve. For what happens when the bot should step aside, see safe human handoff.
