Skip to content

Conversation

@TheovanKraay
Copy link
Contributor

@TheovanKraay TheovanKraay commented Oct 31, 2025

Motivation and Context

This change adds Cosmos DB implementations for Agent Framework's storage abstractions to provide persistent storage options for chat messages and workflow checkpoints.

Partially addresses issue (.NET only): #1390

Description

Added Cosmos DB implementations for three core storage abstractions:

  • CosmosChatMessageStore - Implements ChatMessageStore for chat message persistence
  • CosmosCheckpointStore - Implements JsonCheckpointStore for workflow state persistence

Added convenience extensions:

  • CosmosDBChatExtensions - Extension methods for configuring chat agents with Cosmos DB
  • CosmosDBWorkflowExtensions - Factory methods for creating checkpoint stores

Features implemented:

  • Connection string and DefaultAzureCredential authentication
  • Hierarchical partitioning (/tenantId/userId/sessionId)
  • Transactional batch operations with automatic splitting
  • Configurable batch sizes and TTL settings
  • State serialization/deserialization support

Added corresponding unit tests.

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? No - this is a new feature addition

Copilot AI review requested due to automatic review settings October 31, 2025 17:30
@markwallace-microsoft markwallace-microsoft added .NET workflows Related to Workflows in agent-framework labels Oct 31, 2025
@github-actions github-actions bot changed the title Add Cosmos DB implementations for ChatMessageStore, CheckpointStore, and AgentThread .NET: Add Cosmos DB implementations for ChatMessageStore, CheckpointStore, and AgentThread Oct 31, 2025
Copy link
Contributor

Copilot AI left a 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 Azure Cosmos DB integration to the Agent Framework, providing persistent storage for chat messages and workflow checkpoints. The implementation includes both simple and hierarchical partition key support, along with comprehensive test coverage.

Key Changes

  • New Cosmos DB implementations for chat message storage (CosmosChatMessageStore) and checkpoint storage (CosmosCheckpointStore)
  • Extension methods for easy configuration of Cosmos DB stores
  • Support for connection string, managed identity, and CosmosClient-based authentication
  • Comprehensive unit tests for all Cosmos DB components

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 33 comments.

Show a summary per file
File Description
dotnet/Directory.Packages.props Added package references for Microsoft.Azure.Cosmos (3.53.1) and Newtonsoft.Json (13.0.3)
dotnet/src/Microsoft.Agents.AI.Abstractions/CosmosChatMessageStore.cs Implements chat message storage with Cosmos DB, supporting both simple and hierarchical partitioning
dotnet/src/Microsoft.Agents.AI.Abstractions/CosmosAgentThread.cs Abstract base class for agent threads using Cosmos DB for persistence
dotnet/src/Microsoft.Agents.AI/CosmosDBChatExtensions.cs Extension methods for configuring Cosmos DB message stores in ChatClientAgentOptions
dotnet/src/Microsoft.Agents.AI.Workflows/Checkpointing/CosmosCheckpointStore.cs Implements checkpoint storage with Cosmos DB for workflow persistence
dotnet/src/Microsoft.Agents.AI.Workflows/CosmosDBWorkflowExtensions.cs Extension methods for creating Cosmos DB checkpoint stores
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/CosmosChatMessageStoreTests.cs Comprehensive tests for CosmosChatMessageStore including hierarchical partitioning
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/CosmosAgentThreadTests.cs Tests for CosmosAgentThread functionality and message operations
dotnet/tests/Microsoft.Agents.AI.Workflows.UnitTests/CosmosCheckpointStoreTests.cs Tests for CosmosCheckpointStore covering checkpoint operations and error handling
Multiple .csproj files Added package references to Azure.Identity, Microsoft.Azure.Cosmos, and Newtonsoft.Json

Merged via the queue into microsoft:main with commit a57b37d Nov 26, 2025
14 checks passed
This was referenced Dec 5, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NET workflows Related to Workflows in agent-framework

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants