-
Notifications
You must be signed in to change notification settings - Fork 728
.NET: Add AdditionalProperties to AIAgent and surface in implementations #2133
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
base: main
Are you sure you want to change the base?
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 adds AdditionalProperties support to the AIAgent base class and its implementations, enabling custom metadata annotations on agents (e.g., authorization requirements, beta status, icons). The implementation follows the same pattern as existing AdditionalProperties in AgentRunOptions and ChatOptions.
- Added virtual
AdditionalPropertiesproperty toAIAgentbase class - Surfaced the property through
ChatClientAgent,ChatClientAgentOptions, andAIAgentMetadata - Added comprehensive unit tests validating default null behavior, property assignment, cloning, and metadata integration
Reviewed Changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Show a summary per file
| File | Description |
|---|---|
| dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgent.cs | Added virtual AdditionalProperties property to base class |
| dotnet/src/Microsoft.Agents.AI.Abstractions/AIAgentMetadata.cs | Added readonly AdditionalProperties property and constructor parameter |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgentOptions.cs | Added AdditionalProperties property with get/set and updated Clone() method |
| dotnet/src/Microsoft.Agents.AI/ChatClient/ChatClientAgent.cs | Overrode AdditionalProperties to return value from options and passed to metadata constructor |
| dotnet/tests/Microsoft.Agents.AI.Abstractions.UnitTests/AIAgentTests.cs | Added tests for default null and override behaviors with new mock class |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentOptionsTests.cs | Added tests for default value, setter, and cloning behavior |
| dotnet/tests/Microsoft.Agents.AI.UnitTests/ChatClient/ChatClientAgentTests.cs | Added tests verifying property from options and metadata integration |
|
@kzu A sample app (Or modifying a existing one) showcasing this "AdditionalProperties" would be helpful to understand the use case of this property |
|
@Vijay-Nirmal the scenarios are explained in #2131 (each bullet is a property in the dictionary). I have all those scenarios implemented with an in-house agent thingy that I want to replace with the agent framework. I could try to cook a fake sample, but those are all my real-world use cases. |
Co-authored-by: kzu <[email protected]>
Co-authored-by: kzu <[email protected]>
…nt, and AIAgentMetadata Co-authored-by: kzu <[email protected]>
75d49c6 to
f6c4be3
Compare
|
@kzu Sorry for back and forth, I am just trying to understand. Is this purely to store some additional Metadata in the main AIAgent object so that it can avoid create a AIAgent wrapper or custom tupe or a record like |
|
This approach follows the existing approach of adding these kinds of annotations to ChatOptions, AgentRunOptions and others. Makes them easy to extend without having to inherit (which is not even possible for ChatClientAgent which is sealed). |
|
@Vijay-Nirmal here's an example of how this property makes it easier to have a more dynamic client based on agent metadata: kzu#3 Also, see this concrete example where I drive agent-framework from configuration (including VSCode-compatible custom agent markdown) where the additional metadata can be expressed simply and drive the user experience seamlessly: https://github.com/devlooped/AI/blob/main/sample/Server/notes.agent.md |
Motivation and Context
Implements the suggestion from #2131 to add
AdditionalPropertiestoAIAgentfor custom metadata annotations (e.g., authorization requirements, payment info, beta status, visibility controls, icons).Description
This PR adds
AdditionalPropertiessupport to theAIAgentbase class and surfaces it in the current implementations (ChatClientAgent,ChatClientAgentOptions, andAIAgentMetadata).Changes
Core Implementation:
AdditionalPropertiesDictionary? AdditionalPropertiespropertyImplementation in ChatClientAgent:
AdditionalPropertiesproperty (get/set) and updatedClone()method to clone itAdditionalPropertiesproperty to return value from optionsAdditionalPropertiesproperty and updated constructor to receive it from optionsTests:
Usage
Follows the same pattern as
AgentRunOptions.AdditionalPropertiesandChatOptions.AdditionalProperties.Contribution Checklist
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.