Skip to content

.Net: Fix Gemini Auto Invoke when returned function is non-first part #12174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

ionite34
Copy link

@ionite34 ionite34 commented May 19, 2025

Motivation and Context

Fixes #11651

  • Currently Gemini Connectors will not Auto invoke functions when tool calls are returned in the same message with text parts, which is common with 2.5 Flash and Pro models:
"content": {
  "parts": [
    {
      "text": "Running the TimePlugin.Now function..."
    },
    {
      "functionCall": {
        "name": "TimePlugin.Now",
        "args": {
          "param1": "hello"
        }
      }
    }
  ],
  "role": "model"
}

This fixes this to now support auto kernel functions with this behavior and adds unit tests with this data.

Description

  • Added unit test data for streaming responses with text & tool parts
  • Changed GetChatMessageContentFromCandidate to return tools from all candidate parts instead of only the first part
  • Added extra check in GenerateChatMessageAsync for empty Tool results
  • Fixed stream responses in auto invoke mode with texts & tool parts not returned to the caller, added unit test

Contribution Checklist

@ionite34 ionite34 requested a review from a team as a code owner May 19, 2025 19:43
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels May 19, 2025
@github-actions github-actions bot changed the title Fix Gemini Auto Invoke when returned function is non-first part .Net: Fix Gemini Auto Invoke when returned function is non-first part May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kernel Issues or pull requests impacting the core kernel .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.Net: Bug: Function calling fails when Gemini returns function call as non-first part
2 participants