Skip to content

.NET: [BREAKING] Renamed CreateAIAgent/GetAIAgent to AsAIAgent#3222

Merged
dmytrostruk merged 10 commits intomicrosoft:mainfrom
dmytrostruk:dotnet-as-agent-rename
Jan 15, 2026
Merged

.NET: [BREAKING] Renamed CreateAIAgent/GetAIAgent to AsAIAgent#3222
dmytrostruk merged 10 commits intomicrosoft:mainfrom
dmytrostruk:dotnet-as-agent-rename

Conversation

@dmytrostruk
Copy link
Member

Motivation and Context

Related ADR: https://github.com/microsoft/agent-framework/blob/main/docs/decisions/0011-create-get-agent-api.md

This PR renames extension methods that create local wrapper agents from CreateAIAgent/GetAIAgent to AsAIAgent, following naming conventions where As* indicates a lightweight conversion/wrapping operation without side effects.

Methods that perform server-side operations (create/retrieve agents from remote services) keep their original names.

// Before
var agent = chatClient.CreateAIAgent(options);

// After
var agent = chatClient.AsAIAgent(options);

Impacted Classes:

  • Microsoft.Agents.AI
    • ChatClientExtensions - CreateAIAgent → AsAIAgent
  • Microsoft.Agents.AI.OpenAI
    • OpenAIChatClientExtensions - CreateAIAgent → AsAIAgent
    • OpenAIResponseClientExtensions - CreateAIAgent → AsAIAgent
    • OpenAIAssistantClientExtensions - GetAIAgent (metadata overloads only) → AsAIAgent
  • Microsoft.Agents.AI.AzureAI
    • AzureAIProjectChatClientExtensions - GetAIAgent (AgentRecord/AgentVersion overloads) → AsAIAgent
  • Microsoft.Agents.AI.AzureAI.Persistent
    • PersistentAgentsClientExtensions - GetAIAgent (Response/PersistentAgent overloads) → AsAIAgent
  • Microsoft.Agents.AI.Anthropic
    • AnthropicClientExtensions - CreateAIAgent → AsAIAgent
    • AnthropicBetaServiceExtensions - CreateAIAgent → AsAIAgent
  • Microsoft.Agents.AI.A2A
    • A2AClientExtensions - GetAIAgent → AsAIAgent
    • A2AAgentCardExtensions - GetAIAgent → AsAIAgent

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.

@dmytrostruk dmytrostruk self-assigned this Jan 14, 2026
Copilot AI review requested due to automatic review settings January 14, 2026 21:12
@dmytrostruk dmytrostruk added .NET breaking change Introduces changes that are not backward compatible and may require updates to dependent code. labels Jan 14, 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 implements a breaking change to rename extension methods that create local wrapper agents from CreateAIAgent/GetAIAgent to AsAIAgent, following the naming convention where As* indicates a lightweight conversion/wrapping operation without side effects. Methods that perform server-side operations (create/retrieve agents from remote services) retain their original CreateAIAgent/GetAIAgent names.

Changes:

  • Renamed local wrapper methods across all agent client extension classes to use AsAIAgent naming
  • Updated all test files to use the new method names
  • Updated all sample files to use the new method names

Reviewed changes

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

Show a summary per file
File Description
ChatClientExtensions.cs Renamed CreateAIAgent → AsAIAgent for local wrapper methods
ChatClientBuilderExtensions.cs Updated calls to use AsAIAgent
OpenAIResponseClientExtensions.cs Renamed CreateAIAgent → AsAIAgent for local wrapper methods
OpenAIChatClientExtensions.cs Renamed CreateAIAgent → AsAIAgent for local wrapper methods
OpenAIAssistantClientExtensions.cs Renamed GetAIAgent → AsAIAgent for metadata-based wrapper methods only
AzureAIProjectChatClientExtensions.cs Renamed GetAIAgent → AsAIAgent for AgentRecord/AgentVersion overloads
PersistentAgentsClientExtensions.cs Renamed GetAIAgent → AsAIAgent for Response/PersistentAgent overloads
AnthropicClientExtensions.cs Renamed CreateAIAgent → AsAIAgent for local wrapper methods
AnthropicBetaServiceExtensions.cs Renamed CreateAIAgent → AsAIAgent for local wrapper methods
A2AClientExtensions.cs Renamed GetAIAgent → AsAIAgent
A2AAgentCardExtensions.cs Renamed GetAIAgent → AsAIAgent
A2ACardResolverExtensions.cs Updated call to use AsAIAgent
AzureAgentProvider.cs Updated call to use AsAIAgent
Test files (13 files) Updated all method calls from CreateAIAgent/GetAIAgent to AsAIAgent
Sample files (47 files) Updated all method calls from CreateAIAgent/GetAIAgent to AsAIAgent
Comments suppressed due to low confidence (1)

dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs:199

  • The XML documentation comment is misleading. The method at line 208 retrieves an existing server-side agent (as evidenced by the call to GetAgentRecordByName at line 225), it does not create a new agent. The comment should say 'Retrieves an existing server side agent' or similar to match the actual behavior and be consistent with other GetAIAgent overloads in this file.

@markwallace-microsoft markwallace-microsoft added the documentation Improvements or additions to documentation label Jan 14, 2026
This was referenced Jan 24, 2026
arisng pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
…soft#3222)

* Renamed chat client extension method

* Additional renaming

* Updated documentation

* Fixed tests

* Small fix

* Small fix
arisng pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
…nctions (microsoft#3042)

* Durable Agent samples and automated validation for non-Azure Functions

* Update test projects

* fix file encoding

* Remove AgentThreadMetadata usage

* Absorb breaking change from microsoft#3152

* Absorb newer breaking changes (AgentRunResponse --> AgentResponse)

* Absorb more breaking changes (see microsoft#3222)

* Improve integration test reliability (isolated task hubs, etc.)

* Fix flakey streaming test

---------

Co-authored-by: Mark Wallace <127216156+markwallace-microsoft@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking change Introduces changes that are not backward compatible and may require updates to dependent code. documentation Improvements or additions to documentation .NET

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants