cd /news/artificial-intelligence/our-ai-support-bot-invented-a-refund… Β· home β€Ί topics β€Ί artificial-intelligence β€Ί article
[ARTICLE Β· art-177382] src=dev.to β†— pub= topic=artificial-intelligence verified=true sentiment=↑ positive

Our AI Support Bot Invented a Refund Policy: How We Cut RAG Hallucinations From 18% to 3% in Production (Real Code)

A support team cut hallucinated claims in its RAG-powered support bot from 18% to 3% by adding a retrieval gate with a relevance score floor and freshness filter, citation-forced generation with an explicit abstention path, and a verification layer between the model and the customer. The bot, answering roughly 520 tickets a month, had invented a 60-day no-questions-asked refund policy that did not exist in the knowledge base; hand-labeling 200 answers showed 18% contained at least one claim unsupported by retrieved documents. The team traced the failure to a pipeline with no concept of insufficient evidence, where every question got k chunks and every set of chunks got a confident answer.

recommendation

Add a relevance score floor and freshness filter before generation, force verbatim citations with an explicit can_answer abstention, and verify claims before answers reach users.

more in playbook: Verifying model output
by read6 min views15 publishedNov 27, 2026

AI in Production: War Stories, Scenario #1. One real production incident: the alert, the triage (dead ends included), the root cause, the fix with runnable code, the measured result β€” and how to tell it in a senior interview. This is the hallucination incident.

Full original (canonical) on PrepStack: https://prepstack.co.in/blog/ai-production-scenario-1-rag-hallucinations

Our RAG-powered support bot answers ~520 tickets/month against a knowledge base of product docs, billing policies, and runbooks. Three weeks after launch, a CSM forwarded a screenshot: "did we change the refund policy??"

The bot had told a customer:

"You are eligible for a full refund within 60 days of purchase, no questions asked."

Our actual policy was 14 days, conditional. There was no 60-day policy anywhere in the knowledge base β€” not a draft, not an old version. The model invented it, fluently and confidently.

We hand-labeled 200 recent answers with the support team. 18% contained at least one claim not supported by the retrieved documents. An airline famously lost a tribunal case because its chatbot invented a bereavement-fare policy and the court held the company to it. A hallucinating support bot is not a quality problem; it is a contract-writing machine.

  question -> embed -> vector search (k=8, NO score floor [F1], NO freshness filter [F2])
          -> PROMPT: "answer using the context" (no "I don't know", no citations [F3])
          -> LLM answer -> user   (NO verification [F4])

The refund question hit all four: it asked about annual plans, our docs only covered monthly, retrieval returned 8 weakly-related chunks [F1], one a deprecated 2023 promo doc [F2], the prompt demanded an answer [F3], and nothing stood between the model's guess and the customer [F4].

Root cause: the pipeline had no concept of "not enough evidence." Every question got k chunks and every set of k chunks got a confident answer. Hallucination wasn't a model defect β€” it was the designed behavior of a pipeline with no abstention path.

import anthropic
client = anthropic.Anthropic()

DOCS = [
    "Refunds: monthly plans may be refunded within 14 days of purchase "
    "if usage is below 1,000 API calls.",
    "Billing cycles run from the 1st of each month.",
]

def answer(question: str) -> str:
    context = "\n\n".join(DOCS)                 # [F1] no relevance check
    response = client.messages.create(
        model="claude-sonnet-5-5", max_tokens=1024,
        system="Answer the user's question using the context below.\n\n" + context,  # [F3]
        messages=[{"role": "user", "content": question}],
    )
    return next(b.text for b in response.content if b.type == "text")  # [F4] straight to user

print(answer("What is the refund policy for annual plans?"))

Principle: every claim must be traceable to a retrieved source, and "I don't know" must be a first-class answer.

def gate_retrieval(chunks: list[Chunk]) -> list[Chunk]:
    fresh  = [c for c in chunks if not c.superseded]       # layer 2
    strong = [c for c in fresh if c.score >= MIN_RELEVANCE]  # layer 1 (e.g. 0.72)
    return strong        # an EMPTY result is VALID -> routes to abstention, not generation
class Citation(BaseModel):
    doc_id: str
    quote: str           # verbatim sentence from the source supporting the claim

