-
Notifications
You must be signed in to change notification settings - Fork 950
.NET: [BREAKING] Add GetNewThread overload for taking a ChatMessageStore at thread creation time #2429
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: [BREAKING] Add GetNewThread overload for taking a ChatMessageStore at thread creation time #2429
Conversation
…ation time and move message store creation to thread creation time.
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 adds a new GetNewThread(ChatMessageStore) overload that allows users to provide a custom ChatMessageStore instance at thread creation time, addressing scenarios where async processing is needed to generate a custom thread ID or where users need to access the message store before the first run.
Key Changes
- Adds
GetNewThread(ChatMessageStore)overload for directly providing a message store instance - Moves message store creation from lazy initialization (during first run) to eager initialization (at thread creation time) when using
ChatMessageStoreFactory - Updates test coverage with new test files and modified existing tests to validate the new behavior
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Adds new GetNewThread(ChatMessageStore) overload with XML documentation and modifies parameterless GetNewThread() to eagerly create message store from factory |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_GetNewThreadTests.cs | New test file covering GetNewThread() overloads with factory and parameter-based scenarios |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_DeserializeThreadTests.cs | New test file covering DeserializeThread() with factory scenarios |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs | Refactors and adds tests for the new eager initialization behavior, including validation that exceptions are thrown when both ConversationId and MessageStore are used together |
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Roger Barreto <[email protected]>
Motivation and Context
In some cases users may need to provide a custom ChatMessageStore to a ChatClientAgent when they create the thread, instead of via a factory. E.g. when users need to do some async processing to generate a custom thread id.
Users may also want to access the message store object from the thread before doing the first run, to update it for their specific scenario.
#2325
Description
Contribution Checklist