Skip to content

.NET: Allow overriding the ChatMessageStore to be used per agent run. - #3330

Merged
westey (westey-m) merged 4 commits into
microsoft:mainfrom
westey-m:chatmessagestore-allow-perrun-override
Jan 23, 2026
Merged

.NET: Allow overriding the ChatMessageStore to be used per agent run.#3330
westey (westey-m) merged 4 commits into
microsoft:mainfrom
westey-m:chatmessagestore-allow-perrun-override

Conversation

@westey-m

Copy link
Copy Markdown
Contributor

Motivation and Context

#3104

Description

  • Allow overriding the ChatMessageStore to be used per agent run via AdditionalProperties
  • Moved all ChatMessageStore and ConversationId tests into a separate test file to reduce the side of the main ChatClientAgentTests file.

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? If yes, add "[BREAKING]" prefix to the title of the PR.

CopilotAI review requested due to automatic review settings January 21, 2026 14:42
@markwallace-microsoftMark Wallace (markwallace-microsoft) added the .NET Usage: [Issues, PRs], Target: .Net label Jan 21, 2026
@github-actionsgithub-actionsBot changed the title Allow overriding the ChatMessageStore to be used per agent run..NET: Allow overriding the ChatMessageStore to be used per agent run.Jan 21, 2026

CopilotAI 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.

Pull request overview

This pull request adds functionality to allow overriding the ChatMessageStore on a per-agent-run basis via AdditionalProperties. The PR also reorganizes tests by moving ChatMessageStore and ConversationId related tests into a separate file.

Changes:

  • Added AdditionalPropertiesExtensions with type-based key storage/retrieval for AdditionalPropertiesDictionary
  • Implemented ResolveChatMessageStore to support ChatMessageStore overrides via AdditionalProperties
  • Made ChatMessageStoreMessages nullable in InvokedContext to handle first-run scenarios
  • Reorganized tests by moving chat history management tests to a dedicated file

Reviewed changes

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

Show a summary per file
FileDescription
dotnet/src/Microsoft.Agents.AI.Abstractions/AdditionalPropertiesExtensions.csNew extension methods for type-based storage/retrieval in AdditionalPropertiesDictionary
dotnet/src/Microsoft.Agents.AI.Abstractions/ChatMessageStore.csMade ChatMessageStoreMessages parameter nullable in InvokedContext constructor
dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.csAdded ResolveChatMessageStore method and updated all notification call sites to pass chatOptions
dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AdditionalPropertiesExtensionsTests.csComprehensive tests for AdditionalPropertiesExtensions
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_ChatHistoryManagementTests.csNew test file consolidating ChatMessageStore and ConversationId tests, including override test
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.csRemoved tests that were moved to ChatHistoryManagementTests
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_DeserializeThreadTests.csNamespace changed for consistency
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgent_GetNewThreadTests.csNamespace changed for consistency
dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentContinuationTokenTests.csNamespace changed for consistency

Comment threaddotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs Outdated
Comment threaddotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs Outdated
@westey-m
westey (westey-m) added this pull request to the merge queueJan 22, 2026
github-merge-queueBot pushed a commit that referenced this pull request Jan 22, 2026
…#3330)
* Allow overriding the ChatMessageStore to be used per agent run.
* Fix typos
* Fix Add and add TryAdd, Contains and Remove
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Jan 22, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueJan 23, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Jan 23, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueJan 23, 2026
@github-merge-queue
github-merge-queueBot removed this pull request from the merge queue due to failed status checks Jan 23, 2026
@westey-m
westey (westey-m) added this pull request to the merge queueJan 23, 2026
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

.NETUsage: [Issues, PRs], Target: .Net

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

@westey-m@rogerbarreto@SergeyMenshykh@markwallace-microsoft