Python: Fix Gemini harness tool declarations#7322
Open
scarab-systems wants to merge 1 commit into
Open
Conversation
Forward Agent Framework FunctionTool JSON Schemas to the Gemini SDK parameters_json_schema field and enable Developer API server-side tool invocation reporting when native Gemini tools are mixed with function declarations. Preserves Vertex AI behavior and existing function-calling tool_choice config. Validation: - uv run --directory python poe check -P gemini - uv run --directory python poe build -P gemini - uv run --directory python poe test -A -m 'not integration' - uv run --directory python pytest packages/gemini/tests/test_gemini_client.py -q -m integration (8 skipped: credential-gated)
scarab-systems
temporarily deployed
to
github-app-auth
July 26, 2026 03:12 — with
GitHub Actions
Inactive
scarab-systems
temporarily deployed
to
github-app-auth
July 26, 2026 03:12 — with
GitHub Actions
Inactive
scarab-systems
temporarily deployed
to
github-app-auth
July 26, 2026 03:12 — with
GitHub Actions
Inactive
scarab-systems
temporarily deployed
to
github-app-auth
July 26, 2026 03:13 — with
GitHub Actions
Inactive
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes Gemini (Developer API) tool-calling interoperability in the Python Gemini client so harness scenarios can combine native Gemini tools (e.g., Google Search grounding) with Agent Framework FunctionTools without request-prep validation failures or Gemini API rejections.
Changes:
- Forward full
FunctionToolJSON Schema viatypes.FunctionDeclaration.parameters_json_schema(instead of coercing into the SDK’sparametersSchema subset). - When using the Gemini Developer API and the request mixes native Gemini tools with function declarations, set
tool_config.include_server_side_tool_invocations = Truewhile preserving any existing function-calling configuration (tool_choice). - Add/extend Gemini client tests covering JSON Schema pass-through, mixed native/function tools behavior,
tool_choicepreservation, and Vertex AI non-impact.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| python/packages/gemini/agent_framework_gemini/_chat_client.py | Updates tool declaration building to use JSON Schema passthrough and conditionally enables Developer API server-side tool invocation reporting for mixed native/function tool requests. |
| python/packages/gemini/tests/test_gemini_client.py | Adds tests verifying JSON Schema forwarding, server-side tool invocation flag behavior for Developer API mixed-tool requests, tool_choice preservation, and unchanged Vertex AI behavior. |
scarab-systems
marked this pull request as ready for review
July 26, 2026 03:16
scarab-systems
temporarily deployed
to
github-app-auth
July 26, 2026 03:16 — with
GitHub Actions
Inactive
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 & Context
Fixes #6954.
Gemini Developer API calls can combine native Gemini tools, such as Google Search grounding, with Agent Framework function tools. That mixed-tool path needs Gemini's server-side tool invocation reporting enabled so native tool calls are returned alongside function calls.
Function tool schemas also need to be forwarded through the Gemini SDK's JSON Schema field so richer Agent Framework tool schemas are preserved instead of being coerced into the SDK
Schemasubset.Disclosure: This PR was prepared with AI assistance under human direction and review.
Description & Review Guide
FunctionToolschemas throughparameters_json_schemawhen building Gemini function declarations.include_server_side_tool_invocationsfor Gemini Developer API requests that mix native Gemini tools with function declarations.tool_choice/ function-calling configuration when adding that Developer API flag.tool_choice, and Vertex AI behavior.Related Issue
Fixes #6954
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) -- a workflow keeps the label and title prefix in sync automatically.