Only answer from the docs
In the last lesson your RAG agent retrieved a snippet and grounded its answer in it. But retrieval handing back a snippet doesn't force the model to stay faithful to it — a model will cheerfully blend in a detail from memory the docs never mentioned. A user asks for the support phone number; your snippets cover refunds and pricing but say nothing about phones, and the model invents "1-800-555-0199." Fluent, specific, and completely fabricated. The damage is worse than a wrong general fact, because it arrives wearing the authority of "answered from your documents."
A faithful agent enforces two rules. First, answer only when the answer phrase actually appears in a retrieved snippet — the snippets are the entire universe of what it's allowed to know. Second, cite the snippet it came from, so any reader can trace the claim back to its source. And when no snippet contains the answer, the faithful move isn't a softer guess — it's a flat refusal: "Not in the provided documents."
Walk the three questions. "What is the refund window?" → the answer 30 days
appears in the refunds snippet, so you emit 30 days [refunds]. "How much is the
free tier?" → $0 for the free tier is right there in pricing → cite it. "What's
the phone support number?" → you scan every snippet, find 1-800-555-0199 in none
of them, and refuse rather than reach into memory. The citation isn't decoration:
the act of having to name a source is what mechanically blocks the hallucination —
if you can't find the phrase to point at, there's nothing to cite, so you can't
answer.
Why it matters: this is the trust contract of a grounded agent. Hallucinated facts are the fastest way to lose a user, and "no answer" beats a confident wrong one every time — especially for prices, policies, and numbers people act on.
Below you have two snippets and three questions; the first two answers live in the
snippets, the third does not. Make the agent print <answer> [<id>] when the answer
phrase appears in some snippet, and exactly Not in the provided documents. when it
doesn't. Done means two cited answers followed by one refusal.
Grounding isn't about sounding confident — it's about being checkable. If you can't point to the snippet, you don't get to say it.