From fd981da0f87b0fe6fb41061fa9633a2dbe55a6c5 Mon Sep 17 00:00:00 2001 From: Dmytro Struk <13853051+dmytrostruk@users.noreply.github.com> Date: Wed, 4 Mar 2026 13:24:53 -0800 Subject: [PATCH] Fixed CA1873 warning (#4479) --- .../Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs index 7db4eff6d8..e4b772160e 100644 --- a/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs +++ b/dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs @@ -747,9 +747,15 @@ public sealed partial class ChatClientAgent : AIAgent { // The agent has a ChatHistoryProvider configured, but the service returned a conversation id, // meaning the service manages chat history server-side. Both cannot be used simultaneously. - if (this._agentOptions?.WarnOnChatHistoryProviderConflict is true) + if (this._agentOptions?.WarnOnChatHistoryProviderConflict is true + && this._logger.IsEnabled(LogLevel.Warning)) { - this._logger.LogAgentChatClientHistoryProviderConflict(nameof(ChatClientAgentSession.ConversationId), nameof(this.ChatHistoryProvider), this.Id, this.GetLoggingAgentName()); + var loggingAgentName = this.GetLoggingAgentName(); + this._logger.LogAgentChatClientHistoryProviderConflict( + nameof(ChatClientAgentSession.ConversationId), + nameof(this.ChatHistoryProvider), + this.Id, + loggingAgentName); } if (this._agentOptions?.ThrowOnChatHistoryProviderConflict is true)