Skip to main content
An agent that quotes a policy should be able to say which policy, which version and which page. A context fetch returns that provenance with every item. Synap returns it; showing it to the user, or putting it in the prompt, is up to your code. Synap does not add citations to the text of an item.

What each kind of result carries

source_evidence is a list of short strings, and it is absent on a memory that has none. A document passage carries a citation instead.

Where to find them

Ask for the ranked shape and every item sits in one list, best first. A document item has a kind (passage, record or fetched) and a citation. Memories carry kind: "memory" when they are ranked together with documents.
In the default by-type shape, document items are in separate lists next to the memory lists: passages, records and fetched, each item carrying its citation. A list is absent when it has no items.
The TypeScript SDK (0.9.0) has no named types for document item fields, so kind and citation are read from the item as shown.

What a citation holds

A field that does not apply comes back as null; source_disconnected, etag and age_seconds are left out unless they apply. Check that a field is set before you use it.

Open the source

url is a link you can show as it is. For the file itself, pass document_key and version to documents.original, which returns the file’s bytes. It never returns a link, so serve the bytes from your own endpoint to the user who clicked.
documents.original is Python 0.9.0 and later and JavaScript 0.9.0 and later; in TypeScript it returns the bytes as a Uint8Array. See documents.original.
  • url is empty. The document was sent as a file with no source.url. Open it with documents.original, or build your own link from document_id.
  • document_key is empty on a fetched item. An item read live from a connected source has its url, fetched_at and etag, and a document_key only when a stored copy of the document exists.
  • document_key, url and anchor are all empty. Synap leaves them out whenever the document itself is not visible to the caller, for example because your visibility policy hides its Instance. document_id, version, section_path and page are still there to show as text.
  • page or section_path is empty. The format has no pages or headings, such as a plain text file.
  • documents.original raises ContextNotFoundError. The document or that version no longer exists, was deleted, is not visible, or has no stored original.
  • A conversation memory. It has no citation, only source_evidence.

Next steps

Documents

Ids, versions and provenance: where citation fields come from.

documents.original

Download the file behind a citation.