Ask

Answer format

This page describes the XML answer document, its elements, its Markdown form, and the citation check that runs on every answer.

Two forms of one answer

An answer comes back in two forms built from the same object: Markdown for people and chat, and an XML document that holds the same Markdown plus everything a product needs to render or check it. Prose is Markdown, citations are [^id] markers, and the things they point to are declared once as elements. The code is in src/answer/xml.ts and the spec is specs/answer-xml.v0.md.

An example

This is a real answer from the San Francisco demo, shortened. It came from:

sh
deno task sf ask "What is planned at 150 Hayes Street, and did it come up at the Board?" --path entities --answer --format xml
xml
<answer id="ans_802be77c" path="entities" run="edf3b647-069e-4615-8dae-2a29b98ecba7" at="2026-11-07T02:12:45.070Z">
  <body>
A permit filed on 2026-10-29 would convert the office building at 150 Hayes St
into a 106-unit residential building [^s1]. At the 2026-10-20 Board of Supervisors
meeting, 150 Hayes was named as one of four projects using the adaptive reuse
program [^s2].
  </body>
  <field entity="address.150-hayes-st" name="street" source="s3">hayes st</field>
  <source id="s1" kind="row" title="Permit 202610149441 at 150 Hayes St: filed" href="gw://permits/175834582073">Table: permits
permit number: 202610149441 ...</source>
  <source id="s2" kind="transcript" title="Board of Supervisors, 2026-10-20" href="gw://meetings/SFGTV_20261020_210000_Full_Board_of_Supervisors" start="5750" end="5808">Board of Supervisors, 2026-10-20 ...</source>
  <source id="s3" kind="row" title="Liberty Park Management Inc at 150 Hayes St" href="gw://businesses/0377938-29-001-0377938">Table: businesses ...</source>
  <entity key="address.150-hayes-st" type="address" />
</answer>

Elements

Element Required Meaning
answer Yes Root. id, path (the answer path used), config (config hash), run (audit run id), at
body Yes The answer in Markdown. [^id] cites a source; media:id in an image or link points at a media element
source One per marker What a claim rests on. kind is chunk, row, transcript, page, entity or web. href is a stable source address. Optional page, start and end (seconds for audio, characters for text), and a short quoted excerpt as text
field No A canonical field value the answer used, with the entity key, field name, the source it came from and a confidence
media No An image, audio or video clip the answer refers to: kind, src, alt, optional start and end
entity No A canonical entity the answer is about, so a product can link to it
refusal No Present instead of claims when the answer declines. reason is no-evidence, out-of-scope or rule

How the prototype fills it

fromAnswer turns an AnswerData object (see Ask and search) into an answer document:

  • The answer model cites evidence by id, such as [permits/175834582073]. Each cited piece becomes a numbered source and its marker becomes [^s1]. A citation that matches no evidence keeps its id as the marker, so the check reports it.
  • A count, total or ranking cites the query that produced it, such as [sql/permits-1]. Each table query the agent runs is one piece of evidence holding its SQL and its rows, and the source panel shows it as a table.
  • The source kind comes from where the evidence came from: table rows are row, meetings and videos are transcript, PDFs are page, and anything else is chunk.
  • href is a gw://<doc id> address. PDF pages add #page=<n>, and videos link to the moment on YouTube.
  • Every canonical field of the entities the answer touched becomes a field, pointing at the source its value came from.
  • With no answer model set, the body is a list of the evidence, each item cited.
  • With no evidence at all, the answer includes <refusal reason="no-evidence" />.

Some parts of the spec are not filled yet. The command line does not set config, media is always empty, field has no confidence, and refusals other than no-evidence are not produced.

The Markdown form

renderMarkdown produces the body followed by each cited source as a footnote, in the order first cited. Transcript sources show the moment and page sources show the page. For the example above:

md
A permit filed on 2026-10-29 would convert the office building at 150 Hayes St
into a 106-unit residential building [^s1]. At the 2026-10-20 Board of Supervisors
meeting, 150 Hayes was named as one of four projects using the adaptive reuse
program [^s2].

[^s1]: Permit 202610149441 at 150 Hayes St: filed, gw://permits/175834582073
[^s2]: Board of Supervisors, 2026-10-20 at 1:35:50, gw://meetings/SFGTV_20261020_210000_Full_Board_of_Supervisors

Because the Markdown is derived from the same object, the two forms cannot disagree. The command line's default --format md prints a terminal view with evidence and trace rather than this footnoted form.

Citation check

checkCitations runs on every XML answer and returns:

json
{ "ok": true, "markers": 2, "unresolved": [], "uncited": [], "badFields": [] }
Field Meaning
ok True when every marker, field source and media: reference resolves
markers How many [^id] markers the body has
unresolved Markers with no matching source, and media: ids with no media element
uncited Sources nothing cites in the body or a field. Allowed, but flagged
badFields Fields that name a source that does not exist

This is the result for the example above. s3 is cited only by a field, which counts as a use, so it does not appear in uncited.

The check confirms that citations resolve. Whether each source supports the line that cites it is measured separately, by the generate benchmark (deno task bench:generate) and the citations row of the Scorecard. The spec's Check step plans a model-based support check and an audit ledger row for the result; neither is wired in yet.

Parsing

parseAnswerXml reads this format back into the same object, so a product or test can round-trip an answer. It reads one root with flat children and nothing else.

In the hosted API

The planned API returns this document for format=xml, and Markdown by default for chat. See Ask. The hosted API is in design.