Conversation
Co-authored-by: markwallace-microsoft <127216156+markwallace-microsoft@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Fix case-sensitivity issue in CosmosChatMessageStore methods
Fix case-sensitive property mismatch in CosmosChatHistoryProvider queries
Jan 28, 2026
alliscode
pushed a commit
to alliscode/agent-framework
that referenced
this pull request
Feb 20, 2026
…c and ClearMessagesAsync The count and delete queries used c.Type (capital T) instead of c.type (lowercase t), which doesn't match the stored document property name. Cosmos DB property names are case-sensitive, so these queries would always return 0 results. Fixes the same issue as microsoft#3485 but applied cleanly to current main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
westey-m
approved these changes
Feb 23, 2026
Contributor
|
@copilot, the build is failing with style issues, please fix. |
Co-authored-by: westey-m <164392973+westey-m@users.noreply.github.com>
Contributor
Author
westey-m
approved these changes
Feb 23, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a Cosmos DB SQL case-sensitivity bug in .NET where queries used c.Type even though the stored JSON field is type, causing GetMessageCountAsync() and ClearMessagesAsync() to return 0 incorrectly.
Changes:
- Update CosmosChatHistoryProvider SQL queries to use
c.type(matching[JsonProperty("type")]). - Add Cosmos emulator-backed unit tests covering message counting and clearing scenarios.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs | Fixes case-sensitive Cosmos SQL queries for count and delete operations by querying c.type. |
| dotnet/tests/Microsoft.Agents.AI.CosmosNoSql.UnitTests/CosmosChatHistoryProviderTests.cs | Adds new emulator-skippable tests validating correct counts and deletes for empty/non-empty conversations. |
peibekwe
approved these changes
Feb 23, 2026
github-merge-queue bot
pushed a commit
that referenced
this pull request
Feb 23, 2026
…ntAsyn… (#4139) * Fix case-sensitivity bug in Cosmos DB queries for GetMessageCountAsync and ClearMessagesAsync The count and delete queries used c.Type (capital T) instead of c.type (lowercase t), which doesn't match the stored document property name. Cosmos DB property names are case-sensitive, so these queries would always return 0 results. Fixes the same issue as #3485 but applied cleanly to current main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> * Add tests for GetMessageCountAsync and ClearMessagesAsync Verifies that the count and clear queries correctly match stored documents by using the proper lowercase 'type' property name in Cosmos DB queries. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --------- Co-authored-by: alliscode <bentho@microsoft.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This was referenced Feb 27, 2026
Open
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
SQL queries in
CosmosChatHistoryProviderusedc.Type(uppercase) while the document model defines[JsonProperty("type")](lowercase). Cosmos DB's case-sensitive queries failed to match any documents, causingGetMessageCountAsync()andClearMessagesAsync()to always return 0.Description
Changed queries:
GetMessageCountAsync()- line 555:c.Type→c.typeClearMessagesAsync()- line 585:c.Type→c.typeAdded tests:
GetMessageCountAsync_WithMessages_ShouldReturnCorrectCountAsyncGetMessageCountAsync_WithNoMessages_ShouldReturnZeroAsyncClearMessagesAsync_WithMessages_ShouldDeleteAndReturnCountAsyncClearMessagesAsync_WithNoMessages_ShouldReturnZeroAsyncTest updates:
new(...)instead ofnew ChatMessage(...))AgentSessionparameterTests follow existing patterns (skip when Cosmos DB Emulator unavailable).
Contribution Checklist
Original prompt
💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.