DEV Community

Cover image for Should Your AI Agent Cite Its Sources?
Pykero
Pykero

Posted on Originally published at pykero.com

Should Your AI Agent Cite Its Sources?

Yes, if a human will act on what the agent says without re-checking it. An agent that can show exactly which page, record, or document each claim came from is one you can audit, correct, and trust in front of a customer. An agent that cannot is a well-written guess, and the cost of that guess lands on your team, not on the model.

The question founders actually face is not whether provenance is nice. It is where it is worth paying for, how much it costs, and how to write it into a build so it cannot be quietly dropped when the deadline gets tight.

What "citing sources" really means in an agent

There are three very different things people mean by this, and vendors blur them on purpose.

  • Prompted citations. You tell the model "cite your sources" and it writes plausible references. These are text, not links to anything the system verified. They fail silently.
  • Grounded citations. The system retrieves specific passages, passes them to the model with stable IDs, and the model refers to those IDs. The system then maps IDs back to real documents. This is real provenance and is what RAG done properly gives you.
  • Verified citations. After generation, a check confirms that each cited passage actually supports the sentence it is attached to. This is the strongest form and the one you want in regulated or high-stakes work.

If a demo shows citations, ask which of the three you are looking at. If the answer is the first, the feature does not exist yet.

Where provenance pays for itself

Outputs a person sends or signs

Sales outreach, proposals, support replies, and anything with your company's name on it. When a rep hits send on an agent-drafted email that contains a fabricated detail about the prospect, you lose the lead and some reputation with it.

In our own outreach tool, the agent reads each prospect's website and drafts one tailored email. Early on we made a simple design decision: the model extracts the facts it plans to use and writes the email in the same call, and every fact stays tied to the page it came from. That let a reviewer glance at the draft, see which page justified the opening line, and reject drafts where the "fact" was a stretch. We covered why the single call beat the multi-step version on cost and quality in single call vs agent chains. The provenance came almost for free because we never let the source URL fall off the data as it moved through the pipeline.

Healthcare, legal, government, finance

Here provenance is not a feature, it is the product. A clinician will not act on a summary that says "the patient has a documented allergy" unless they can click through to the note. A procurement officer evaluating an AI vendor will ask how a given answer can be reconstructed after the fact. If you sell into these markets, put provenance next to access control in your architecture, because the two are linked: a citation is only safe if the reader was allowed to see the source, which is the whole point of permission-aware retrieval.

Anything you will be asked to defend later

Disputes, audits, and post-incident reviews all ask the same question: why did the system say this? A log of prompts and completions is not an answer. A log that says "this sentence was generated from passage 14 of document X, retrieved at this time, visible to this user" is.

Where it is not worth it

Be honest about this too, because provenance adds friction and you do not want it everywhere.

  • Creative and exploratory tools. Brainstorming names, rewriting tone, generating variants. Nobody needs a footnote on a headline suggestion, and there is no retrieved passage for it to point at anyway.
  • Internal assistants with a human in the loop by default. If the user is an expert who will always verify before acting, a short "here is what I looked at" list beats per-sentence citations. The reviewer in our outreach tool needed to know which page justified the opening line, not a reference stapled to every clause.
  • Code generation. Tests and review are the verification layer. Citations to documentation are pleasant but rarely change behavior.

The rule of thumb: the further the output travels from the person who requested it before someone checks it, the more provenance you need. A draft the rep reads before sending needs less than a support reply that goes out on its own.

What it costs to build

Provenance is one of the cheapest things to add early and one of the more annoying things to retrofit. The cost sits in three places.

Data plumbing. Every chunk you index needs a stable ID, a source reference, and ideally a character range. This is a schema decision made once. In the outreach tool it was a single field, the URL of the page each fact came from, carried on the record through every step and never dropped. Skipping it saves a day now and costs weeks later when you try to reconstruct which chunk produced which sentence.

Prompt and output format. The model has to be given IDs and asked to reference them in a structured way, and your parser has to handle the model getting it slightly wrong. Budget for a structured output format and a fallback for when the model cites an ID that was not in context. That case is the prompted-citation failure from earlier sneaking back in, and it must be flagged, not rendered as a link. Several providers now offer native citation modes that return source spans alongside text, which removes most of the parsing work. Check your provider's documentation for whether the model you are using supports it before building your own.

UI. Someone has to design how a citation looks and what happens when you click it. Underestimating this is the most common reason provenance features ship half-finished. A citation that opens the whole 40-page PDF at page one is technically present and practically useless. Deep link to the passage.

Token cost is real but secondary. Passing IDs and asking for structured references adds a modest overhead per call. If your budget is tight, the levers in LLM cost optimization matter far more than trimming citations.

How to write it into a vendor spec

Vague language here gets you the prompted version. Write acceptance criteria that can be measured.

  • Every factual claim in an output is linked to a retrieved passage, not to a document title. The link opens the passage, not the file.
  • A citation the model invents is treated as a defect. The system must reject or flag any reference to a source that was not in the retrieval set for that call.
  • Citation accuracy is a tested number. Take a sample of outputs, have a person check whether each cited passage supports the claim, and set a threshold. This belongs in the same document as your other evals in the vendor contract.
  • Provenance is logged, not just displayed. For any output, you can later retrieve the exact sources, their versions, and who was allowed to see them.
  • No citation, no claim. If the agent cannot find a source for something, it says so rather than filling the gap. This single rule removes most of the embarrassing failures.

If a vendor pushes back on any of these as "too heavy for an MVP," ask which of them they would be willing to have a customer discover was missing.

The quiet benefit: it makes the agent better

Teams that add provenance usually find their agents improve for a reason that has nothing to do with trust. Once every claim has to point at a passage, you can see which retrievals are weak, which documents are stale, and which prompts cause the model to overreach. Provenance turns "the agent was wrong" into "the agent was wrong because the retrieval returned the 2023 pricing page," which is a bug you can fix. Without it you are tuning in the dark.

If you are scoping an agent where the output leaves your building, treat provenance as part of the core build, not a phase two item. We can help you design the retrieval, the citation model, and the review flow so the thing you ship is checkable from day one. Let's talk.


Originally published on the Pykero blog.

Top comments (0)