Skip to content

.NET: add SQLite conversation persistence API sample - #8493

Open
Naveen Chatlapalli (1aifanatic) wants to merge 2 commits into
microsoft:mainfrom
1aifanatic:contrib/7805-enterprise-agents
Open

Naveen Chatlapalli (1aifanatic) wants to merge 2 commits into
microsoft:mainfrom
1aifanatic:contrib/7805-enterprise-agents

Conversation

@1aifanatic

@1aifanatic Naveen Chatlapalli (1aifanatic) commented Sep 18, 2026

Copy link
Copy Markdown
Contributor

Motivation & Context

Applications hosting a .NET agent behind an API need a concrete example of saving conversations in a database and resuming them by ID after a restart.

Description & Review Guide

  • What are the major changes? Add a small ASP.NET Core API sample that persists serialized AgentSession state in SQLite through the existing serialization APIs. Add a parameterized SQLite store, setup/resume instructions, solution registration, and provider-free regression tests.
  • What is the impact of these changes? Demonstrates persistence of the default chat history without writing another ChatHistoryProvider. Turns are serialized within the single process, and state is saved only after successful agent execution, independently of a subsequently aborted request. The README distinguishes session storage from external message storage and DevUI protocol stores, and explicitly limits the anonymous endpoint to local development.
  • What do you want reviewers to focus on? Session restore/save behavior and the documented authentication, retention, concurrency, and deployment boundaries. All three net10.0 tests pass, covering fresh agent/store resumption, repeated saves without duplicate history, separate conversation IDs, uncommitted state, and committing a completed turn after request cancellation. The project builds cleanly; sample/test formatting and diff checks pass. A local HTTP smoke check verified conversation creation and empty-message rejection. No live model call was made.

Related Issue

Fixes #7805 by providing the requested API-hosted database persistence example. It does not add a DevUI Conversations-store integration. No other open PR for this issue was found when preparing this contribution.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • All unit tests pass, and I have added new tests where possible
  • The PR follows the Contribution Guidelines
  • This PR is linked to an issue and there is no other open PR for this issue (see Related Issue above).
  • This is not a breaking change.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Request cancellation can prevent persistence after successful agent execution, violating the documented commit behavior.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Adds an ASP.NET Core sample demonstrating SQLite-backed agent session persistence and conversation resumption.

Changes:

  • Adds conversation API and SQLite session store.
  • Documents setup, security, concurrency, and deployment boundaries.
  • Adds persistence regression tests and solution registration.
File summaries
File Description
dotnet/tests/AspNetAgentPersistence.UnitTests/ConversationStoreTests.cs Tests session persistence and isolation.
dotnet/tests/AspNetAgentPersistence.UnitTests/AspNetAgentPersistence.UnitTests.csproj Defines the test project.
dotnet/samples/README.md Links the new sample.
dotnet/samples/05-end-to-end/AspNetAgentPersistence/README.md Documents usage and boundaries.
dotnet/samples/05-end-to-end/AspNetAgentPersistence/Program.cs Implements the conversation API.
dotnet/samples/05-end-to-end/AspNetAgentPersistence/ConversationStore.cs Implements SQLite persistence.
dotnet/samples/05-end-to-end/AspNetAgentPersistence/AspNetAgentPersistence.csproj Configures sample dependencies.
dotnet/agent-framework-dotnet.slnx Registers sample and tests.
Review details
  • Files reviewed: 8/8 changed files
  • Comments generated: 2
  • Review effort level: Balanced (auto)

Note

Copilot is running an experiment and ran this review at Balanced.


💡 Add a code-review agent skill for context-aware, tailored reviews. Learn more in the docs.

Comment thread dotnet/samples/05-end-to-end/AspNetAgentPersistence/Program.cs Outdated
Comment thread dotnet/samples/05-end-to-end/AspNetAgentPersistence/Program.cs Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Usage: [Issues, PRs], Target: documentation in the code base and learn docs .NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Feature]: Please add example to store conversation in database (.NET API Hosting)

2 participants