-
Notifications
You must be signed in to change notification settings - Fork 826
.NET: Update AgentFeatureCollections with feedback #2379
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
.NET: Update AgentFeatureCollections with feedback #2379
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR updates the AgentFeatureCollection API based on feedback from issue #2325. The changes improve the API design by replacing the indexer with a TryGet method, requiring non-null features, and adding a Remove method.
Key changes:
- Replaced
Get<TFeature>()method withTryGet<TFeature>(out TFeature feature)for safer feature retrieval - Removed the indexer
this[Type key]in favor of explicitSet,TryGet, andRemovemethods - Added
Remove<TFeature>()method to explicitly remove features from the collection - Added class constraint to all generic type parameters and made all features non-nullable
- Added
WithFeatureextension method for fluent API usage - Updated all usages across the codebase to use the new API
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Abstractions/Features/IAgentFeatureCollection.cs | Updated interface with TryGet, Remove, and Set methods, removed indexer |
| dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollection.cs | Implemented new API methods, renamed _defaults to _innerCollection for clarity |
| dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollectionExtensions.cs | Added new extension methods file with WithFeature helper |
| dotnet/src/Microsoft.Agents.AI.Abstractions/Features/ConversationIdAgentFeature.cs | Updated documentation to remove reference to 3rd party stores |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Updated to use TryGet pattern instead of Get |
| dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs | Updated to use TryGet pattern instead of Get |
| dotnet/src/Microsoft.Agents.AI.A2A/A2AAgent.cs | Updated to use TryGet pattern instead of Get |
| dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs | Updated sample to use new WithFeature extension method |
| dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AgentFeatureCollectionTests.cs | Updated tests to cover new API methods including Remove and TryGet |
dotnet/samples/GettingStarted/Agents/Agent_Step07_3rdPartyThreadStorage/Program.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollection.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollection.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated no new comments.
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/IAgentFeatureCollection.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollection.cs
Outdated
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollectionExtensions.cs
Show resolved
Hide resolved
|
I see AgentRunOptions now has both AdditionalProperties and Features: agent-framework/dotnet/src/Microsoft.Agents.AI.Abstractions/AgentRunOptions.cs Lines 93 to 98 in 5b39389
What's the use case for having both? When would I pick one over the other? Do we need Features if AdditionalProperties exists, or vice versa? |
@stephentoub, yeah, this still bugs me as well. Let's discuss directly offline. I don't intend to merge the feature branch until we have made a decision on this. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollectionExtensions.cs
Outdated
Show resolved
Hide resolved
…ureCollectionExtensions.cs Co-authored-by: Copilot <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 7 comments.
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/IAgentFeatureCollection.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollection.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.CopilotStudio/CopilotStudioAgent.cs
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
Copilot reviewed 9 out of 9 changed files in this pull request and generated 1 comment.
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/AgentFeatureCollection.cs
Show resolved
Hide resolved
dotnet/src/Microsoft.Agents.AI.Abstractions/Features/IAgentFeatureCollection.cs
Show resolved
Hide resolved
ReubenBond
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just one comment about the indexer removal
9d86adf
into
microsoft:feature-featurecollections-messagestore
Motivation and Context
#2325
Description
Contribution Checklist