.NET: Alliscode/fix declarative autosend output#7217
Open
alliscode wants to merge 3 commits into
Open
Conversation
Restore completed responses for workflow-conversation agents while preventing hosted workflow adapters from materializing streamed responses twice. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2d86826-ead0-40bc-b84b-a513ac4d325f
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2d86826-ead0-40bc-b84b-a513ac4d325f
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves streaming response correlation in the .NET workflow stack by (1) generating stable MessageIds for streaming updates that lack them, and (2) avoiding duplicated content when forwarding completion events after content was already streamed.
Changes:
- Assign stable
MessageIdvalues across related streamingAgentResponseUpdates inAIAgentHostExecutorand declarativeAgentProviderExtensions. - Track streamed message IDs in
WorkflowSessionand suppress duplicate completion content, while still emitting an “observable” completion event with empty contents. - Expand/update unit tests to validate stable
MessageIdpropagation, auto-send behavior, and completion-event emission without duplication.
Show a summary per file
| File | Description |
|---|---|
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs | Updates smoke tests to assert completion events remain observable without duplicating streamed text; adds scenarios around suppression boundaries. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AIAgentHostExecutorTests.cs | Adds coverage ensuring the executor assigns one stable MessageId across streaming updates and propagates it to the completed response. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/SendActivityExecutorTest.cs | Verifies SendActivityExecutor propagates MessageId/ResponseId consistently into update + response events. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/ObjectModel/InvokeAzureAgentExecutorTest.cs | Adds tests for autoSend defaulting to true and honoring explicit values for event emission. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.UnitTests/Extensions/AgentProviderExtensionsTest.cs | Adjusts test updates to use ChatResponseUpdate and asserts stable generated MessageId across events/response. |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowSession.cs | Tracks streamed message IDs and avoids duplicating already-streamed message content during completion forwarding. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/AIAgentHostExecutor.cs | Generates stable MessageId for streaming updates (per response/role) when missing. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/ObjectModel/SendActivityExecutor.cs | Ensures SendActivity emits update + response with consistent MessageId/ResponseId. |
| dotnet/src/Microsoft.Agents.AI.Workflows.Declarative/Extensions/AgentProviderExtensions.cs | Generates stable MessageId for declarative streaming updates when missing. |
Review details
- Files reviewed: 9/9 changed files
- Comments generated: 2
- Review effort level: Low
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: c2d86826-ead0-40bc-b84b-a513ac4d325f
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces improvements to how message IDs are assigned and handled for streaming agent responses, ensuring that all related updates share a stable identifier and that completion events do not duplicate content. It also adds and updates tests to verify the correct assignment and propagation of message and response IDs, and corrects the emission of completion events in streaming workflows.
Stable Message ID Assignment and Propagation:
Streaming agent response updates now receive a stable
MessageIdthat is reused for all updates belonging to the same logical message, ensuring consistent identification across updates. This applies both inAgentProviderExtensions.InvokeAgentAsyncandAIAgentHostExecutor. [1] [2]The
SendActivityExecutornow assigns bothMessageIdandResponseIdto messages and updates, and ensures these are correctly propagated through all related events.Workflow Session and Completion Event Handling:
Test Enhancements and Coverage:
MessageId, and that response events reference the correct IDs. New tests also ensure that auto-send behavior is correctly honored and that completion events are emitted as expected without content duplication. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10]Test Infrastructure and Mocking:
MessageIdscenarios and to validate the new stable message ID logic.Minor Code Cleanups:
using System;directives in relevant files. [1] [2]These changes collectively improve the reliability and clarity of agent response streaming, making it easier to track and correlate updates and final responses throughout the workflow system.
Contribution Checklist
breaking changelabel (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.