Skip to content

Conversation

TaoChenOSU
Copy link
Contributor

@TaoChenOSU TaoChenOSU commented Oct 13, 2025

Motivation and Context

Addressed #1137

Description

Use the ToAgentRunResponse extension method to assemble streaming updates into fully-formed updates. This will avoid unintended bugs caused by differences between underlying clients/services driving the agents.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

@TaoChenOSU TaoChenOSU self-assigned this Oct 13, 2025
@Copilot Copilot AI review requested due to automatic review settings October 13, 2025 20:50
@TaoChenOSU TaoChenOSU added .NET workflows Related to Workflows in agent-framework labels Oct 13, 2025
@github-actions github-actions bot changed the title AIAgentHostExecutor to use ToAgentRunResponse .NET: AIAgentHostExecutor to use ToAgentRunResponse Oct 13, 2025
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors the AIAgentHostExecutor to use the ToAgentRunResponse extension method for processing streaming agent updates. The change simplifies the complex manual aggregation logic that was previously used to assemble streaming updates into complete messages.

  • Replaces manual message aggregation with a standardized extension method approach
  • Simplifies streaming update processing by collecting all updates before transforming them
  • Updates corresponding unit tests to reflect the simplified message handling structure

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
AIAgentHostExecutor.cs Refactored streaming message processing to use ToAgentRunResponse extension method, removing complex manual aggregation logic
SpecializedExecutorSmokeTests.cs Updated test structure to match simplified message handling, removing detailed content splitting verification

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.


currentStreamingMessage = null;
}
await context.SendMessageAsync(updates.ToAgentRunResponse().Messages, cancellationToken: cancellationToken).ConfigureAwait(false);
Copy link
Member

Choose a reason for hiding this comment

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

Note that the new M.E.AI build that should be out tomorrow updates the logic used by this to also factor in AuthorName for message boundary detection, which should help in the case where message ID isn't set but AuthorName is (and AuthorName is always set when using ChatClientAgent).

@lokitoth
Copy link
Member

This changes the logic of the resulting joined messages - they lose the initial splits as sent out by the agent in individual updates. We were keeping them around deliberately: I recall that fixing a bug that @crickman had with Declarative Workflows at one point (though the details elude me now).

Are we sure this behaviour change will not cause problems?

@stephentoub
Copy link
Member

they lose the initial splits as sent out by the agent in individual updates.

Can you elaborate on this?

@lokitoth
Copy link
Member

Can you elaborate on this?

Looks like I had outdated info - it used to be that when the AgentRunResponses were merged using the existing method in the AgentFramework they would merge the multiple updates into a single ChatMessage. But it looks like now that is no longer the logic going on.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants