E535 .NET: Cleanup unnecessary usages of AsIChatClient by westey-m · Pull Request #4561 · microsoft/agent-framework · GitHub
[go: up one dir, main page]

Skip to content

.NET: Cleanup unnecessary usages of AsIChatClient#4561

Merged
westey-m merged 3 commits intomicrosoft:mainfrom
westey-m:asichatclient-cleanup
Mar 10, 2026
Merged

.NET: Cleanup unnecessary usages of AsIChatClient#4561
westey-m merged 3 commits intomicrosoft:mainfrom
westey-m:asichatclient-cleanup

Conversation

@westey-m
Copy link
Contributor
@westey-m westey-m commented Mar 9, 2026

Motivation and Context

#4505

Description

  • Cleanup unnecessary usages of AsIChatClient

Contribution Checklist

  • The code builds clean without any errors or warnings
  • The PR follows the Contribution Guidelines
  • All unit tests pass, and I have added new tests where possible
  • Is this a breaking change? If yes, add "[BREAKING]" prefix to the title of the PR.

Copilot AI review requested due to automatic review settings March 9, 2026 14:43
@markwallace-microsoft markwallace-microsoft added documentation Improvements or additions to documentation .NET labels Mar 9, 2026
@github-actions github-actions bot changed the title Cleanup unnecessary usages of AsIChatClient .NET: Cleanup unnecessary usages of AsIChatClient Mar 9, 2026
Copy link
Contributor
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

This PR addresses Issue #4505 by removing unnecessary .AsIChatClient() calls from sample code throughout the dotnet samples. The AsAIAgent() extension method on OpenAI.Chat.ChatClient already internally calls AsIChatClient(), so the explicit intermediate call was redundant and required an extra dependency (Microsoft.Extensions.AI.OpenAI).

Changes:

  • Replaced .GetChatClient(deploymentName).AsIChatClient().AsAIAgent(...) with .GetChatClient(deploymentName).AsAIAgent(...) across all AGUI and end-to-end sample projects.
  • Removed unnecessary Microsoft.Extensions.AI.OpenAI package references and using Microsoft.Extensions.AI; imports where they were only needed for the AsIChatClient() extension method.
  • Updated README documentation in the AGUIWebChat sample to match the simplified code pattern.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated no comments.

Show a summary per file
File Description
dotnet/samples/05-end-to-end/AspNetAgentAuthorization/Service/Service.csproj Removed Microsoft.Extensions.AI.OpenAI package reference
dotnet/samples/05-end-to-end/AspNetAgentAuthorization/Service/Program.cs Added using OpenAI.Chat;, removed .AsIChatClient() call
dotnet/samples/05-end-to-end/AGUIWebChat/Server/Program.cs Removed using Microsoft.Extensions.AI; and .AsIChatClient() call
dotnet/samples/05-end-to-end/AGUIWebChat/README.md Updated two code snippets to remove .AsIChatClient()
dotnet/samples/05-end-to-end/AGUIClientServer/AGUIDojoServer/ChatClientAgentFactory.cs Changed alias import to namespace import, removed 8 .AsIChatClient() calls
dotnet/samples/02-agents/AGUI/Step05_StateManagement/Server/Server.csproj Removed Microsoft.Extensions.AI.OpenAI package reference
dotnet/samples/02-agents/AGUI/Step05_StateManagement/Server/Program.cs Removed using Microsoft.Extensions.AI; and .AsIChatClient() call
dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Server/Server.csproj Removed Microsoft.Extensions.AI.OpenAI package reference
dotnet/samples/02-agents/AGUI/Step04_HumanInLoop/Server/Program.cs Removed .AsIChatClient() call
dotnet/samples/02-agents/AGUI/Step03_FrontendTools/Server/Server.csproj Removed Microsoft.Extensions.AI.OpenAI package reference
dotnet/samples/02-agents/AGUI/Step03_FrontendTools/Server/Program.cs Removed using Microsoft.Extensions.AI; and .AsIChatClient() call
dotnet/samples/02-agents/AGUI/Step02_BackendTools/Server/Server.csproj Removed Microsoft.Extensions.AI.OpenAI package reference
dotnet/samples/02-agents/AGUI/Step02_BackendTools/Server/Program.cs Removed .AsIChatClient() call
dotnet/samples/02-agents/AGUI/Step01_GettingStarted/Server/Server.csproj Removed Microsoft.Extensions.AI.OpenAI package reference
dotnet/samples/02-agents/AGUI/Step01_GettingStarted/Server/Program.cs Removed using Microsoft.Extensions.AI; and .AsIChatClient() call

@westey-m westey-m enabled auto-merge March 9, 2026 15:14
@westey-m westey-m added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
@westey-m westey-m added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
@westey-m westey-m added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
@westey-m westey-m added this pull request to the merge queue Mar 9, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 9, 2026
@westey-m westey-m added this pull request to the merge queue Mar 10, 2026
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Mar 10, 2026
Copilot AI review requested due to automatic review settings March 10, 2026 15:27
Copy link
Contributor
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

Copilot reviewed 15 out of 15 changed files in this pull request and generated no new comments.

@westey-m westey-m added this pull request to the merge queue Mar 10, 2026
Merged via the queue into microsoft:main with commit c15f075 Mar 10, 2026
26 checks passed
davidahmann pushed a commit to davidahmann/agent-framework that referenced this pull request Mar 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants

0