semantic-kernel icon indicating copy to clipboard operation
semantic-kernel copied to clipboard

.Net: Fix #13262: GeminiRequest to handle single turn requests correctly

Open icyca opened this issue 1 month ago • 3 comments

Updated the CreateGeminiRequest to ensure that single turn requests end with a "user" role or no role

Motivation and Context

  1. The fix is required since Gemini API rejects single turn requests ending with "model" role, but orchestration passes agent responses directly to next agents.
  2. Fixes orchestration workflows with Gemini models that fail after the first agent with HTTP 400 error.
  3. It contributes to multi-agent orchestration workflows using Gemini models.
  4. Fixes: https://github.com/microsoft/semantic-kernel/issues/13262

Description

Removes role from single assistant messages in Gemini requests (Gemini treats no role as user input). Only affects Gemini connector, preserves multi-turn conversations, no breaking changes. Basically this is a specific case solution to keep Gemini API satisfied.

Contribution Checklist

icyca avatar Oct 23 '25 11:10 icyca

@icyca this PR is still a draft, are you still working on it?

markwallace-microsoft avatar Nov 03 '25 12:11 markwallace-microsoft

@markwallace-microsoft No, it is done. I just had it as draft in case it needed further discussion. I will publish it now

icyca avatar Nov 03 '25 13:11 icyca

@markwallace-microsoft added unit tests

icyca avatar Nov 10 '25 19:11 icyca