-
Notifications
You must be signed in to change notification settings - Fork 1.1k
.NET: Allow overriding the ChatMessageStore to be used per agent run. #3330
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
westey-m
merged 4 commits into
microsoft:main
from
westey-m:chatmessagestore-allow-perrun-override
Jan 23, 2026
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
40637fc
Allow overriding the ChatMessageStore to be used per agent run.
westey-m fe81d51
Fix typos
westey-m 5bbde82
Fix Add and add TryAdd, Contains and Remove
westey-m 33ff003
Merge branch 'main' into chatmessagestore-allow-perrun-override
westey-m File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
49 changes: 49 additions & 0 deletions
49
dotnet/src/Microsoft.Agents.AI.Abstractions/AdditionalPropertiesExtensions.cs
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| // Copyright (c) Microsoft. All rights reserved. | ||
|
|
||
| using System.Diagnostics.CodeAnalysis; | ||
| using Microsoft.Extensions.AI; | ||
| using Microsoft.Shared.Diagnostics; | ||
|
|
||
| namespace Microsoft.Agents.AI; | ||
|
|
||
| /// <summary> | ||
| /// Contains extension methods to allow storing and retrieving properties using the type name of the property as the key. | ||
| /// </summary> | ||
| public static class AdditionalPropertiesExtensions | ||
| { | ||
| /// <summary> | ||
| /// Sets an additional property using the type name of the property as the key. | ||
| /// </summary> | ||
| /// <typeparam name="T">The type of the property to set.</typeparam> | ||
| /// <param name="additionalProperties">The dictionary of additional properties.</param> | ||
| /// <param name="value">The value to set.</param> | ||
| public static void Add<T>(this AdditionalPropertiesDictionary additionalProperties, T value) | ||
| { | ||
| _ = Throw.IfNull(additionalProperties); | ||
|
|
||
| additionalProperties[typeof(T).FullName!] = value!; | ||
| } | ||
|
|
||
| /// <summary> | ||
| /// Attempts to retrieve a value from the additional properties dictionary using the type name of the property as the key. | ||
| /// </summary> | ||
| /// <remarks> | ||
| /// This method uses the full name of the type parameter as the key when searching the dictionary. | ||
| /// </remarks> | ||
| /// <typeparam name="T">The type of the property to be retrieved.</typeparam> | ||
| /// <param name="additionalProperties">The dictionary containing additional properties.</param> | ||
| /// <param name="value"> | ||
| /// When this method returns, contains the value retrieved from the dictionary, if found and successfully converted to the requested type; | ||
| /// otherwise, the default value of <typeparamref name="T"/>. | ||
| /// </param> | ||
| /// <returns> | ||
| /// <see langword="true"/> if a non-<see langword="null"/> value was found | ||
| /// in the dictionary and converted to the requested type; otherwise, <see langword="false"/>. | ||
| /// </returns> | ||
| public static bool TryGetValue<T>(this AdditionalPropertiesDictionary additionalProperties, [NotNullWhen(true)] out T? value) | ||
| { | ||
| _ = Throw.IfNull(additionalProperties); | ||
|
|
||
| return additionalProperties.TryGetValue(typeof(T).FullName!, out value); | ||
| } | ||
| } | ||
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
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.