Skip to content

Conversation

westey-m
Copy link
Contributor

@westey-m westey-m commented Oct 9, 2025

Address two issues:

  1. Yield remaining updates at the end of the downstream client stream, when we received FCC that did not require approval, and we never received any that did, so we had to buffer all the way to the end.
  2. Before we receive any FCC we can yield all updates, since there is no risk yet of incorrectly yielding FCC without approval.

Fixes microsoft/agent-framework#1295

Microsoft Reviewers: Open in CodeFlow

@westey-m westey-m requested a review from a team as a code owner October 9, 2025 11:26
@Copilot Copilot AI review requested due to automatic review settings October 9, 2025 11:26
@github-actions github-actions bot added the area-ai Microsoft.Extensions.AI libraries label Oct 9, 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 addresses two critical bugs in the FunctionInvokingChatClient's streaming functionality related to function call content (FCC) buffering and yielding behavior. The fix ensures that all buffered updates are properly yielded when the stream ends, particularly in scenarios involving mixed approval requirements for function calls.

Key changes:

  • Enhanced condition to yield updates when no function calls are present yet
  • Added logic to yield remaining buffered updates at stream end
  • Extended test coverage for mixed approval scenarios with multi-round testing

Reviewed Changes

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

File Description
src/Libraries/Microsoft.Extensions.AI/ChatCompletion/FunctionInvokingChatClient.cs Fixed streaming logic to yield remaining buffered updates and handle pre-FCC scenarios
test/Libraries/Microsoft.Extensions.AI.Tests/ChatCompletion/FunctionInvokingChatClientApprovalsTests.cs Added comprehensive test for mixed approval scenarios and refactored existing test methods to support multi-round testing

Copy link
Member

@stephentoub stephentoub left a comment

Choose a reason for hiding this comment

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

Thanks!

@stephentoub stephentoub merged commit a9b3385 into dotnet:main Oct 9, 2025
7 checks passed
This was referenced Oct 15, 2025
This was referenced Oct 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-ai Microsoft.Extensions.AI libraries

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: Bug Report [Potential] : Invalid Message Sequence When Mixing ApprovalRequiredAIFunction and Auto-Execute Functions with RunStreamingAsync

2 participants