Skip to content
Source
Sign inSign up
TanStack/ai

feat(ai): normalize provider-executed web search sources for OpenAI and Gemini #1376

Mergedmikemikimike(GitHub profile, opens in a new tab)merged 14 commits intomain fromrefs/pull/1376/headmerged by AlemTuzlak View on GitHub

Showing 17 changed files with 20 additions and 0 deletions (loading 13).

x
0 of 17 viewed, 17 left
8 additions and 0 deletions.changeset/preserve-provider-search-sources.mdAdded
View file
@@ -0,0 +1,8 @@
+---
+'@tanstack/ai': minor
+'@tanstack/openai-base': minor
+'@tanstack/ai-openai': minor
+'@tanstack/ai-gemini': minor
+---
+​
+Preserve source links for hosted web search calls. OpenAI Responses `web_search_call` items and Gemini Google Search grounding now surface as provider-executed tool calls with a normalized `metadata.sources` array (new `ProviderExecutedToolSource` type) and the raw provider data under `metadata.openai` / `metadata.gemini`. The OpenAI adapter requests `web_search_call.action.sources` when a branded web search tool is used, and both adapters replay the raw items on the next turn instead of treating them as function calls.
6 additions and 0 deletionsdocs/adapters/gemini.mdModified
View file
@@ -825,6 +825,12 @@
​
**Supported models:** Gemini 1.5 Pro, Gemini 2.x, Gemini 2.5. See [Provider Tools](../tools/provider-tools.md#which-models-support-which-tools).
​
+When Google Search returns grounding data, the assistant tool-call part
+includes `metadata.providerExecuted: true` and the normalized
+`metadata.sources` array. Gemini's raw `groundingMetadata` stays under
+`metadata.gemini`. The agent loop does not execute this call in your
+application.
+​
### `googleSearchRetrievalTool`
​
A retrieval-augmented variant of Google Search that returns ranked passages
6 additions and 0 deletionsdocs/adapters/openai.mdModified
View file
@@ -534,6 +534,12 @@
​