Skip to content

Conversation

ionite34
Copy link
Contributor

@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
@rogerbarreto rogerbarreto added this pull request to the merge queue Jun 5, 2025
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Jun 5, 2025
@rogerbarreto rogerbarreto added this pull request to the merge queue Jun 5, 2025
Merged via the queue into microsoft:main with commit 4e40f39 Jun 5, 2025
19 checks passed
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
4 participants