Skip to content

Commit d82a9c5

Browse files
alliscodeCopilot
andcommitted
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 microsoft#3485 but applied cleanly to current main. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent 44aec20 commit d82a9c5

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

dotnet/src/Microsoft.Agents.AI.CosmosNoSql/CosmosChatHistoryProvider.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -435,7 +435,7 @@ public async Task<int> GetMessageCountAsync(AgentSession? session, CancellationT
435435
var partitionKey = BuildPartitionKey(state);
436436

437437
// Efficient count query
438-
var query = new QueryDefinition("SELECT VALUE COUNT(1) FROM c WHERE c.conversationId = @conversationId AND c.Type = @type")
438+
var query = new QueryDefinition("SELECT VALUE COUNT(1) FROM c WHERE c.conversationId = @conversationId AND c.type = @type")
439439
.WithParameter("@conversationId", state.ConversationId)
440440
.WithParameter("@type", "ChatMessage");
441441

@@ -469,7 +469,7 @@ public async Task<int> ClearMessagesAsync(AgentSession? session, CancellationTok
469469
var partitionKey = BuildPartitionKey(state);
470470

471471
// Batch delete for efficiency
472-
var query = new QueryDefinition("SELECT VALUE c.id FROM c WHERE c.conversationId = @conversationId AND c.Type = @type")
472+
var query = new QueryDefinition("SELECT VALUE c.id FROM c WHERE c.conversationId = @conversationId AND c.type = @type")
473473
.WithParameter("@conversationId", state.ConversationId)
474474
.WithParameter("@type", "ChatMessage");
475475

0 commit comments

Comments
 (0)