.Net: Add support for 3rd party thread storage and thread serialization#203
Merged
westey-m merged 42 commits intomicrosoft:mainfrom Aug 5, 2025
westey-m:threadstorageandserialization
Merged
.Net: Add support for 3rd party thread storage and thread serialization#203westey-m merged 42 commits intomicrosoft:mainfrom westey-m:threadstorageandserialization
westey-m merged 42 commits intomicrosoft:mainfrom
westey-m:threadstorageandserialization
Conversation
westey-m
commented
Jul 21, 2025
dotnet/src/Microsoft.Extensions.AI.Agents/MessageStoringAgentThread.cs
Outdated
Show resolved
Hide resolved
westey-m
commented
Jul 21, 2025
dotnet/src/Microsoft.Extensions.AI.Agents/MessageStoringAgentThread.cs
Outdated
Show resolved
Hide resolved
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR implements a proof-of-concept for thread storage and serialization capabilities in the agent framework. It refactors the existing ChatClientAgentThread into a more general MessageStoringAgentThread that supports multiple storage locations and adds serialization/deserialization functionality to the agent thread system.
Key changes:
- Replaces
ChatClientAgentThreadwithMessageStoringAgentThreadfor more flexible message storage - Introduces serialization/deserialization capabilities for agent threads
- Adds abstract
DeserializeThreadmethod to the baseAgentclass
Reviewed Changes
Copilot reviewed 25 out of 25 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| MessageStoringAgentThread.cs | New implementation replacing ChatClientAgentThread with serialization support and flexible storage options |
| MessageStoringThreadStorageLocation.cs | New enum defining storage location types (Unknown, AgentThreadManaged, ConversationId) |
| IChatMessageStore.cs | New interface for custom message storage implementations |
| ChatClientAgent.cs | Updated to use MessageStoringAgentThread and implement DeserializeThread method |
| AgentThread.cs | Added serialization support and deserialization constructor |
| AIAgent.cs | Added abstract DeserializeThread method |
| Various test files | Updated type references and added comprehensive serialization tests |
dotnet/src/Microsoft.Extensions.AI.Agents/MessageStoringAgentThread.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Extensions.AI.Agents.Abstractions/IChatMessageStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Extensions.AI.Agents/MessageStoringAgentThread.cs
Outdated
Show resolved
Hide resolved
dotnet/tests/Microsoft.Extensions.AI.Agents.UnitTests/MessageStoringAgentThreadTests.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Extensions.AI.Agents/MessageStoringAgentThread.cs
Outdated
Show resolved
Hide resolved
dmytrostruk
reviewed
Jul 31, 2025
dotnet/src/Microsoft.Extensions.AI.Agents.Abstractions/IChatMessageStore.cs
Outdated
Show resolved
Hide resolved
dmytrostruk
reviewed
Jul 31, 2025
dotnet/src/Microsoft.Extensions.AI.Agents.Abstractions/InMemoryChatMessageStore.cs
Show resolved
Hide resolved
westey-m
commented
Jul 31, 2025
dotnet/src/Microsoft.Extensions.AI.Agents.Abstractions/AgentThread.cs
Outdated
Show resolved
Hide resolved
westey-m
commented
Jul 31, 2025
Make Thread Deserialize internal. Make AgentThread type switching fobidden.
ReubenBond
reviewed
Aug 1, 2025
dotnet/src/Microsoft.Extensions.AI.Agents.Abstractions/IChatMessageStore.cs
Show resolved
Hide resolved
ReubenBond
reviewed
Aug 1, 2025
dotnet/src/Microsoft.Extensions.AI.Agents.Abstractions/IChatMessageStore.cs
Show resolved
Hide resolved
ReubenBond
reviewed
Aug 1, 2025
SergeyMenshykh
approved these changes
Aug 5, 2025
4 tasks
ReubenBond
pushed a commit
to ReubenBond/agent-framework
that referenced
this pull request
Oct 28, 2025
…on (microsoft#203) * Add thread storage and serialization POC * Switch to using JsonElement and add unit tests * Add additional unit tests. * Exclude private debugger properties from CodeCoverage. * Rename IChatMessagesStorable to IChatMessageStore * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Improve xml doc. * Update the message storing thread to always use external store for both local and remote storage. * Remove threadid from the IChatMessageStore interface, since the store should own the thread id itself, if it requires one. * Switch GetMessages to IEnumerable * Address pr comments. * Make jsonserializer options default consistent on DeserializeThreadAsync * Move message storing thread functionality into AgentThread and simplify AgentThread behavior. * Remove embedding generation from VectorStore chat history sample. * Remove unecessary code and fix formatting. * Make GetNewThread and DeserializeThread virtual with default implementations. Remove unsued json utilities. * Fix formatting * Remove problem test. * Add more unit tests * Remove unused using clause. * Address pr feedback. * Address PR comments. * Make InMemory store internal * Switch InMemoryChatMessageStore to implement IList instead of inheriting from List. * Rename store deserialize param. * Update serialization based on PR comments. * Remove confusing comment. * Address Deserialization PR comments in the same way as Serialization * Add State to IChatMessageStore Serialize and Deserialize names. Make Thread Deserialize internal. Make AgentThread type switching fobidden. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
Arturo-Quiroga-MSFT
pushed a commit
to Arturo-Quiroga-MSFT/agent-framework-public
that referenced
this pull request
Nov 23, 2025
…on (microsoft#203) * Add thread storage and serialization POC * Switch to using JsonElement and add unit tests * Add additional unit tests. * Exclude private debugger properties from CodeCoverage. * Rename IChatMessagesStorable to IChatMessageStore * Apply suggestions from code review Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Improve xml doc. * Update the message storing thread to always use external store for both local and remote storage. * Remove threadid from the IChatMessageStore interface, since the store should own the thread id itself, if it requires one. * Switch GetMessages to IEnumerable * Address pr comments. * Make jsonserializer options default consistent on DeserializeThreadAsync * Move message storing thread functionality into AgentThread and simplify AgentThread behavior. * Remove embedding generation from VectorStore chat history sample. * Remove unecessary code and fix formatting. * Make GetNewThread and DeserializeThread virtual with default implementations. Remove unsued json utilities. * Fix formatting * Remove problem test. * Add more unit tests * Remove unused using clause. * Address pr feedback. * Address PR comments. * Make InMemory store internal * Switch InMemoryChatMessageStore to implement IList instead of inheriting from List. * Rename store deserialize param. * Update serialization based on PR comments. * Remove confusing comment. * Address Deserialization PR comments in the same way as Serialization * Add State to IChatMessageStore Serialize and Deserialize names. Make Thread Deserialize internal. Make AgentThread type switching fobidden. --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: Chris <66376200+crickman@users.noreply.github.com>
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.
Motivation and Context
We need to be able to store thread messages in 3rd party storage.
We also need to be able to serialize/deserialize threads regardless of where the 3rd party storage is located.
Description
This PR adds thread storage and serialization in a way that the abstraction user doesn't have to know anything about the thread type or storage that it uses
Contribution Checklist