Skip to content

Add Gemini provider tools#1578

Merged
u9g merged 2 commits into
brian/provider-tool-basefrom
port-gemini-provider-tools
May 22, 2026
Merged

Add Gemini provider tools#1578
u9g merged 2 commits into
brian/provider-tool-basefrom
port-gemini-provider-tools

Conversation

@rosetta-livekit-bot
Copy link
Copy Markdown
Contributor

Summary

  • Port Python Google Gemini provider tools as GeminiTool subclasses: Google Search, Google Maps, URL context, File Search, code execution, and Vertex RAG retrieval
  • Serialize Gemini provider tools from ToolContext for Google LLM and realtime sessions
  • Keep legacy geminiTools config support and add a Google plugin changeset

Stacked on #1576.

Test plan

  • pnpm build:agents
  • pnpm --filter @livekit/agents-plugins-test build && pnpm --filter @livekit/agents-plugin-silero build && pnpm --filter @livekit/agents-plugin-openai build && pnpm --filter @livekit/agents-plugin-google build

Note: pnpm --filter @livekit/agents-plugin-google api:check currently fails on this branch with API Extractor rejecting the existing export-star-as-beta declaration syntax in dist/index.d.ts.

@changeset-bot
Copy link
Copy Markdown

changeset-bot Bot commented May 21, 2026

🦋 Changeset detected

Latest commit: b9cb3a7

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 31 packages
Name Type
@livekit/agents-plugin-google Major
@livekit/agents Major
@livekit/agents-plugin-anam Major
@livekit/agents-plugin-assemblyai Major
@livekit/agents-plugin-baseten Major
@livekit/agents-plugin-bey Major
@livekit/agents-plugin-cartesia Major
@livekit/agents-plugin-cerebras Major
@livekit/agents-plugin-deepgram Major
@livekit/agents-plugin-elevenlabs Major
@livekit/agents-plugin-fishaudio Major
@livekit/agents-plugin-hedra Major
@livekit/agents-plugin-hume Major
@livekit/agents-plugin-inworld Major
@livekit/agents-plugin-lemonslice Major
@livekit/agents-plugin-liveavatar Major
@livekit/agents-plugin-livekit Major
@livekit/agents-plugin-minimax Major
@livekit/agents-plugin-mistral Major
@livekit/agents-plugin-mistralai Major
@livekit/agents-plugin-neuphonic Major
@livekit/agents-plugin-openai Major
@livekit/agents-plugin-phonic Major
@livekit/agents-plugin-resemble Major
@livekit/agents-plugin-rime Major
@livekit/agents-plugin-runway Major
@livekit/agents-plugin-sarvam Major
@livekit/agents-plugin-silero Major
@livekit/agents-plugin-trugen Major
@livekit/agents-plugin-xai Major
@livekit/agents-plugins-test Major

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 5 additional findings.

Open in Devin Review

Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 6 additional findings in Devin Review.

Open in Devin Review

Comment on lines +192 to +206
if (geminiTools !== undefined) {
providerTools.push(geminiTools);
}

if (toolCtx) {
for (const tool of toolCtx.providerTools) {
if (tool instanceof GeminiTool) {
providerTools.push(tool.toToolConfig());
}
}
}

if (tools.length > 0 && providerTools.length > 0) {
throw new Error('Gemini does not support mixing function tools and provider tools');
}
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.

🔴 Regression: geminiTools combined with function tools now throws instead of merging into a single Tool object

The old code in buildConnectConfig merged geminiTools (e.g., {googleSearch: {}}) and functionDeclarations into a single Tool object via the spread operator: [{ functionDeclarations: [...], ...this.options.geminiTools }]. The new toToolsConfig function treats geminiTools as a separate "provider tool" (plugins/google/src/utils.ts:192-193) and then throws an error at plugins/google/src/utils.ts:204-206 if both function declarations and provider tools are present. This breaks any existing user who configures both geminiTools (e.g., {googleSearch: {}}) and function tools in a realtime session — a combination that worked before and is valid in the Google API (a single Tool object can contain both functionDeclarations and other tool types like googleSearch). The fix should merge geminiTools into the function declarations Tool object (matching the old behavior) rather than pushing it into the separate providerTools array.

Prompt for agents
The toToolsConfig function in plugins/google/src/utils.ts incorrectly treats the geminiTools option as a separate provider tool, causing a runtime error when users combine geminiTools (e.g. {googleSearch: {}}) with function tools. The old behavior in plugins/google/src/beta/realtime/realtime_api.ts merged geminiTools into the same Tool object as functionDeclarations using spread: [{functionDeclarations: [...], ...geminiTools}].

The fix: instead of pushing geminiTools into the providerTools array (line 192-194), merge it into the function declarations Tool object when function declarations exist, or push it as a standalone Tool when no function declarations are present. This maintains backward compatibility while still throwing when new GeminiTool provider tool instances (from toolCtx.providerTools) are mixed with function tools.

Approach: When building the function declarations Tool object (lines 177-189), spread geminiTools into it (similar to the old realtime code). Remove the geminiTools push from providerTools (line 192-194). If there are no function declarations but geminiTools is defined, push it as a standalone Tool object in the tools array.
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@u9g u9g merged commit d05b896 into brian/provider-tool-base May 22, 2026
2 checks passed
@u9g u9g deleted the port-gemini-provider-tools branch May 22, 2026 18:16
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