Skip to content
GitHub (opens in a new tab)

CitedAnswer

An assistant reply with inline citation marks that preview their passage in a hover card, and sources folded into one pill with site icons. A missing source shows as a broken cite.

stableOrganismcontracts/citedanswer.json

Preview

CitedAnswer

An assistant reply with its sources. Not Chat. Not LinkList.

Master

Hover or focus a mark to read the passage it came from. Click it, or the pill, to open the sources.

Billing agent· 14:02

Refunds on annual plans are prorated by the daydocs.example.comRefunds · Annual plansWhen an annual plan is cancelled early, the unused part is prorated by the day and refunded., and the refund goes back to the original card within 5–10 business dayshelp.payments.exampleCard refunds and settlementRefunds return to the original payment method. Most banks post them within 5–10 business days.. Tax is refunded with the line it was charged ondocs.example.comTax on refundsTax is refunded together with the invoice line it was charged on, never as a separate line., so a partial refund recalculates itreporefund.ts · recalcTax()A partial refund calls recalcTax() on the remaining amount before the credit note is issued.. Credits issued instead of refunds never expirenotes.example.comCredits policy, 2026Account credits issued in place of a refund do not expire and apply to the next invoice first..

  1. [1]
    Refunds · Annual plans (opens in a new tab)docs.example.com/billing/refundsWhen an annual plan is cancelled early, the unused part is prorated by the day and refunded.
  2. [2]
    Card refunds and settlement (opens in a new tab)help.payments.example/card-refundsRefunds return to the original payment method. Most banks post them within 5–10 business days.
  3. [3]
    Tax on refunds (opens in a new tab)docs.example.com/billing/taxTax is refunded together with the invoice line it was charged on, never as a separate line.
  4. [4]
    refund.ts · recalcTax()repo · src/billing/refund.tsA partial refund calls recalcTax() on the remaining amount before the credit note is issued.
  5. [5]
    Credits policy, 2026 (opens in a new tab)notes.example.com/policy/creditsAccount credits issued in place of a refund do not expire and apply to the next invoice first.

Usage

CitedAnswer is one reply; Chat stays the thread shell. Each mark is a button: hover or focus shows a card with the site, title and passage, the cited words marked; Enter or Space toggles it and Escape closes it. On touch the first tap pins the card and the second opens the list. The sources fold into one pill with the sites' icons, and a mark and its row glow together. A source that went missing says so instead of disappearing.

Do's

  • an assistant answer that cites documents, pages or files
  • let people jump from a mark to its source
  • flag a source that no longer exists

Don'ts

  • the whole chat thread — Chat
  • a plain list of links — LinkList
  • a single recommendation card — InsightCard
<CitedAnswer
  time="14:02"
  content="Store invoice totals as integer cents[1]. Floats are not allowed for money[2]."
  citations={citations}
/>

When to use

  • an assistant answer that cites documents, pages or files
  • let people jump from a mark to its source
  • flag a source that no longer exists

When not to use

  • the whole chat thread — Chat
  • a plain list of links — LinkList
  • a single recommendation card — InsightCard

What an agent reads

import { CitedAnswer } from "agentic-ds-kit";
must
  • marks are buttons named "Source N: title" ("Source N: missing, title" when missing), with a 24px hit area. Hover or focus opens a HoverCard with the site, title and passage, the cited words marked; Enter and Space toggle it, Escape closes it. A mouse click (or a second tap) opens the list and moves focus to the source
  • the sources toggle (left out when a trail is shown) is a button with aria-expanded and aria-controls, a quiet text row flush with the answer: no frame or fill at rest, a hover fill and the focus ring. Its text comes from KitLabels sourceCount and missingSourceCount, and its site icons are decorative. It and the trail summary are CitedAnswer's own button, not kit Button: kit Button takes text only, and these rows hold the source marks, the ShimmerText running label and the BlurCrossfade swap
  • external source links say they open a new tab
  • a missing source is said in text ("[n] missing", "Missing: title"), not colour alone
  • loading uses kit ShimmerText; the error is a kit LoadError (role=alert); emptyText shows as a small kit Empty
  • the clicked source stays tinted until another mark is clicked. One decorative fill (the shared gliding highlight, aria-hidden) glides between source rows: it follows the row under the pointer, else the row whose mark is pointed at or focused, else the clicked row; the mark glows with it. A missing row keeps its danger tint
  • a missing source keeps its danger tint when its mark is clicked, so the warning stays visible
  • the list glides open with rows rising in turn; under prefers-reduced-motion it all shows and hides with no motion
  • trail: the summary pill is a button with aria-expanded and aria-controls; the steps are kit AgentTrail (list, header={false}, an ordered list) and the pages read are an ordered list of real links that say they open a new tab
  • trail: the running step is said once per step through one aria-live=polite line, never per tick; the pill label crossfades (BlurCrossfade) from the running step (ShimmerText) to the summary
  • trail: only live changes move (steps, pages and site icons rise in, a finished step draws its check); a first render and prefers-reduced-motion are still
defaults
  • author Assistant
  • loading false
  • loadingText Reading sources…
  • emptyText No sources. Check before you act on this.
stops if
  • Do not invent a local CitedMessage, SourcesList, or Footnotes
  • Do not render marks as plain text
  • Do not hide missing sources
  • Do not use raw hex

From contracts/citedanswer.json: must is the a11y requirements, defaults the prop defaults, stops if the doNot rules where the agent asks instead of inventing a cousin.

Props

NameTypeRequiredDefaultNotes
contentstringYes—Marks like [1] become citation links.
citationsarrayYes—{ id, title, href?, origin?, snippet?, highlight?, favicon?, missing?, missingReason? }[]; id matches the mark. highlight marks the cited words inside snippet; favicon is the site icon URL, shown in the hover card only (else a neutral letter tile from the origin host). The toggle's source marks never use favicon: one neutral letter circle per site, all alike, 2px apart, at most 4 then a lighter "+N" circle. Circles here are an approved exception to Avatar's square-for-organisations rule. A missing mark reads "[n] missing" and the list opens on first render.
authorstringNoAssistant—
timestringNo——
openSourcesbooleanNo—Controlled; otherwise internal.
onOpenSourcesChangefunctionNo—(open) => void
onCitationClickfunctionNo—(id) => void. On click the list opens, the source highlights and takes focus.
loadingbooleanNofalse—
loadingTextstringNoReading sources…—
errorstringNo——
onRetryfunctionNo——
emptyTextstringNoNo sources. Check before you act on this.Shown when citations is []. "" hides it.
trailobjectNo—{ status: "searching" | "reading" | "done", queries: { id, text, status: "pending" | "running" | "done" }[], read: { id, title, href, favicon? }[] }. Web search trail above the answer: one step per query, then the pages read as links. Open while it runs; folds to KitLabels webSearchSummary when done. With a trail the sources pill is left out (the summary line counts the sources; marks still open the list). Left out, nothing changes.
  • Component
    →

    Chat

    Assistant panel with a header, a thread, and a composer.

  • Component
    →

    LinkList

    A column of links, one a row with a chevron at the end, like an account's quick links.

  • Component
    →

    InsightCard

    A recommended insight or opportunity as a compact card, with tone and optional actions.

  • Component
    →

    AgentTrail

    A vertical step list for a running agent task: done steps with durations, the current step with a live timer, then pending steps.