fix(openai): correct web citation grounding metadata - #388
Merged
Conversation
cpsievert
force-pushed
the
fix/openai-grounded-span-citations
branch
from
August 12, 2026 17:25
f6d355a to
d84307d
Compare
cpsievert
marked this pull request as ready for review
August 13, 2026 14:48
Contributor
There was a problem hiding this comment.
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_spanfrom OpenAI URL citation annotation offsets on finalized turns; keep the raw annotation payload inContentCitation.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 assertgrounded_spanremainsNonefor 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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
grounded_spanunset in streaming and finalized turns.Verification
uv run pytest tests/test_provider_openai.py -k web_search -quv run ruff check chatlas/_provider_openai.py tests/test_provider_openai.py