Loading WURK...
RomanMotion
RomanMotion
Product ad & launch videos · 3D product visuals · app & AI builder. Concept to final cut in days. Open for projects.

Make your AI agent cite its sources so you can check its answers

Require a URL plus a verbatim quote for every claim your AI agent makes, then check the quote really appears on that page.

Published on November 7, 20266 min read

Your agent hands you a tidy answer and you ship it to the client. A week later they ask where a number came from and your only honest reply is "the AI said so." A small setup fixes that: every claim your agent makes gets a source URL and a quote you can verify in seconds.

Here's the direct answer. Put one rule in your agent's instructions: every factual claim must come with the URL it came from and a short quote copied word for word from that page. Store the claims in a fixed format like JSON, then run a small script that fetches each URL and confirms the quote actually appears on the page. Claims that fail get retried, marked unknown, or dropped. That turns "trust me" into something anyone can check, and it catches made-up facts before your client does.

Why an uncited answer is a liability

An agent that answers without sources fails in three predictable ways.

First, it can invent things. A language model fills gaps with plausible-sounding text, and a plausible number looks exactly like a real one until someone checks it. On a gig, that someone is your client, after they paid.

Second, it can be right about a page that changed. Prices, dates, availability, and policies move. An answer built from stale training data reads as confident and is quietly wrong.

Third, nobody can check anything. Without a URL there is no way to re-trace the work, not for you, not for the person reviewing your bounty submission, not for the client six months later. An unverifiable claim in delivered work is a rework ticket waiting to happen.

The fix costs almost nothing: make the citation a requirement of the output, not a nice-to-have.

The rule to put in the agent's instructions

Add this to the system prompt or task instructions, in plain words:

For every factual claim in your answer, cite the exact page it came from: give the full URL and a short quote copied verbatim from that page, no longer than two sentences. If you cannot find a page that says it, say "not found" for that claim instead of guessing. A claim without a URL and a quote is not an answer.

Two details in that rule do most of the work. The verbatim requirement matters because a paraphrase is unverifiable: only exact text can be matched against the page later. And "not found" being an allowed answer matters because agents pad gaps rather than admit them. If your agent knows an honest empty result is acceptable, it stops inventing to fill one.

Apply the rule to facts, not opinions. "This library is easier to set up" is a judgment; "the library requires Node 18" is a claim and needs a source.

An output format that makes checking trivial

Free-text citations are hard to verify automatically. Make the agent return structured claims instead. This is the template worth screenshotting:

[
  {
    "claim": "The API rate limit is 100 requests per minute.",
    "url": "https://example.com/docs/rate-limits",
    "quote": "Clients may make up to 100 requests per minute.",
    "checked": false
  }
]

Three fields carry the whole system: what is claimed, where it came from, and the exact words on that page. The checked field starts false and your verification script flips it. If you deliver Markdown to a human instead, use the same fields as a table so the reviewer can scan claim, source, and quote side by side.

The automatic check: fetch the URL and look for the quote

Once claims come back structured, verification is a few lines of Python. Fetch the page, normalize whitespace, and check whether the quote appears in it:

import requests

def check(claim):
    page = requests.get(claim["url"], timeout=15).text
    page_text = " ".join(page.lower().split())
    quote = " ".join(claim["quote"].lower().split())
    return quote in page_text

for claim in claims:
    claim["checked"] = check(claim)
    if not claim["checked"]:
        print("FAILED:", claim["claim"])

Run it on every claim before the work ships. Anything that fails gets flagged, not silently included.

Two practical caveats. Pages that render with JavaScript can return an empty shell to a plain fetch, so a failed check on one of those may be a fetching problem, not a false claim; open the page in a browser before you accuse the agent of making it up. And a quote spanning bold text, a list, or a line break can fail the naive match even though the words are there, which is one more reason to keep quotes short.

What to do when a claim fails

A failed check is information, not an inconvenience to route around.

Retry the search once with the failure in hand: tell the agent the quote did not appear and have it find a page that does support the claim. Often the second pass lands on a better source anyway. If it fails again, the claim becomes "unknown" in the output, stated as such, or gets dropped entirely. What it never becomes is a claim with the citation removed, or a quote edited until it matches. Editing a quote to pass the check is exactly the made-up-fact problem wearing a citation as a costume.

Make failures loud in your workflow. A short line such as "3 of 12 claims failed verification, marked unknown" in your delivery tells the client you ran the check, which builds more trust than a clean-looking answer with no process behind it.

What a citation does not prove

The quote on the page proves the page says it. It does not prove the page is true. A well-formatted blog post repeating a wrong number passes this check with flying colors, so does a vendor's own marketing page. The verification step catches fabrication and staleness, not error at the source.

Two habits close most of that gap. Prefer primary sources: the changelog over the blog post about the changelog, the official docs over a tutorial summarizing them, the filing over the article about the filing. And check who publishes the page when the claim matters, because an interested party saying something about itself is weaker evidence than it looks.

A citation is not proof of truth. It is proof of provenance, and that is what makes the answer auditable instead of vibes. Ship work where every number can be traced in one click, and the client's first question stops being "where did this come from" and starts being "what's next."

That's the whole setup: one rule in the instructions, one JSON format, one short script. For the format side, see Get JSON you can trust from an LLM: schema, validate, retry.

If it saved you from shipping a made-up fact, a tip on WURK is appreciated, never required.

Conversation

Join the conversation

Share your thoughts with the author and other readers.

Comments0

Checking your account…

Latest comments

0
No comments yet. Be the first to share your thoughts.