Skip to content

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

Open
wants to merge 9 commits into
base: main
Choose a base branch
from

Conversation

dmytrostruk
Copy link

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.

@Copilot Copilot AI review requested due to automatic review settings June 26, 2025 02:18
@github-actions github-actions bot added AI Model Inference AI Projects Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization. labels Jun 26, 2025
Copy link

Thank you for your contribution @dmytrostruk! We will review the pull request and get back to you soon.

Copy link
Contributor

@Copilot Copilot AI left a 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";

Comment on lines +255 to +264
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);
}
Copy link
Author

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>
Copy link

github-actions bot commented Jun 26, 2025

API Change Check

APIView identified API level changes in this PR and created the following API reviews

Azure.AI.Agents.Persistent

@dmytrostruk
Copy link
Author

Regarding build error - the test recording should be pushed to the assets repository.
I'm getting the following error:

remote: Permission to Azure/azure-sdk-assets.git denied to dmytrostruk.
fatal: unable to access 'https://github.com/Azure/azure-sdk-assets/': The requested URL returned error: 403

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:

**NOTE**: Permission is required for updating the assets repository. If you failed when executing `test-proxy push` command, please [join a partner write team](https://dev.azure.com/azure-sdk/internal/_wiki/wikis/internal.wiki/785/Externalizing-Recordings-(Asset-Sync)?anchor=permissions-to-%60azure/azure-sdk-assets%60). Please notice that this is "Microsoft Internal", community contributors will need to work with the pull request reviewers to merge the assets.

@jsquire jsquire requested a review from KrzysztofCwalina June 26, 2025 19:22
Copy link
Member

@jsquire jsquire left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dmytrostruk:

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.

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.

@dmytrostruk
Copy link
Author

Please review the Azure SDK onboarding documentation and use the associated Teams channel for support.

Thanks, working on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
AI Model Inference AI Projects Community Contribution Community members are working on the issue customer-reported Issues that are reported by GitHub users external to the Azure organization.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants