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

* Renamed chat client extension method

* Additional renaming

* Updated documentation

* Fixed tests

* Small fix

* Small fix
This commit is contained in:
Dmytro Struk
2026-01-15 16:01:15 +00:00
committed by GitHub
parent e192af93a7
commit 2ab859dd94
99 changed files with 307 additions and 307 deletions
@@ -41,7 +41,7 @@ public sealed class AgentEntityTests(ITestOutputHelper outputHelper) : IDisposab
public async Task EntityNamePrefixAsync()
{
// Setup
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "TestAgent",
instructions: "You are a helpful assistant that always responds with a friendly greeting."
);
@@ -88,7 +88,7 @@ public sealed class AgentEntityTests(ITestOutputHelper outputHelper) : IDisposab
public async Task RunAgentMethodNamesAllWorkAsync(string runAgentMethodName)
{
// Setup
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "TestAgent",
instructions: "You are a helpful assistant that always responds with a friendly greeting."
);
@@ -143,7 +143,7 @@ public sealed class AgentEntityTests(ITestOutputHelper outputHelper) : IDisposab
public async Task OrchestrationIdSetDuringOrchestrationAsync()
{
// Arrange
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "TestAgent",
instructions: "You are a helpful assistant that always responds with a friendly greeting."
);
@@ -41,7 +41,7 @@ public sealed class ExternalClientTests(ITestOutputHelper outputHelper) : IDispo
public async Task SimplePromptAsync()
{
// Setup
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
instructions: "You are a helpful assistant that always responds with a friendly greeting.",
name: "TestAgent");
@@ -94,7 +94,7 @@ public sealed class ExternalClientTests(ITestOutputHelper outputHelper) : IDispo
return isSunny ? "Pack sunglasses and sunscreen." : "Pack a raincoat and umbrella.";
}
AIAgent tripPlanningAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent tripPlanningAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
instructions: "You are a trip planning assistant. Use the weather tool and packing list tool as needed.",
name: "TripPlanningAgent",
description: "An agent to help plan your day trips",
@@ -174,7 +174,7 @@ public sealed class ExternalClientTests(ITestOutputHelper outputHelper) : IDispo
// This is the agent that will be used to start the workflow
agents.AddAIAgentFactory(
"WorkflowAgent",
sp => TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
sp => TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "WorkflowAgent",
instructions: "You can start greeting workflows and check their status.",
services: sp,
@@ -184,7 +184,7 @@ public sealed class ExternalClientTests(ITestOutputHelper outputHelper) : IDispo
]));
// This is the agent that will be called by the workflow
agents.AddAIAgent(TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
agents.AddAIAgent(TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "SimpleAgent",
instructions: "You are a simple assistant."
));
@@ -217,14 +217,14 @@ public sealed class ExternalClientTests(ITestOutputHelper outputHelper) : IDispo
public void AsDurableAgentProxy_ThrowsWhenAgentNotRegistered()
{
// Setup: Register one agent but try to use a different one
AIAgent registeredAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent registeredAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
instructions: "You are a helpful assistant.",
name: "RegisteredAgent");
using TestHelper testHelper = TestHelper.Start([registeredAgent], this._outputHelper);
// Create an agent with a different name that isn't registered
AIAgent unregisteredAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent unregisteredAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
instructions: "You are a helpful assistant.",
name: "UnregisteredAgent");
@@ -57,7 +57,7 @@ public sealed class OrchestrationTests(ITestOutputHelper outputHelper) : IDispos
// Register a different agent, but not "NonExistentAgent"
agents.AddAIAgentFactory(
"OtherAgent",
sp => TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
sp => TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "OtherAgent",
instructions: "You are a test agent."));
},
@@ -40,7 +40,7 @@ public sealed class TimeToLiveTests(ITestOutputHelper outputHelper) : IDisposabl
{
// Arrange: Create agent with short TTL (10 seconds)
TimeSpan ttl = TimeSpan.FromSeconds(10);
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "TTLTestAgent",
instructions: "You are a helpful assistant."
);
@@ -105,7 +105,7 @@ public sealed class TimeToLiveTests(ITestOutputHelper outputHelper) : IDisposabl
{
// Arrange: Create agent with short TTL
TimeSpan ttl = TimeSpan.FromSeconds(6);
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).CreateAIAgent(
AIAgent simpleAgent = TestHelper.GetAzureOpenAIChatClient(s_configuration).AsAIAgent(
name: "TTLResetTestAgent",
instructions: "You are a helpful assistant."
);