Skip to content

fix(openai): correct web citation grounding metadata - #388

Merged
cpsievert merged 2 commits into
mainfrom
fix/openai-grounded-span-citations
Aug 13, 2026
Merged

fix(openai): correct web citation grounding metadata#388
cpsievert merged 2 commits into
mainfrom
fix/openai-grounded-span-citations

Conversation

@cpsievert

Copy link
Copy Markdown
Collaborator

Why this matters

OpenAI web-search annotations locate inline URL citation markers, not the answer claims that the sources support. This change prevents chatlas from exposing a Markdown source link as ContentCitation.grounded_span.

What changes

  • Preserve OpenAI citation URLs, titles, and raw annotation metadata while leaving grounded_span unset in streaming and finalized turns.
  • Strengthen VCR coverage around the actual marker offsets.

Verification

  • uv run pytest tests/test_provider_openai.py -k web_search -q
  • uv run ruff check chatlas/_provider_openai.py tests/test_provider_openai.py

@cpsievert
cpsievert force-pushed the fix/openai-grounded-span-citations branch from f6d355a to d84307d Compare August 12, 2026 17:25
@cpsievert
cpsievert marked this pull request as ready for review August 13, 2026 14:48
@cpsievert
cpsievert requested a lite review from Copilot August 13, 2026 15:21

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR corrects how OpenAI web-search URL citation annotations are surfaced by treating OpenAI’s start_index/end_index as offsets for the inline citation marker (not the grounded answer claim), and therefore leaving ContentCitation.grounded_span unset while preserving raw annotation metadata.

Changes:

  • Stop deriving grounded_span from OpenAI URL citation annotation offsets on finalized turns; keep the raw annotation payload in ContentCitation.extra.
  • Clarify streaming behavior/comments to reflect that OpenAI offsets delimit the inline marker, not grounded answer text.
  • Update VCR tests to validate marker offsets/URL presence via extra, and assert grounded_span remains None for OpenAI web-search citations (streaming and non-streaming).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
chatlas/_provider_openai.py Preserves OpenAI URL citation metadata in extra and stops populating grounded_span from URL citation offsets.
tests/test_provider_openai.py Adjusts web-search citation assertions to validate marker offsets via extra and ensures grounded_span is unset.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@cpsievert
cpsievert merged commit aed6e5e into main Aug 13, 2026
7 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.

2 participants