Repository navigation
.Net: Fix Gemini function-response message role - #14585
Open
Mikita (lil-kita) wants to merge 1 commit into
Open
Mikita (lil-kita) wants to merge 1 commit into
Mikita (lil-kita) wants to merge 1 commit into
Conversation
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Mikita (lil-kita)
temporarily deployed
to
github-app-auth
October 13, 2026 12:59 — with
GitHub Actions
Inactive
Mikita (lil-kita)
temporarily deployed
to
github-app-auth
October 13, 2026 12:59 — with
GitHub Actions
Inactive
Author
|
@microsoft-github-policy-service agree |
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
The focused protocol correction is consistent across both serialization paths and is adequately covered by regression tests.
0 open findings
What changed in this PR
Corrects Gemini tool-response serialization to use the supported "user" wire role while retaining internal tool semantics.
Changes:
- Maps
AuthorRole.Toolto"user"during serialization. - Expands generation and streaming regression coverage.
- Verifies batched, successive, and thought-signature tool rounds.
| File | Description |
|---|---|
AuthorRoleConverter.cs |
Corrects tool-role serialization. |
GeminiRequestTests.cs |
Verifies serialized function responses. |
GeminiChatStreamingFunctionCallingTests.cs |
Updates streaming wire-role expectations. |
GeminiChatGenerationFunctionCallingTests.cs |
Covers generation, batching, successive rounds, and signatures. |
AuthorRoleConverterTests.cs |
Updates converter expectations. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
This branch was previously deployed
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
The .NET Google connector serializes
AuthorRole.Toolasrole: "function"when sending function results back to Gemini. The Gemini generateContent API definesContent.roleas"user"or"model"; function results should be carried by a"user"message containingfunctionResponseparts.With automatic function invocation, the initial request can succeed and the local function can execute, but the continuation request is rejected with:
This can leave an action completed locally without a final model response. Requests that do not invoke functions do not encounter this tool-result serialization path.
API references:
Minimal reproduction:
GeminiToolCallBehavior.AutoInvokeKernelFunctions.role: "function"instead ofrole: "user".Description
AuthorRole.Toolas"user"in the shared Gemini role converter.functionResponsepayloads."function"deserialization unchanged.The fix applies to the shared Google AI and Vertex AI Gemini serialization path. It introduces no public API signatures, model-version conditions, retry behavior, dependency changes, or package metadata changes.
Validation
Verified the bug-fix-only patch against upstream
mainat1b1f64b98c3828ada434d262c0e3038da6cc3508on Windows with .NET SDK10.0.401.git diff --check: passed.Commands run from the repository's
dotnetdirectory:TF_BUILD=truedisables the repository's automatic formatting-on-Release-build target; formatting was verified separately without modifying files.Contribution Checklist