-
Notifications
You must be signed in to change notification settings - Fork 934
.NET: [BREAKING] Prevent nulls in AIAgent.Id property #2719
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: [BREAKING] Prevent nulls in AIAgent.Id property #2719
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.
Copilot reviewed 13 out of 13 changed files in this pull request and generated 2 comments.
…yMenshykh/agent-framework into refactor-agent-id-property
|
I have some second thoughts about how bad is always generating an I would suggest either:
|
We don't want it to be nullable because many calling sites would need to be updated to
In this case, consumers won't be able to access the id via a variable of the AIAgent type, which will complicate writing custom decorators and may require casting the AIAgent type variable to a specific agent type to access the id property.
Is the idea to introduce ChatClientAgent specialization for Assistant / Foundry Agents V1/V2 that will have the ServerId in addition to the Id property from AIAgent class? Note: The ChatClientAgent is sealed and thus can't be inherited.
Agent.Id and AgentThread are consistent today in a way that abstracts the consumers from the agent implementation details. This allows consumers to work with agents polymorphically, without dealing with those details. Adding an AgentThread.ConversationId property to the abstractions, which is only relevant to a few agents, does not seem right. |
This PR refactors the AIAgent.Id property to prevent it from returning nulls and, as a result, breaking consumer code. With the existing code, it's possible for a derivative to override the Id property and return null. The refactored code prevents this by disallowing the AIAgent.Id property from being overridden and falling back to a Guid value if a derivative returns null.
Contributes to: #2542