Skip to content

Knowledge and RAG

Sources and citations

The sources event in the stream, its fields, when it's sent, and how the agent cites documents and web pages in its answer.

Reference1 min readUpdated 23 October 2026

When an answer uses knowledge, your app hears about it twice: a structured sources event before the answer, and source lines the model writes at the end of the answer.

The sources event

Sent once, before the first delta, when knowledge context was added and at least one passage can be cited. A cached answer replays its sources too.

Server-sent event
data: {"type": "sources", "sources": [  {"index": 1, "id": "...", "title": "Returns and refunds", "url": "https://example.com/returns",   "filename": null, "source_type": "web", "score": 0.84, "snippet": "Unworn items can be returned within..."},  {"index": 2, "id": "...", "title": "Warranty terms", "url": null,   "filename": "warranty-2026.pdf", "source_type": "document", "score": 0.71, "snippet": "..."}]}
FieldMeaning
indexPosition, starting at 1
idThe chunk's id
titleThe page title or document name
urlThe page address for web sources, otherwise null
filenameThe file name for documents, otherwise null
source_typedocument, web, faq (a snippet) or qa
scoreThe relevance score after reranking
snippetThe start of the passage, up to 240 characters

Citations in the answer text

The model is told not to cite inline, and to end its answer with one line per source it used: a web page as a markdown link, a document as its file name. Snippets and Q&A pairs are internal knowledge and are never cited.

End of an answer
Worn items can't be returned, but faults are covered for 12 months.Source: [https://example.com/returns](https://example.com/returns)Source: warranty-2026.pdf

Showing sources in your app

  • Render the sources event as a citations panel as soon as it arrives, before the answer finishes.
  • Use url to link out, or filename to label a document.
  • Log the ids and scores with your request id to investigate answers later.
  • The widget shows the answer text, including its source lines, rendered as markdown.

Still stuck?

Email us with what you tried and any request id. A person replies.

support@sentientone.ai