.NET: Add AGUI session persistence#5113
Open
Kazunari001 wants to merge 3 commits intomicrosoft:mainfrom
Open
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Adds server-side, in-memory session persistence for the ASP.NET Core AG-UI hosting endpoint to ensure conversation/session continuity across requests using thread IDs (fixing #4869).
Changes:
- Introduces an in-memory
AGUIInMemorySessionStoreand registers it in DI viaAddAGUI(). - Updates
MapAGUIstreaming execution to load/create a session byThreadIdand persist it after streaming completes. - Adds unit + integration tests validating cache-key isolation, expiration, and cross-request/session restoration behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIInMemorySessionStore.cs | Adds an in-memory MemoryCache-backed store for AgentSession keyed by agent/thread. |
| dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/ServiceCollectionExtensions.cs | Registers the in-memory session store in DI as a singleton when calling AddAGUI(). |
| dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs | Loads/creates sessions by ThreadId and persists them during streaming runs. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIInMemorySessionStoreTests.cs | Unit tests for reuse, key isolation, and expiration behavior. |
| dotnet/tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.IntegrationTests/BasicStreamingTests.cs | Integration tests validating conversation/session restoration across calls. |
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIInMemorySessionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs
Show resolved
Hide resolved
...tests/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore.UnitTests/AGUIInMemorySessionStoreTests.cs
Show resolved
Hide resolved
Author
|
@copilot apply changes based on the comments in this thread |
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIInMemorySessionStore.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIInMemorySessionStore.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Hosting.AGUI.AspNetCore/AGUIEndpointRouteBuilderExtensions.cs
Outdated
Show resolved
Hide resolved
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
Fix #4869
Description
Contribution Checklist