class GroundedAnswer(BaseModel):
    can_answer: bool     # False when the context does not contain the answer
    answer: str
    citations: list[Citation]

SYSTEM = """Use ONLY the provided context. Every factual claim must carry a
verbatim citation. If the context does not contain the answer, set
can_answer=false - that is a GOOD outcome. Do not generalize from a
similar-but-different case (e.g. monthly vs annual)."""
def judge_faithfulness(answer, chunks) -> float:
    ...
def answer_question(question, retrieved) -> str:
    chunks = gate_retrieval(retrieved)
    if not chunks:                       return ABSTAIN   # escalate to a human ticket
    result = generate(question, chunks)
    if not result.can_answer:            return ABSTAIN
    source_text = " ".join(c.text for c in chunks)
    for cit in result.citations:                          # deterministic, no LLM
        if cit.quote not in source_text: return ABSTAIN   # fabricated citation -> abstain
    if judge_faithfulness(result, chunks) < MIN_FAITHFULNESS: return ABSTAIN
    return result.answer

Four things matter more than any prompt wording:

gate_retrieval returning [] is the system saying "escalate to a human." Before the fix, that state was unrepresentable.cit.quote not in source_text is dumb string containment β€” and that's its virtue. An LLM cannot talk its way past it. Catches fabricated citations with zero model calls.abstain logs became our knowledge-base content roadmap.

# Case Caught by
1 Pure fabrication (the 60-day policy) Judge (claims unsupported)
2 Wrong-source citation Verbatim citation check
3 Stale truth (superseded promo doc) Freshness filter (layer 2)
4 Near-miss generalization (monthly β†’ annual) Prompt rule + judge
5 Partial truth (real window, invented "no questions asked") Judge (per-claim split)
6 Confident answer on garbage retrieval (0.61) Relevance gate (layer 1)

A fix that handles only one of these will look done and still burn you.

Addition Latency Cost
Citation-forced structured output ~0 +15% output tokens
Verbatim citation check <1 ms $0
Faithfulness judge (small model) +400-600 ms ~$0.0004/query

We clawed the judge's latency back three ways: model tiering (judge on a 20x-cheaper small model; verification is narrower than generation), running the judge on the stream while the UI shows "checking sources" (~300 ms perceived, not 600), and prompt caching on the byte-stable system prompt + context (repeat-turn input cost βˆ’85%). Net: roughly cost-neutral per query, p95 +under 300 ms.

Metric Before After
Answers with β‰₯1 unsupported claim 18% 3%
Faithfulness (judge-scored) not measured 0.96
Policy-risk incidents reaching customers ~2/month 0 in 8 weeks
Abstention rate 0% (by design!) 9%, all escalated to humans

The 9% abstention is the number stakeholders questioned β€” "the bot refuses one in eleven?" Yes. Before, those eleven got confident answers and two were wrong in ways a human had to clean up. An honest escalation beats a confident lie on every support metric we track, including CSAT. The remaining 3% is dominated by near-miss generalization β€” the hardest class. Zero isn't the target; zero undetected is.

STAR, 60 seconds: "Our RAG bot was inventing policies β€” 18% unsupported claims, including a refund policy that didn't exist. Instead of swapping models, I rebuilt the pipeline around evidence: a retrieval gate with a relevance floor + freshness filter, citation-forced generation with an abstention path, a deterministic verbatim-quote check, and a cheap second-model faithfulness judge gating every answer. 18% β†’ 3%, faithfulness 0.96, policy incidents to zero, and the 9% we escalate became our KB roadmap."

Follow-ups you'll get: why not a better model? (tried; 18%β†’16% β€” it's a pipeline problem). Who judges the judge? (a 150-pair golden set; 95% agreement with humans before any threshold ships). How'd you pick 0.72 / 0.85? (from labeled data, not vibes). What does it cost? (have the table). What still gets through? (near-miss generalization, ~3% β€” name your residual).

Originally published on PrepStack.

── more in #artificial-intelligence 4 stories Β· sorted by recency
── more on @prepstack 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/our-ai-support-bot-i…] indexed:0 read:6min 2026-11-27 Β· β€”