Skip to content

Feature: scriptable citations / annotations on text responses #547

Closed

Description

@abhiaiyer91

Problem

Responses API output_text parts are always emitted with annotations: [], and Chat Completions / Anthropic / Gemini have no citation equivalent. There is no way to script a model turn that returns sources, so clients that surface citations (e.g. the AI SDK source stream part) can't be tested end-to-end against aimock.

Proposal

An optional citations (or annotations) field on TextResponse / ContentWithToolCallsResponse, e.g.

llm.on({ endpoint: 'responses' }, {
  content: 'Paris is the capital of France.',
  citations: [{ type: 'url', url: 'https://example.com/paris', title: 'Paris', startIndex: 0, endIndex: 5 }],
});

Emitted per provider wire format:

  • OpenAI Responses: url_citation (and file_citation) entries in output_text.annotations, plus response.output_text.annotation.added events when streaming
  • Chat Completions: message.annotations / delta.annotations (url_citation)
  • Anthropic: citations on text blocks (citations_delta when streaming)
  • Gemini: groundingMetadata.groundingChunks / groundingSupports

Use case

Mastra is moving its agent-loop regression tests from hand-written mock models to aimock scenarios; source/citation propagation is one of the few behaviours we can't currently cover.

Activity

  1. jpr5 commented on Oct 21, 2026

    @jpr5
    Contributor

    Your PR #550 covers Responses citations. It just needs the two changes from review: rename the new file type so it doesn't clash with FixtureFile, and keep Gemini files on the combined content + tool-call responses. Once that's in, I'll leave this open for the other providers.

  2. jpr5 commented on Oct 23, 2026

    @jpr5
    Contributor

    Reopening — #550 shipped citations for the Responses API only. Chat Completions, Anthropic and Gemini are next.

  3. reopened this on Oct 23, 2026
  4. added a commit that references this issue on Oct 23, 2026
    16db8dc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions