Skip to content

Conversation

@icyca
Copy link
Contributor

@icyca icyca commented Oct 23, 2025

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: .Net: Bug: Gemini does not accept 'model' / assistant role as a last message in ChatHistory when pass over to the next agent. #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

…rectly

Updated the `CreateGeminiRequest` to ensure that single turn requests end with a "user" role or no role
@markwallace-microsoft markwallace-microsoft added .NET Issue or Pull requests regarding .NET code kernel Issues or pull requests impacting the core kernel labels Oct 23, 2025
@github-actions github-actions bot changed the title Fix #13262: GeminiRequest to handle single turn requests correctly .Net: Fix #13262: GeminiRequest to handle single turn requests correctly Oct 23, 2025
@markwallace-microsoft
Copy link
Member

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

@icyca
Copy link
Contributor Author

icyca commented Nov 3, 2025

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

@icyca icyca marked this pull request as ready for review November 3, 2025 13:01
@icyca icyca requested a review from a team as a code owner November 3, 2025 13:01
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: Gemini does not accept 'model' / assistant role as a last message in ChatHistory when pass over to the next agent.

2 participants