Skip to content

fix(google): keep streamed citations adjacent to text - #385

Merged
cpsievert merged 5 commits into
mainfrom
fix/google-grounded-citations
Aug 13, 2026
Merged

fix(google): keep streamed citations adjacent to text#385
cpsievert merged 5 commits into
mainfrom
fix/google-grounded-citations

Conversation

@cpsievert

@cpsievert cpsievert commented Aug 12, 2026

Copy link
Copy Markdown
Collaborator

Why this matters

Google can report URL fetch activity before final grounding metadata arrives. Streaming that activity immediately separates citations from their answer paragraph, so clients such as Shiny Chat cannot highlight the provider-grounded claim.

What changes

  • Continue streaming answer text without buffering.
  • Emit Google citations before deferred search and fetch activity once the final metadata-bearing chunk arrives.
  • Cover search-only and early-fetch stream ordering while preserving final-turn ordering and provider-supplied grounded spans.
  • Temporarily cap OpenAI below 3.0 and regenerate its client argument types because OpenAI 3 switched to httpx2 while chatlas provider adapters still accept httpx clients.

Verification

  • UV_CACHE_DIR=/tmp/chatlas-uv-cache uv run pytest tests/test_provider_google.py -k "grounding or web_search or web_fetch" -q
  • UV_CACHE_DIR=/tmp/chatlas-uv-cache uv run pyright
  • UV_CACHE_DIR=/tmp/chatlas-uv-cache uv run ruff check chatlas/_provider_google.py tests/test_provider_google.py
  • A fresh Python 3.12 dependency sync plus regenerated provider types passes Pyright with OpenAI 2.54.0.
  • A live Gemini 2.5 Flash request in Shiny Chat confirmed citations precede late search/fetch activity and the fetch completes successfully.

@cpsievert
cpsievert marked this pull request as ready for review August 12, 2026 03:47
@cpsievert
cpsievert force-pushed the fix/google-grounded-citations branch from 5222d37 to f3041c5 Compare August 12, 2026 17:26
@cpsievert
cpsievert merged commit 66745dd 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.

1 participant