From 522637759958591caa745cdd8ce2e96ec5a8edde Mon Sep 17 00:00:00 2001 From: Jacob Alber Date: Thu, 28 May 2026 17:06:04 -0400 Subject: [PATCH] fix: Revert logic change and add comments --- .../WorkflowSession.cs | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs index 0f828b8f8e..812bda1150 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs @@ -522,14 +522,18 @@ internal sealed class WorkflowSession : AgentSession case AgentResponseEvent agentResponse: // Under Futures.EnableAgentResponseOutputTaggingAndFiltering=true, mirror // AgentResponseUpdateEvent's behavior: always forward, regardless of the - // _includeWorkflowOutputsInResponse host flag. Under the legacy default, - // keep today's behavior — gated by the include flag. - if ((Futures.EnableAgentResponseOutputTaggingAndFiltering && !agentResponse.IsIntermediate()) || - (!Futures.EnableAgentResponseOutputTaggingAndFiltering && !this._includeWorkflowOutputsInResponse)) + // _includeWorkflowOutputsInResponse host flag / "intermediate" tag. Under + // the legacy default, keep today's behavior — gated by the include flag. + if (!Futures.EnableAgentResponseOutputTaggingAndFiltering && !this._includeWorkflowOutputsInResponse) { goto default; } + // Either EnableAgentResponseOutputTaggingAndFiltering -- so yield the Response + // regardless of whether it is tagged "intermediate" or whether the + // _includeWorkflowOutputInResponse flag is set. Reason being: The user specifies + // exclusion of an event by enabling filtering and then _not_ marking an Executor + // as an output executor. foreach (ChatMessage message in agentResponse.Response.Messages) { yield return this.CreateUpdate(this.LastResponseId, evt, message); @@ -544,11 +548,11 @@ internal sealed class WorkflowSession : AgentSession _ => null }; - // Same gating asymmetry as AgentResponseEvent: intermediate outputs are - // forwarded unconditionally; terminal/untagged outputs require the host - // to opt in via _includeWorkflowOutputsInResponse. - if (updateMessages == null || - (!output.IsIntermediate() && !this._includeWorkflowOutputsInResponse)) + // Same assymetry as with AgentResponseEvent, but there is no EnableFiltering flag + // to consider. If this made it here (and since it is not an AgentResponse[Update]), + // it means it is already been selected as an Output() from the user. Intermediate + // is irrelevant here. + if (updateMessages == null || !this._includeWorkflowOutputsInResponse) { goto default; }