Python: Fix Gemini client support for Gemini API and Vertex AI#5258
Open
eavanvalkenburg wants to merge 4 commits intomicrosoft:mainfrom
Open
Python: Fix Gemini client support for Gemini API and Vertex AI#5258eavanvalkenburg wants to merge 4 commits intomicrosoft:mainfrom
eavanvalkenburg wants to merge 4 commits intomicrosoft:mainfrom
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
This PR updates the Python Gemini connector to support both google-genai connection modes (Gemini Developer API and Vertex AI), aligns environment variable handling with the SDK-style GOOGLE_* settings, and fixes tool/thinking metadata handling so the samples and tool loops behave correctly with newer Gemini models.
Changes:
- Add
GoogleGeminiSettingsand updateGeminiChatClient/RawGeminiChatClientto preferGOOGLE_*settings, support Vertex AI configuration, and resolve the service URL from the instantiatedgenai.Client. - Preserve
thought_signatureacross tool-call round trips and improve tool serialization to handle Pydantic tool models. - Refresh tests and sample docs to reflect the new configuration options and behaviors.
Reviewed changes
Copilot reviewed 14 out of 14 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| python/packages/gemini/agent_framework_gemini/_chat_client.py | Adds Google/Vertex settings, service URL resolution, Vertex AI options, and thought signature preservation in tool calls. |
| python/packages/gemini/agent_framework_gemini/init.py | Exports GoogleGeminiSettings from the package. |
| python/packages/gemini/tests/test_gemini_client.py | Adds env precedence and Vertex AI tests; updates integration-test skipping logic; adds thought_signature regression test. |
| python/packages/core/agent_framework/_tools.py | Extends tool serialization to support Pydantic BaseModel specs via model_dump(). |
| python/packages/core/tests/core/test_tools.py | Adds a regression test covering Pydantic tool spec serialization. |
| python/packages/gemini/samples/*.py | Updates sample prerequisites/comments and adds inline “Sample output” blocks. |
| python/packages/gemini/samples/README.md | Documents both Gemini Developer API and Vertex AI environment variable options and how to run samples. |
| python/packages/gemini/README.md | Documents both auth modes and corresponding env vars. |
| python/packages/gemini/AGENTS.md | Updates package description and lists GoogleGeminiSettings. |
| python/packages/gemini/samples/init.py | Adds copyright header. |
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Contributor
Python Test Coverage Report •
Python Unit Test Overview
|
||||||||||||||||||||||||||||||||||||||||
TaoChenOSU
reviewed
Apr 14, 2026
TaoChenOSU
reviewed
Apr 14, 2026
moonbox3
approved these changes
Apr 15, 2026
giles17
approved these changes
Apr 16, 2026
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.
Motivation and Context
This update fixes the Python Gemini connector so it works with both
google-genaiconnection modes: the Gemini Developer API and Vertex AI. It also addresses follow-up issues that showed up in the Gemini samples when switching models and when using Gemini built-in tools.Description
GeminiChatClientcan resolve either Gemini Developer API or Vertex AI configurationGOOGLE_*values lead when both namespaces are present, including support forGOOGLE_MODELthought_signaturedata across tool-call round trips so tool-enabled conversations continue to work with newer reasoning-capable modelsgoogle-genaiclient instead of hardcoding endpointsCan't parse tool.warningContribution Checklist