Skip to content

.Net: Add Support for {Azure}OpenAIPromptExecutionSettings.ChatSystem/DeveloperPrompt for ChatClients #12619

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 4 commits into
base: main
Choose a base branch
from

Conversation

rogerbarreto
Copy link
Member

@rogerbarreto rogerbarreto self-assigned this Jun 27, 2025
@rogerbarreto rogerbarreto requested a review from a team as a code owner June 27, 2025 21:56
@rogerbarreto rogerbarreto added .NET Issue or Pull requests regarding .NET code ai connector Anything related to AI connectors msft.ext.ai Related to Microsoft.Extensions.AI labels Jun 27, 2025
@markwallace-microsoft markwallace-microsoft added kernel Issues or pull requests impacting the core kernel kernel.core labels Jun 27, 2025
Comment on lines +553 to +558
if (!string.IsNullOrWhiteSpace(this.ChatDeveloperPrompt) && !chatHistory.Any(m => m.Role == AuthorRole.Developer))
{
chatHistory.Insert(0, new ChatMessageContent(AuthorRole.Developer, this.ChatDeveloperPrompt));
}

if (!string.IsNullOrWhiteSpace(this.ChatSystemPrompt) && !chatHistory.Any(m => m.Role == AuthorRole.System))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Doing chatHistory.Any() twice will iterate through chatHistory two times, while only one iteration is needed to find if Developer and/or System messages exist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ai connector Anything related to AI connectors kernel.core kernel Issues or pull requests impacting the core kernel msft.ext.ai Related to Microsoft.Extensions.AI .NET Issue or Pull requests regarding .NET code
Projects
None yet
Development

Successfully merging this pull request may close these issues.

.Net: Bug: ChatSystemPrompt not applied in AddAzureOpenAIChatClient
4 participants