From 9ab50903b072e33b5a49ac543fdb20879e870a95 Mon Sep 17 00:00:00 2001 From: Ben Thomas <25218250+alliscode@users.noreply.github.com> Date: Wed, 22 Jul 2026 10:56:08 -0700 Subject: [PATCH 1/3] .NET: Guard workflow warning logging Avoid unnecessary structured logging argument evaluation when warning logging is disabled, resolving CA1873 in release builds. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0bc01e26-22ba-42ce-ac1e-6fe166500f4f --- .../HostedWorkflowState.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs b/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs index 8c66046d231..429fc7d8422 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs @@ -362,11 +362,16 @@ private void UpdateCursor(string sessionId, CheckpointInfo? checkpoint) } private void WarnOnNoProgress(string sessionId) + { // The resumed turn drove no work: the checkpoint may be stale or the input may not match the workflow's // expected type, so the session's state may not have progressed. - => this._logger.LogWarning( - "Resuming workflow session '{SessionId}' produced no events; the checkpoint may be stale or the input may not match the workflow's expected input type. Session state may not have progressed.", - sessionId); + if (this._logger.IsEnabled(LogLevel.Warning)) + { + this._logger.LogWarning( + "Resuming workflow session '{SessionId}' produced no events; the checkpoint may be stale or the input may not match the workflow's expected input type. Session state may not have progressed.", + sessionId); + } + } /// /// Gets the recorded head checkpoint for , if any. From 329faeb5d6c23165005fc3f6acfb7d5ebb00bca9 Mon Sep 17 00:00:00 2001 From: Ben Thomas <25218250+alliscode@users.noreply.github.com> Date: Wed, 22 Jul 2026 11:33:17 -0700 Subject: [PATCH 2/3] .NET: Use generated workflow logging Align the no-progress warning with the repository-standard LoggerMessage source generator pattern. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 0bc01e26-22ba-42ce-ac1e-6fe166500f4f --- .../HostedWorkflowState.cs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs b/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs index 429fc7d8422..5e8c4b2b989 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs @@ -362,16 +362,9 @@ private void UpdateCursor(string sessionId, CheckpointInfo? checkpoint) } private void WarnOnNoProgress(string sessionId) - { // The resumed turn drove no work: the checkpoint may be stale or the input may not match the workflow's // expected type, so the session's state may not have progressed. - if (this._logger.IsEnabled(LogLevel.Warning)) - { - this._logger.LogWarning( - "Resuming workflow session '{SessionId}' produced no events; the checkpoint may be stale or the input may not match the workflow's expected input type. Session state may not have progressed.", - sessionId); - } - } + => this._logger.LogWorkflowResumeMadeNoProgress(sessionId); /// /// Gets the recorded head checkpoint for , if any. @@ -388,3 +381,11 @@ internal bool TryGetCheckpoint(string sessionId, out CheckpointInfo? checkpoint) return this._cursor.TryGetValue(sessionId, out checkpoint); } } + +internal static partial class HostedWorkflowStateLogMessages +{ + [LoggerMessage( + Level = LogLevel.Warning, + Message = "Resuming workflow session '{SessionId}' produced no events; the checkpoint may be stale or the input may not match the workflow's expected input type. Session state may not have progressed.")] + public static partial void LogWorkflowResumeMadeNoProgress(this ILogger logger, string sessionId); +} From 694275f26006d8763c4b6bbd341023e5b7c9e5fb Mon Sep 17 00:00:00 2001 From: Ben Thomas Date: Wed, 22 Jul 2026 13:15:12 -0700 Subject: [PATCH 3/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs b/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs index 5e8c4b2b989..8887cef6135 100644 --- a/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs +++ b/dotnet/src/Microsoft.Agents.AI.Hosting/HostedWorkflowState.cs @@ -382,6 +382,7 @@ internal bool TryGetCheckpoint(string sessionId, out CheckpointInfo? checkpoint) } } +[System.Diagnostics.CodeAnalysis.ExcludeFromCodeCoverage] internal static partial class HostedWorkflowStateLogMessages { [LoggerMessage(