-
Notifications
You must be signed in to change notification settings - Fork 874
.NET: Prevent streamed updates loss when resuming streaming #2516
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
.NET: Prevent streamed updates loss when resuming streaming #2516
Conversation
…anaged store or/and context provider
There was a problem hiding this 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 a critical issue with message loss during streaming resumption by adding validation to prevent unsupported scenarios. The changes ensure that continuation tokens cannot be used with custom message stores or context providers during streaming operations, where collected updates could be lost.
Key changes:
- Added validation in
ValidateStreamResumptionAllowedto prevent streaming resumption with MessageStore or AIContextProvider - Added validation to prevent continuation tokens from being used on initial runs (when thread has no ConversationId and no MessageStore)
- Updated existing tests to include ConversationId in thread and response objects to ensure tests represent realistic continuation scenarios
- Added comprehensive test coverage for all new validation scenarios
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Implements new validation logic to prevent streaming resumption with MessageStore or AIContextProvider, and prevents continuation tokens on initial runs |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs | Updates existing tests to use ConversationId and adds four new test cases covering all validation scenarios for continuation token usage |
Co-authored-by: Copilot <[email protected]>
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: westey <[email protected]>
Co-authored-by: westey <[email protected]>
This PR disables scenarios that would experience message loss, such as streaming resumption with threads configured with either a custom message store or a context provider.
Closes: #1760