.NET: [BREAKING] Change SerializeSession to be Async#3879
Merged
westey-m merged 3 commits intomicrosoft:mainfrom Feb 12, 2026
Merged
.NET: [BREAKING] Change SerializeSession to be Async#3879westey-m merged 3 commits intomicrosoft:mainfrom
westey-m merged 3 commits intomicrosoft:mainfrom
Conversation
SergeyMenshykh
approved these changes
Feb 12, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Updates the .NET AIAgent session serialization API to be asynchronous, aligning it with the existing async session creation/deserialization patterns and propagating the change through implementations, tests, and samples.
Changes:
- Replaced
AIAgent.SerializeSession/SerializeSessionCorewithSerializeSessionAsync/SerializeSessionCoreAsync(ValueTask-based, supports CancellationToken). - Updated all
AIAgentimplementations and call sites (workflows, hosting/session store, wrappers). - Updated unit/integration tests and samples to use the async API.
Reviewed changes
Copilot reviewed 42 out of 42 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs | Introduces async session serialization API + new abstract core async method. |
| dotnet/src/Microsoft.Agents.AI.Abstractions/AgentSession.cs | Updates XML docs to reference SerializeSessionAsync. |
| dotnet/src/Microsoft.Agents.AI.Abstractions/DelegatingAIAgent.cs | Forwards serialization via async API to inner agent. |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Updates core serialization override to async ValueTask form. |
| dotnet/src/Microsoft.Agents.AI.Workflows/WorkflowHostAgent.cs | Updates core serialization override to async ValueTask form. |
| dotnet/src/Microsoft.Agents.AI.Workflows/Specialized/AIAgentHostExecutor.cs | Uses SerializeSessionAsync during checkpointing. |
| dotnet/src/Microsoft.Agents.AI.Hosting/Local/InMemoryAgentSessionStore.cs | Awaits SerializeSessionAsync when persisting session state. |
| dotnet/src/Microsoft.Agents.AI.Purview/PurviewAgent.cs | Wraps inner agent serialization via async API. |
| dotnet/src/Microsoft.Agents.AI.GitHub.Copilot/GitHubCopilotAgent.cs | Updates core serialization override to async ValueTask form. |
| dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs | Updates core serialization override to async ValueTask form. |
| dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs | Updates core serialization override to async ValueTask form. |
| dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgent.cs | Updates core serialization override to async ValueTask form (Durable Task agent). |
| dotnet/src/Microsoft.Agents.AI.DurableTask/DurableAIAgentProxy.cs | Updates core serialization override to async ValueTask form (proxy). |
| dotnet/tests/Microsoft.Agents.AI.AGUI.UnitTests/AGUIChatClientTests.cs | Updates test to await SerializeSessionAsync. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/TestAIAgent.cs | Updates test agent override signature to async core method. |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/AgentExtensionsTests.cs | Updates nested test agent override signature to async core method. |
| dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIAgentTests.cs | Updates mock agent overrides to async core method signature. |
| dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentRunContextTests.cs | Updates nested test agent override signature to async core method. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AzureFunctions.UnitTests/TestAgent.cs | Updates test agent override signature to async core method. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIEndpointRouteBuilderExtensionsTests.cs | Updates test agents to use async session serialization core override. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/SharedStateTests.cs | Updates fake agent core serialization override + wraps returned JsonElement in ValueTask. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/ForwardedPropertiesTests.cs | Updates fake agent core serialization override + wraps returned JsonElement in ValueTask. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.cs | Updates fake agent core serialization override(s) to async signature. |
| dotnet/tests/Microsoft.Agents.AI.Declarative.UnitTests/AggregatorPromptAgentFactoryTests.cs | Updates nested agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/WorkflowHostSmokeTests.cs | Updates test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestRequestAgent.cs | Updates test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestReplayAgent.cs | Updates test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/TestEchoAgent.cs | Wraps serialized JsonElement in ValueTask for async core override. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/Sample/06_GroupChat_Workflow.cs | Updates test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RoleCheckAgent.cs | Updates test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/RepresentationTests.cs | Updates test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/InProcessExecutionTests.cs | Updates nested test agent core serialization override signature. |
| dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/AgentWorkflowBuilderTests.cs | Updates nested agent core serialization override signature. |
| dotnet/samples/M365Agent/AFAgentApplication.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/Program.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/Agents/Agent_Step20_AdditionalAIContext/Program.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/Agents/Agent_Step13_BackgroundResponsesWithToolsAndPersistence/Program.cs | Updates helper to async and awaits SerializeSessionAsync. |
| dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyChatHistoryStorage/Program.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/Agents/Agent_Step06_PersistedConversations/Program.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step03_CustomMemory/Program.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step02_MemoryUsingMem0/Program.cs | Updates sample to await SerializeSessionAsync. |
| dotnet/samples/GettingStarted/AgentProviders/Agent_With_CustomImplementation/Program.cs | Updates custom agent example to async core serialization override. |
Comments suppressed due to low confidence (1)
dotnet/samples/GettingStarted/AgentWithMemory/AgentWithMemory_Step03_CustomMemory/Program.cs:55
- Variable name
sesionElementlooks like a typo; consider renaming tosessionElement(and updating its uses below) to keep the sample code clear.
JsonElement sesionElement = await agent.SerializeSessionAsync(session);
Console.WriteLine("\n>> Use deserialized session with previously created memories\n");
// Later we can deserialize the session and continue the conversation with the previous memory component state.
var deserializedSession = await agent.DeserializeSessionAsync(sesionElement);
rogerbarreto
approved these changes
Feb 12, 2026
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
#3725
Description
Contribution Checklist