Skip to content

fix(examples-chat): use Pandoc citation refs so inline markers link#221

Merged
blove merged 1 commit into
mainfrom
claude/examples-chat-citation-syntax-fix
May 9, 2026
Merged

fix(examples-chat): use Pandoc citation refs so inline markers link#221
blove merged 1 commit into
mainfrom
claude/examples-chat-citation-syntax-fix

Conversation

@blove
Copy link
Copy Markdown
Contributor

@blove blove commented May 9, 2026

Summary

Live smoke (post Phase 2B merge in #220) surfaced Finding G: chat-streaming-md rendered the assistant's response with plain [1], [2] text markers and a fully-populated Sources panel below — but the inline markers were not clickable links to the sources. They rendered as raw text.

Root cause

@cacheplane/partial-markdown recognises Pandoc-style [^refId] citation syntax, not plain [N] numerical markers. The Phase 2B system prompt instructed the model to emit [1], [2], etc., which the parser ignored — so <chat-md-citation-reference> elements were never generated despite the citations registry being correctly wired.

Fix

Update the python graph's system prompt and the Angular welcome suggestion to instruct Pandoc-style [^doc-id] syntax, using the document id field returned by the search_documents tool (e.g. [^ng-signals-overview], [^ng-control-flow]). Each first-use of a document gets an auto-numbered marker; subsequent references to the same document share the number.

The Message.citations shape produced by attach_citations already carries each document's id as the citation's id field, which CitationsResolverService.lookup(refId) matches against — so the resolver finds the citation by document id and renders the marker as a clickable <a> link to the source URL.

Test plan

Verified locally

  • nx run examples-chat-python:smoke — 4 passed
  • nx run examples-chat-angular:build — succeeds (development)
  • Server-side probe: submit the welcome suggestion to gpt-5-mini. Raw AI text contains 17 [^doc-id] markers (3 unique: ng-signals-overview, ng-signals-rxjs, ng-control-flow); 0 plain [N] markers.

Pending visual verification

  • After merge: live smoke against the workspace examples/chat demo. Inline [N] superscript markers in the assistant's response link to the Sources panel; hovering shows the citation snippet; clicking opens the source URL.

…s link

The chat-streaming-md component renders citation references via
@cacheplane/partial-markdown, which recognises Pandoc-style [^refId]
syntax. The previous system prompt instructed the model to emit plain
[1], [2] markers, which render as plain text and don't link to the
sources panel.

Live smoke (post Phase 2B merge) confirmed the issue: chat-message
showed plain [1] in the body with the Sources panel rendered below,
but inlineRefs (chat-md-citation-reference elements) was 0.

System prompt + welcome suggestion now instruct the model to use
[^doc-id] with the document id field returned by the search tool.
Server-side probe confirms the model emits 17 markers across 3
unique document ids per response, and 0 plain [N] markers.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@vercel
Copy link
Copy Markdown

vercel Bot commented May 9, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
cacheplane Ready Ready Preview, Comment May 9, 2026 2:21am

Request Review

@blove blove merged commit 794c914 into main May 9, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant