Skip to content

.NET: CosmosDB Actor State Storage#262

Merged
adityamandaleeka merged 18 commits intomainfrom
cosmos-state-rebased
Aug 5, 2025
Merged

.NET: CosmosDB Actor State Storage#262
adityamandaleeka merged 18 commits intomainfrom
cosmos-state-rebased

Conversation

@adityamandaleeka
Copy link
Member

This change adds an IActorStateStorage implementation that uses CosmosDB, and a set of tests for it that use Aspire and can run either using the real service or in the emulator.

I've just rebased everything onto current main (was previously based on a personal feature branch) and had to disable a few warnings to get things building and running. I suspect we'll be able to resolve some of those soon but I didn't want to delay getting this PR out.

Copilot AI review requested due to automatic review settings July 29, 2025 01:30
@github-actions github-actions bot changed the title WIP: CosmosDB Actor State Storage .Net: WIP: CosmosDB Actor State Storage Jul 29, 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 a CosmosDB-based implementation for actor state storage in the AI Agents framework. It provides an alternative storage backend to the default in-memory storage for persistent actor state management.

Key changes include:

  • A complete CosmosDB implementation of IActorStateStorage with optimistic concurrency control
  • Comprehensive integration tests using Aspire for both real CosmosDB and emulator scenarios
  • Service collection extensions for easy dependency injection setup

Reviewed Changes

Copilot reviewed 19 out of 19 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
CosmosActorStateStorage.cs Core implementation of actor state storage using CosmosDB with document structure and transactional batch operations
ServiceCollectionExtensions.cs DI configuration helpers for registering CosmosDB storage with various setup options
Test files Comprehensive integration tests covering CRUD operations, concurrency, list operations, and edge cases
Sample integration Example usage in HelloHttpApi sample showing how to integrate CosmosDB storage
Project files Package references and solution structure updates

@adityamandaleeka adityamandaleeka added this pull request to the merge queue Aug 5, 2025
Merged via the queue into main with commit f5b35d8 Aug 5, 2025
14 checks passed
@crickman crickman deleted the cosmos-state-rebased branch August 7, 2025 22:18
ReubenBond pushed a commit to ReubenBond/agent-framework that referenced this pull request Oct 28, 2025
* Implement CosmosDB actor state storage.

* Fix.

* Minor fixes.

* Fixes.

* Make CosmosDB initialization be lazy.

* Remove unnecessary read from write path.

* Throw on empty writes.

* Add arg validation for read.

* Add CosmosIdSanitizer.

* Fix.

* Fix.

* Simplify doc IDs.

* Update comment.

* fb

* Make LazyCosmosContainer internal and add tests.

* Make test constants public and remove IVT.

* Use source generated JSON context for future nativeAOT support.

* Re-add dropped comments.
Arturo-Quiroga-MSFT pushed a commit to Arturo-Quiroga-MSFT/agent-framework-public that referenced this pull request Nov 23, 2025
* Implement CosmosDB actor state storage.

* Fix.

* Minor fixes.

* Fixes.

* Make CosmosDB initialization be lazy.

* Remove unnecessary read from write path.

* Throw on empty writes.

* Add arg validation for read.

* Add CosmosIdSanitizer.

* Fix.

* Fix.

* Simplify doc IDs.

* Update comment.

* fb

* Make LazyCosmosContainer internal and add tests.

* Make test constants public and remove IVT.

* Use source generated JSON context for future nativeAOT support.

* Re-add dropped comments.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

6 participants