Skip to content

.NET: [BREAKING] Decouple Cosmos chat metadata from partition-key strategy - #9214

Merged
Vincent Biret (baywet) merged 2 commits into
mainfrom
copilot/dotnet-allow-customizing-partition-key
Oct 9, 2026
Merged

Vincent Biret (baywet) merged 2 commits into
mainfrom
copilot/dotnet-allow-customizing-partition-key

Conversation

Copilot AI commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Motivation & Context

CosmosChatHistoryProvider ties tenant/user metadata persistence to hierarchical partitioning. Flat conversation-ID partitioning should retain that metadata and preserve conversation continuity across authentication transitions.

Description & Review Guide

  • What are the major changes?
    • Partition strategy: Add optional PartitionKeyFactory, used for writes, reads, counts, and deletes.
    • Metadata: Persist tenant/user IDs whenever provided; always persist session ID as conversation ID.
    • Configuration: Move optional constructor arguments into CosmosChatHistoryProviderOptions.
  • What is the impact of these changes? Default partitioning remains unchanged. Callers supplying optional constructor arguments must migrate to options.
  • What do you want reviewers to focus on? Strategy consistency across operations, metadata independence, and preservation of filtering and client-ownership behavior.

Flat partitioning with tenant/user metadata:

new CosmosChatHistoryProvider(
    cosmosClient, databaseId, containerId,
    _ => new CosmosChatHistoryProvider.State(conversationId, tenantId, userId),
    new CosmosChatHistoryProviderOptions
    {
        PartitionKeyFactory = state => new PartitionKey(state.ConversationId)
    });

Related Issue

Maintainer-approved direction, including the options-class refactor.

AI Assistance

  • No material AI assistance was used.
  • This is an AI-assisted contribution. I reviewed, understood, and verified all submitted content and accept responsibility for it.

AI assistance details: Implementation, regression tests, XML documentation, and PR description.

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 links to an agreed issue with no competing open PR, or the Related Issue section documents a trivial-change or repository-automation exception.
  • This is not a breaking change. If it is a breaking change, add the breaking change label (or add "[BREAKING]" to the title prefix, before or after any language prefix) — a workflow keeps the label and title prefix in sync automatically.

Copilot AI balanced review requested due to automatic review settings October 8, 2026 14:58

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.

Copilot wasn't able to review any files in this pull request. Check if the Files changed in this pull request are included in default exclusions.

Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Copilot AI changed the title [WIP] Add support for customizable partition key strategy in CosmosChatHistoryProvider .NET: [BREAKING] Decouple Cosmos chat metadata from partition-key strategy Oct 8, 2026
Copilot AI deployed to github-app-auth October 8, 2026 15:59 Active
Copilot AI deployed to github-app-auth October 8, 2026 15:59 Active
Copilot AI deployed to github-app-auth October 8, 2026 15:59 Active
Copilot AI deployed to github-app-auth October 8, 2026 15:59 Active
@westey-m
westey (westey-m) marked this pull request as ready for review October 8, 2026 15:59
Copilot AI deployed to integration October 8, 2026 16:00 Active
Copilot AI deployed to integration October 8, 2026 16:00 Active
@westey-m
westey (westey-m) deployed to github-app-auth October 8, 2026 16:00 — with GitHub Actions Active
@agent-framework-automation agent-framework-automation Bot added .NET Usage: [Issues, PRs], Target: .Net breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible labels Oct 8, 2026
@github-code-quality

Copy link
Copy Markdown
Contributor

Code Coverage Overview

Languages: C#

C# / code-coverage/dotnet

The overall line coverage in commit aeac0d7 in the copilot/dotnet-allow... branch remains at 85%, unchanged from commit 91ab44f in the main branch.

Show a line coverage summary of the most impacted files.
File main 91ab44f copilot/dotnet-allow... aeac0d7 +/-
/home/runner/wo...SessionStore.cs 100% 53% -47%
/home/runner/wo...ptionsHelper.cs 89% 95% +6%
/home/runner/wo...toryProvider.cs 31% 95% +64%
/home/runner/wo...FeatureIndex.cs 0% 100% +100%

@baywet
Vincent Biret (baywet) added this pull request to the merge queue Oct 9, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Oct 9, 2026
@baywet
Vincent Biret (baywet) added this pull request to the merge queue Oct 9, 2026
Merged via the queue into main with commit f72bf95 Oct 9, 2026
42 checks passed
@baywet
Vincent Biret (baywet) deleted the copilot/dotnet-allow-customizing-partition-key branch October 9, 2026 17:40

This branch was successfully deployed

2 active deployments
github-app-auth — aeac0d7e Deployed Oct 8, 2026 by westey-m via team_check #6397
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Usage: [PRs], Target: all PRs that introduce changes that are not backward compatible .NET Usage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

.NET: [Feature]: Allow customizing partition key strategy in CosmosChatHistoryProvider

4 participants