-
Notifications
You must be signed in to change notification settings - Fork 5k
Added IChatClient implementation for PersistentAgentsClient #50898
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
Thank you for your contribution @dmytrostruk! We will review the pull request and get back to you soon. |
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
Adds support for using PersistentAgentsClient
as an IChatClient
, including implementation, tests, samples, and package updates.
- Introduce
PersistentAgentsChatClient
and its public API surface - Provide
AsIChatClient
extension method and related sample - Add tests covering synchronous, streaming, and tool-based chat scenarios
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
sdk/ai/Azure.AI.Agents.Persistent/tests/Samples/Sample_PersistentAgents_As_IChatClient.cs | New sample showing how to call AsIChatClient on PersistentAgentsClient . |
sdk/ai/Azure.AI.Agents.Persistent/tests/PersistentAgentsChatClientTests.cs | Adds end-to-end tests for PersistentAgentsChatClient , covering basic, streaming, and tool flows. |
sdk/ai/Azure.AI.Agents.Persistent/src/Custom/PersistentAgentsClientExtensions.cs | Extension method AsIChatClient to expose PersistentAgentsClient as an IChatClient . |
sdk/ai/Azure.AI.Agents.Persistent/src/Custom/PersistentAgentsChatClient.cs | Core implementation of IChatClient over PersistentAgentsClient . |
sdk/ai/Azure.AI.Agents.Persistent/src/Azure.AI.Agents.Persistent.csproj | Add dependency on Microsoft.Extensions.AI.Abstractions . |
sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.netstandard2.0.cs | Declare new public APIs for PersistentAgentsChatClient and its extension in netstandard2.0. |
sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs | Declare new public APIs for PersistentAgentsChatClient and its extension in net8.0. |
eng/Packages.Data.props | Update package reference to include Microsoft.Extensions.AI.Abstractions . |
Comments suppressed due to low confidence (1)
sdk/ai/Azure.AI.Agents.Persistent/tests/PersistentAgentsChatClientTests.cs:19
- Constants should use PascalCase (e.g., 'AgentName') instead of SCREAMING_SNAKE_CASE to follow .NET naming conventions.
private const string AGENT_NAME = "cs_e2e_tests_chat_client";
sdk/ai/Azure.AI.Agents.Persistent/src/Custom/PersistentAgentsClientExtensions.cs
Outdated
Show resolved
Hide resolved
sdk/ai/Azure.AI.Agents.Persistent/tests/PersistentAgentsChatClientTests.cs
Outdated
Show resolved
Hide resolved
sdk/ai/Azure.AI.Agents.Persistent/src/Custom/PersistentAgentsChatClient.cs
Outdated
Show resolved
Hide resolved
if (runOptions.OverrideTools is null || !runOptions.OverrideTools.Any()) | ||
{ | ||
if (_agentTools is null) | ||
{ | ||
PersistentAgent agent = await _client!.Administration.GetAgentAsync(_agentId, cancellationToken).ConfigureAwait(false); | ||
_agentTools = agent.Tools; | ||
} | ||
|
||
toolDefinitions.AddRange(_agentTools); | ||
} |
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.
This logic is required, because currently there is no way (at least I didn't find it) how to add "additional" tools on top of already existing ones rather than override tools per request. If there will be a possibility to add "additional" tools, then this logic can be removed.
With this logic, _agentTools
are stored on the class level to avoid pulling agent tools every time when user sends a request. So, there is a small possibility that agent tools can be updated on the server side, but previous tool collection will be cached in the class instance. So, it depends on how often agent tools change and if it happens rarely, this logic should be a good trade-off between performance and consistency.
…lientExtensions.cs Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
API Change CheckAPIView identified API level changes in this PR and created the following API reviews |
…trostruk/azure-sdk-for-net into persistent-agent-chat-client
sdk/ai/Azure.AI.Agents.Persistent/api/Azure.AI.Agents.Persistent.net8.0.cs
Outdated
Show resolved
Hide resolved
Regarding build error - the test recording should be pushed to the
I tried to get a permission by following a link from documentation, but it looks like I also don't have access to that link or the page doesn't exist anymore:
|
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.
Your account lacks public membership to the Azure GitHub organization and the write
permission required for an internal contributor. Please review the Azure SDK onboarding documentation and use the associated Teams channel for support.
- Azure SDK onboarding (Microsoft internal)
- Azure SDK onboarding assistance (Microsoft internal)
You can verify the state of your account by running the Validate-AzsdkCodeOwner script from the Azure SDK tools repository.
Please also be sure to add yourself to CODEOWNERS for this library, if you will be maintaining it going forward.
Thanks, working on it. |
Contributing to the Azure SDK
Please see our CONTRIBUTING.md if you are not familiar with contributing to this repository or have questions.
For specific information about pull request etiquette and best practices, see this section.