Skip to content

fix(google): grounding streaming sources #7226

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jul 15, 2025
Merged

fix(google): grounding streaming sources #7226

merged 6 commits into from
Jul 15, 2025

Conversation

dancer
Copy link
Collaborator

@dancer dancer commented Jul 11, 2025

background

Google Grounding with Gemini was only emitting sources at the end of streaming when finishReason was present, not during the streaming process as they became available. Users reported sources appearing in Google's events during streaming but the AI SDK wasn't processing them until completion.

summary

  • fix google grounding sources to stream during generation
  • sources now emit immediately when grounding metadata is available

verification

  • all tests pass
  • sources appear during streaming
  • grounding metadata accessible in provider metadata

tasks

  • process grounding sources immediately when available
  • test for chunk streaming

related issue #7063

@dancer dancer marked this pull request as ready for review July 11, 2025 12:26
@lgrammel
Copy link
Collaborator

How do we ensure that the sources are not duplicated? might be good to test with duplicated sources and keep track of them in a set. If duplicate sources come we dont send it (sources are different from citations which are future work)

@patelvivekdev
Copy link
Contributor

@dancer, can you also include changes from #7183

Currently, when using url-context in streaming, we don't get urlContextMetadata in providerOptions.

@lgrammel
Copy link
Collaborator

please add a changeset

@lgrammel
Copy link
Collaborator

@dancer, can you also include changes from #7183

Currently, when using url-context in streaming, we don't get urlContextMetadata in providerOptions.

ideally this should be a separate fix / pr

@lgrammel lgrammel changed the title fix(google): grounding sse streaming sources fix(google): grounding streaming sources Jul 15, 2025
@dancer dancer merged commit 7badba2 into main Jul 15, 2025
9 checks passed
@dancer dancer deleted the js/grounding branch July 15, 2025 08:40
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.

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy