diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props
index 69182a6fc5..cf32afe49c 100644
--- a/dotnet/Directory.Packages.props
+++ b/dotnet/Directory.Packages.props
@@ -17,7 +17,8 @@
-
+
+
diff --git a/dotnet/agent-framework-dotnet.slnx b/dotnet/agent-framework-dotnet.slnx
index a43f439ca7..102b24b4cc 100644
--- a/dotnet/agent-framework-dotnet.slnx
+++ b/dotnet/agent-framework-dotnet.slnx
@@ -44,8 +44,8 @@
-
-
+
+
diff --git a/dotnet/nuget.config b/dotnet/nuget.config
index f7e74aa056..10d2f1e7e5 100644
--- a/dotnet/nuget.config
+++ b/dotnet/nuget.config
@@ -10,7 +10,7 @@
-
+
\ No newline at end of file
diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryAgent/Agent_With_AzureFoundryAgent.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/Agent_With_AzureAIAgentsPersistent.csproj
similarity index 100%
rename from dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryAgent/Agent_With_AzureFoundryAgent.csproj
rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/Agent_With_AzureAIAgentsPersistent.csproj
diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryAgent/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/Program.cs
similarity index 100%
rename from dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryAgent/Program.cs
rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/Program.cs
diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/README.md
similarity index 100%
rename from dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/README.md
rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/README.md
diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/Agent_With_AzureAIAgent.csproj b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Agent_With_AzureAIProject.csproj
similarity index 90%
rename from dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/Agent_With_AzureAIAgent.csproj
rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Agent_With_AzureAIProject.csproj
index 61f6c90316..057a0fc507 100644
--- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/Agent_With_AzureAIAgent.csproj
+++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Agent_With_AzureAIProject.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/Program.cs b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Program.cs
similarity index 75%
rename from dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/Program.cs
rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Program.cs
index 1c2628d8f9..dd4a011e4d 100644
--- a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgent/Program.cs
+++ b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Program.cs
@@ -2,7 +2,8 @@
// This sample shows how to create and use a AI agents with Azure Foundry Agents as the backend.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
@@ -13,13 +14,13 @@ const string JokerInstructions = "You are good at telling jokes.";
const string JokerName = "JokerAgent";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-var agentsClient = new AgentClient(new Uri(endpoint), new AzureCliCredential());
+var aiProjectClient = new AIProjectClient(new Uri(endpoint), new AzureCliCredential());
// Define the agent you want to create. (Prompt Agent in this case)
var agentVersionCreationOptions = new AgentVersionCreationOptions(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions });
// Azure.AI.Agents SDK creates and manages agent by name and versions.
// You can create a server side agent version with the Azure.AI.Agents SDK client below.
-var agentVersion = agentsClient.CreateAgentVersion(agentName: JokerName, options: agentVersionCreationOptions);
+var agentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options: agentVersionCreationOptions);
// Note:
// agentVersion.Id = ":",
@@ -27,13 +28,13 @@ var agentVersion = agentsClient.CreateAgentVersion(agentName: JokerName, options
// agentVersion.Name =
// You can retrieve an AIAgent for a already created server side agent version.
-AIAgent jokerAgentV1 = agentsClient.GetAIAgent(agentVersion);
+AIAgent jokerAgentV1 = aiProjectClient.GetAIAgent(agentVersion);
// You can also create another AIAgent version (V2) by providing the same name with a different definition.
-AIAgent jokerAgentV2 = agentsClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions + "V2");
+AIAgent jokerAgentV2 = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions + "V2");
// You can also get the AIAgent latest version just providing its name.
-AIAgent jokerAgentLatest = agentsClient.GetAIAgent(name: JokerName);
+AIAgent jokerAgentLatest = aiProjectClient.GetAIAgent(name: JokerName);
var latestVersion = jokerAgentLatest.GetService()!;
// The AIAgent version can be accessed via the GetService method.
@@ -47,7 +48,4 @@ Console.WriteLine(await jokerAgentLatest.RunAsync("Tell me a joke about a pirate
Console.WriteLine(await jokerAgentLatest.RunAsync("Now tell me a joke about a cat and a dog using last joke as the anchor.", thread));
// Cleanup by agent name removes both agent versions created (jokerAgentV1 + jokerAgentV2).
-agentsClient.DeleteAgent(jokerAgentV1.Name);
-
-// It is also possible delete just a specific agent version by the composition (name + version number).
-// agentsClient.DeleteAgentVersion(latestVersion.Name, latestVersion.Version);
+aiProjectClient.Agents.DeleteAgent(jokerAgentV1.Name);
diff --git a/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryAgent/README.md b/dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/README.md
similarity index 100%
rename from dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureFoundryAgent/README.md
rename to dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/README.md
diff --git a/dotnet/samples/GettingStarted/AgentProviders/README.md b/dotnet/samples/GettingStarted/AgentProviders/README.md
index 4e84cd4f08..5d32f2542b 100644
--- a/dotnet/samples/GettingStarted/AgentProviders/README.md
+++ b/dotnet/samples/GettingStarted/AgentProviders/README.md
@@ -15,7 +15,8 @@ See the README.md for each sample for the prerequisites for that sample.
|Sample|Description|
|---|---|
|[Creating an AIAgent with A2A](./Agent_With_A2A/)|This sample demonstrates how to create AIAgent for an existing A2A agent.|
-|[Creating an AIAgent with AzureFoundry Agent](./Agent_With_AzureFoundryAgent/)|This sample demonstrates how to create an Azure Foundry agent and expose it as an AIAgent|
+|[Creating an AIAgent with Foundry Agents using Azure.AI.Agents.Persistent](./Agent_With_AzureAIAgentsPersistent/)|This sample demonstrates how to create a Foundry Persistent agent and expose it as an AIAgent using the Azure.AI.Agents.Persistent SDK|
+|[Creating an AIAgent with Foundry Agents using Azure.AI.Project](./Agent_With_AzureAIProject/)|This sample demonstrates how to create an Foundry Project agent and expose it as an AIAgent using the Azure.AI.Project SDK|
|[Creating an AIAgent with AzureFoundry Model](./Agent_With_AzureFoundryModel/)|This sample demonstrates how to use any model deployed to Azure Foundry to create an AIAgent|
|[Creating an AIAgent with Azure OpenAI ChatCompletion](./Agent_With_AzureOpenAIChatCompletion/)|This sample demonstrates how to create an AIAgent using Azure OpenAI ChatCompletion as the underlying inference service|
|[Creating an AIAgent with Azure OpenAI Responses](./Agent_With_AzureOpenAIResponses/)|This sample demonstrates how to create an AIAgent using Azure OpenAI Responses as the underlying inference service|
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/FoundryAgents_Step01.1_Basics.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/FoundryAgents_Step01.1_Basics.csproj
index 6d0e3c1272..a2ccc2a339 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/FoundryAgents_Step01.1_Basics.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/FoundryAgents_Step01.1_Basics.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/Program.cs
index 6988643a0d..c51d345c11 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/Program.cs
@@ -2,7 +2,8 @@
// This sample shows how to create and use AI agents with Azure Foundry Agents as the backend.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -14,14 +15,14 @@ const string JokerInstructions = "You are good at telling jokes.";
const string JokerName = "JokerAgent";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent you want to create. (Prompt Agent in this case)
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions });
// Azure.AI.Agents SDK creates and manages agent by name and versions.
// You can create a server side agent version with the Azure.AI.Agents SDK client below.
-AgentVersion agentVersion = agentClient.CreateAgentVersion(agentName: JokerName, options);
+AgentVersion agentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options);
// Note:
// agentVersion.Id = ":",
@@ -29,13 +30,13 @@ AgentVersion agentVersion = agentClient.CreateAgentVersion(agentName: JokerName,
// agentVersion.Name =
// You can retrieve an AIAgent for an already created server side agent version.
-AIAgent jokerAgentV1 = agentClient.GetAIAgent(agentVersion);
+AIAgent jokerAgentV1 = aiProjectClient.GetAIAgent(agentVersion);
// You can also create another AIAgent version (V2) by providing the same name with a different definition.
-AIAgent jokerAgentV2 = agentClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions + "V2");
+AIAgent jokerAgentV2 = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions + "V2");
// You can also get the AIAgent latest version by just providing its name.
-AIAgent jokerAgentLatest = agentClient.GetAIAgent(name: JokerName);
+AIAgent jokerAgentLatest = aiProjectClient.GetAIAgent(name: JokerName);
AgentVersion latestVersion = jokerAgentLatest.GetService()!;
// The AIAgent version can be accessed via the GetService method.
@@ -49,7 +50,4 @@ Console.WriteLine(await jokerAgentLatest.RunAsync("Tell me a joke about a pirate
Console.WriteLine(await jokerAgentLatest.RunAsync("Now tell me a joke about a cat and a dog using last joke as the anchor.", thread));
// Cleanup by agent name removes both agent versions created (jokerAgentV1 + jokerAgentV2).
-await agentClient.DeleteAgentAsync(jokerAgentV1.Name);
-
-// It is also possible delete just a specific agent version by the composition (name + version number).
-// agentClient.DeleteAgentVersion(latestVersion.Name, latestVersion.Version);
+await aiProjectClient.Agents.DeleteAgentAsync(jokerAgentV1.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/FoundryAgents_Step01.2_Running.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/FoundryAgents_Step01.2_Running.csproj
index f15f7740e9..3ed207aadf 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/FoundryAgents_Step01.2_Running.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/FoundryAgents_Step01.2_Running.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/Program.cs
index fd26f5a4aa..bd5620ff1f 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/Program.cs
@@ -2,7 +2,8 @@
// This sample shows how to create and use a simple AI agent with Azure Foundry Agents as the backend.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
@@ -13,17 +14,17 @@ const string JokerInstructions = "You are good at telling jokes.";
const string JokerName = "JokerAgent";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent you want to create. (Prompt Agent in this case)
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions });
// Azure.AI.Agents SDK creates and manages agent by name and versions.
// You can create a server side agent version with the Azure.AI.Agents SDK client below.
-AgentVersion agentVersion = agentClient.CreateAgentVersion(agentName: JokerName, options);
+AgentVersion agentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options);
// You can retrieve an AIAgent for a already created server side agent version.
-AIAgent jokerAgent = agentClient.GetAIAgent(agentVersion);
+AIAgent jokerAgent = aiProjectClient.GetAIAgent(agentVersion);
// Invoke the agent and output the text result.
AgentThread thread = jokerAgent.GetNewThread();
@@ -37,4 +38,4 @@ await foreach (AgentRunResponseUpdate update in jokerAgent.RunStreamingAsync("Te
}
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(jokerAgent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(jokerAgent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/FoundryAgents_Step02_MultiturnConversation.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/FoundryAgents_Step02_MultiturnConversation.csproj
index f15f7740e9..3ed207aadf 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/FoundryAgents_Step02_MultiturnConversation.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/FoundryAgents_Step02_MultiturnConversation.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/Program.cs
index 911da5fc33..3cbb0099ea 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/Program.cs
@@ -2,7 +2,8 @@
// This sample shows how to create and use a simple AI agent with a multi-turn conversation.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
@@ -13,16 +14,16 @@ const string JokerInstructions = "You are good at telling jokes.";
const string JokerName = "JokerAgent";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent you want to create. (Prompt Agent in this case)
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions });
// Create a server side agent version with the Azure.AI.Agents SDK client.
-AgentVersion agentVersion = agentClient.CreateAgentVersion(agentName: JokerName, options);
+AgentVersion agentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options);
// Retrieve an AIAgent for the created server side agent version.
-AIAgent jokerAgent = agentClient.GetAIAgent(agentVersion);
+AIAgent jokerAgent = aiProjectClient.GetAIAgent(agentVersion);
// Invoke the agent with a multi-turn conversation, where the context is preserved in the thread object.
AgentThread thread = jokerAgent.GetNewThread();
@@ -41,4 +42,4 @@ await foreach (AgentRunResponseUpdate update in jokerAgent.RunStreamingAsync("No
}
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(jokerAgent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(jokerAgent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/FoundryAgents_Step03.1_UsingFunctionTools.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/FoundryAgents_Step03.1_UsingFunctionTools.csproj
index f15f7740e9..3ed207aadf 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/FoundryAgents_Step03.1_UsingFunctionTools.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/FoundryAgents_Step03.1_UsingFunctionTools.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/Program.cs
index b24b3e6651..e2af503905 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/Program.cs
@@ -4,7 +4,7 @@
// It shows both non-streaming and streaming agent interactions using weather-related tools.
using System.ComponentModel;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -20,13 +20,13 @@ const string AssistantInstructions = "You are a helpful assistant that can get w
const string AssistantName = "WeatherAssistant";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent with function tools.
AITool tool = AIFunctionFactory.Create(GetWeather);
// Create AIAgent directly
-AIAgent agent = await agentClient.CreateAIAgentAsync(name: AssistantName, model: deploymentName, instructions: AssistantInstructions, tools: [tool]);
+AIAgent agent = await aiProjectClient.CreateAIAgentAsync(name: AssistantName, model: deploymentName, instructions: AssistantInstructions, tools: [tool]);
// Non-streaming agent interaction with function tools.
AgentThread thread = agent.GetNewThread();
@@ -40,4 +40,4 @@ await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync("What is
}
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI.csproj
index fd26283f13..90bc94a20f 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/Program.cs
index 7b5abaadf4..f9540d1725 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/Program.cs
@@ -3,7 +3,7 @@
// This sample demonstrates how to use an agent with function tools provided via an OpenAPI spec.
// It uses functionality from Semantic Kernel to parse the OpenAPI spec and create function tools to use with the Agent Framework Agent.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -25,14 +25,14 @@ const string AssistantInstructions = "You are a helpful assistant that can query
const string AssistantName = "GitHubAssistant";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Create AIAgent directly
-AIAgent agent = await agentClient.CreateAIAgentAsync(name: AssistantName, model: deploymentName, instructions: AssistantInstructions, tools: tools);
+AIAgent agent = await aiProjectClient.CreateAIAgentAsync(name: AssistantName, model: deploymentName, instructions: AssistantInstructions, tools: tools);
// Run the agent with the OpenAPI function tools.
AgentThread thread = agent.GetNewThread();
Console.WriteLine(await agent.RunAsync("Please list the names, colors and descriptions of all the labels available in the microsoft/agent-framework repository on github.", thread));
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/FoundryAgents_Step04_UsingFunctionToolsWithApprovals.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/FoundryAgents_Step04_UsingFunctionToolsWithApprovals.csproj
index f15f7740e9..3ed207aadf 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/FoundryAgents_Step04_UsingFunctionToolsWithApprovals.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/FoundryAgents_Step04_UsingFunctionToolsWithApprovals.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/Program.cs
index d2d56bfa7b..bd72a2c940 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/Program.cs
@@ -6,7 +6,7 @@
// while the agent is waiting for user input.
using System.ComponentModel;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -23,12 +23,12 @@ const string AssistantInstructions = "You are a helpful assistant that can get w
const string AssistantName = "WeatherAssistant";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
ApprovalRequiredAIFunction approvalTool = new(AIFunctionFactory.Create(GetWeather));
// Create AIAgent directly
-AIAgent agent = await agentClient.CreateAIAgentAsync(name: AssistantName, model: deploymentName, instructions: AssistantInstructions, tools: [approvalTool]);
+AIAgent agent = await aiProjectClient.CreateAIAgentAsync(name: AssistantName, model: deploymentName, instructions: AssistantInstructions, tools: [approvalTool]);
// Call the agent with approval-required function tools.
// The agent will request approval before invoking the function.
@@ -61,4 +61,4 @@ while (userInputRequests.Count > 0)
Console.WriteLine($"\nAgent: {response}");
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/FoundryAgents_Step05_StructuredOutput.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/FoundryAgents_Step05_StructuredOutput.csproj
index f15f7740e9..3ed207aadf 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/FoundryAgents_Step05_StructuredOutput.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/FoundryAgents_Step05_StructuredOutput.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/Program.cs
index d68895f08d..0edbed70e8 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/Program.cs
@@ -5,7 +5,7 @@
using System.ComponentModel;
using System.Text.Json;
using System.Text.Json.Serialization;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using SampleApp;
@@ -19,10 +19,10 @@ const string AssistantInstructions = "You are a helpful assistant that extracts
const string AssistantName = "StructuredOutputAssistant";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Create ChatClientAgent directly
-ChatClientAgent agent = await agentClient.CreateAIAgentAsync(
+ChatClientAgent agent = await aiProjectClient.CreateAIAgentAsync(
model: deploymentName,
new ChatClientAgentOptions(name: AssistantName, instructions: AssistantInstructions)
{
@@ -42,7 +42,7 @@ Console.WriteLine($"Age: {response.Result.Age}");
Console.WriteLine($"Occupation: {response.Result.Occupation}");
// Create the ChatClientAgent with the specified name, instructions, and expected structured output the agent should produce.
-ChatClientAgent agentWithPersonInfo = agentClient.CreateAIAgent(
+ChatClientAgent agentWithPersonInfo = aiProjectClient.CreateAIAgent(
model: deploymentName,
new ChatClientAgentOptions(name: AssistantName, instructions: AssistantInstructions)
{
@@ -65,7 +65,7 @@ Console.WriteLine($"Age: {personInfo.Age}");
Console.WriteLine($"Occupation: {personInfo.Occupation}");
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
namespace SampleApp
{
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/FoundryAgents_Step06_PersistedConversations.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/FoundryAgents_Step06_PersistedConversations.csproj
index f15f7740e9..3ed207aadf 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/FoundryAgents_Step06_PersistedConversations.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/FoundryAgents_Step06_PersistedConversations.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/Program.cs
index dc3f32a695..305422aa4d 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/Program.cs
@@ -3,7 +3,7 @@
// This sample shows how to create and use a simple AI agent with a conversation that can be persisted to disk.
using System.Text.Json;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
@@ -14,9 +14,9 @@ const string JokerInstructions = "You are good at telling jokes.";
const string JokerName = "JokerAgent";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
-AIAgent agent = await agentClient.CreateAIAgentAsync(name: JokerName, model: deploymentName, instructions: JokerInstructions);
+AIAgent agent = await aiProjectClient.CreateAIAgentAsync(name: JokerName, model: deploymentName, instructions: JokerInstructions);
// Start a new thread for the agent conversation.
AgentThread thread = agent.GetNewThread();
@@ -41,4 +41,4 @@ AgentThread resumedThread = agent.DeserializeThread(reloadedSerializedThread);
Console.WriteLine(await agent.RunAsync("Now tell the same joke in the voice of a pirate, and add some emojis to the joke.", resumedThread));
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/FoundryAgents_Step07_Observability.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/FoundryAgents_Step07_Observability.csproj
index a3f6998125..49b903d041 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/FoundryAgents_Step07_Observability.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/FoundryAgents_Step07_Observability.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/Program.cs
index 50e4bd93d4..eb011ba064 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step07_Observability/Program.cs
@@ -2,7 +2,7 @@
// This sample shows how to create and use a simple AI agent with Azure Foundry Agents as the backend that logs telemetry using OpenTelemetry.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Azure.Monitor.OpenTelemetry.Exporter;
using Microsoft.Agents.AI;
@@ -29,10 +29,10 @@ if (!string.IsNullOrWhiteSpace(applicationInsightsConnectionString))
using var tracerProvider = tracerProviderBuilder.Build();
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent you want to create. (Prompt Agent in this case)
-AIAgent agent = agentClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions)
+AIAgent agent = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions)
.AsBuilder()
.UseOpenTelemetry(sourceName: sourceName)
.Build();
@@ -49,4 +49,4 @@ await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync("Tell me
}
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/FoundryAgents_Step08_DependencyInjection.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/FoundryAgents_Step08_DependencyInjection.csproj
index 75c84b0987..ea8fc63de0 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/FoundryAgents_Step08_DependencyInjection.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/FoundryAgents_Step08_DependencyInjection.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/Program.cs
index f3e42a75c1..4bf4843d66 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/Program.cs
@@ -2,7 +2,7 @@
// This sample shows how to use dependency injection to register an AIAgent and use it from a hosted service with a user input chat loop.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.DependencyInjection;
@@ -18,11 +18,11 @@ const string JokerName = "JokerAgent";
HostApplicationBuilder builder = Host.CreateApplicationBuilder(args);
// Add the agents client to the service collection.
-builder.Services.AddSingleton((sp) => new AgentClient(new Uri(endpoint), new AzureCliCredential()));
+builder.Services.AddSingleton((sp) => new AIProjectClient(new Uri(endpoint), new AzureCliCredential()));
// Add the AI agent to the service collection.
builder.Services.AddSingleton((sp)
- => sp.GetRequiredService()
+ => sp.GetRequiredService()
.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions));
// Add a sample service that will use the agent to respond to user input.
@@ -35,7 +35,7 @@ await host.RunAsync().ConfigureAwait(false);
///
/// A sample service that uses an AI agent to respond to user input.
///
-internal sealed class SampleService(AgentClient client, AIAgent agent, IHostApplicationLifetime appLifetime) : IHostedService
+internal sealed class SampleService(AIProjectClient client, AIAgent agent, IHostApplicationLifetime appLifetime) : IHostedService
{
private AgentThread? _thread;
@@ -77,6 +77,6 @@ internal sealed class SampleService(AgentClient client, AIAgent agent, IHostAppl
public async Task StopAsync(CancellationToken cancellationToken)
{
Console.WriteLine("\nDeleting agent ...");
- await client.DeleteAgentAsync(agent.Name, cancellationToken).ConfigureAwait(false);
+ await client.Agents.DeleteAgentAsync(agent.Name, cancellationToken).ConfigureAwait(false);
}
}
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/README.md b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/README.md
index 8c82590ff2..ab2b01e5d1 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/README.md
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step08_DependencyInjection/README.md
@@ -5,7 +5,7 @@ This sample demonstrates how to use dependency injection to register and manage
## What this sample demonstrates
- Setting up dependency injection with HostApplicationBuilder
-- Registering AgentClient as a singleton service
+- Registering AIProjectClient as a singleton service
- Registering AIAgent as a singleton service
- Using agents in hosted services
- Interactive chat loop with streaming responses
@@ -42,7 +42,7 @@ dotnet run --project .\FoundryAgents_Step08_DependencyInjection
The sample will:
1. Create a host with dependency injection configured
-2. Register AgentClient and AIAgent as services
+2. Register AIProjectClient and AIAgent as services
3. Create an agent named "JokerAgent" with instructions to tell jokes
4. Start an interactive chat loop where you can ask the agent questions
5. The agent will respond with streaming output
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step09_UsingMcpClientAsTools/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step09_UsingMcpClientAsTools/Program.cs
index ef273dfe06..a821c1194b 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step09_UsingMcpClientAsTools/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step09_UsingMcpClientAsTools/Program.cs
@@ -2,7 +2,7 @@
// This sample shows how to expose an AI agent as an MCP tool.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -25,12 +25,12 @@ await using var mcpClient = await McpClient.CreateAsync(new StdioClientTransport
IList mcpTools = await mcpClient.ListToolsAsync();
string agentName = "AgentWithMCP";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
Console.WriteLine($"Creating the agent '{agentName}' ...");
// Define the agent you want to create. (Prompt Agent in this case)
-AIAgent agent = agentClient.CreateAIAgent(
+AIAgent agent = aiProjectClient.CreateAIAgent(
name: agentName,
model: deploymentName,
instructions: "You answer questions related to GitHub repositories only.",
@@ -44,4 +44,4 @@ Console.WriteLine($"Invoking agent '{agent.Name}' with prompt: {prompt} ...");
Console.WriteLine(await agent.RunAsync(prompt));
// Clean up the agent after use.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/FoundryAgents_Step10_UsingImages.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/FoundryAgents_Step10_UsingImages.csproj
index 8cd91af15d..d0cd81c352 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/FoundryAgents_Step10_UsingImages.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/FoundryAgents_Step10_UsingImages.csproj
@@ -9,7 +9,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/Program.cs
index 9ed0e5a64b..52ee408a25 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step10_UsingImages/Program.cs
@@ -2,7 +2,7 @@
// This sample shows how to use Image Multi-Modality with an AI agent.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -14,10 +14,10 @@ const string VisionInstructions = "You are a helpful agent that can analyze imag
const string VisionName = "VisionAgent";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent you want to create. (Prompt Agent in this case)
-AIAgent agent = agentClient.CreateAIAgent(name: VisionName, model: deploymentName, instructions: VisionInstructions);
+AIAgent agent = aiProjectClient.CreateAIAgent(name: VisionName, model: deploymentName, instructions: VisionInstructions);
ChatMessage message = new(ChatRole.User, [
new TextContent("What do you see in this image?"),
@@ -32,4 +32,4 @@ await foreach (AgentRunResponseUpdate update in agent.RunStreamingAsync(message,
}
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/FoundryAgents_Step11_AsFunctionTool.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/FoundryAgents_Step11_AsFunctionTool.csproj
index bfa873c0b5..f9336d4556 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/FoundryAgents_Step11_AsFunctionTool.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/FoundryAgents_Step11_AsFunctionTool.csproj
@@ -10,7 +10,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/Program.cs
index 49eefb0850..9fb589f5ce 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step11_AsFunctionTool/Program.cs
@@ -3,7 +3,7 @@
// This sample shows how to create and use an Azure Foundry Agents AI agent as a function tool.
using System.ComponentModel;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -21,18 +21,18 @@ static string GetWeather([Description("The location to get the weather for.")] s
=> $"The weather in {location} is cloudy with a high of 15°C.";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Create the weather agent with function tools.
AITool weatherTool = AIFunctionFactory.Create(GetWeather);
-AIAgent weatherAgent = agentClient.CreateAIAgent(
+AIAgent weatherAgent = aiProjectClient.CreateAIAgent(
name: WeatherName,
model: deploymentName,
instructions: WeatherInstructions,
tools: [weatherTool]);
// Create the main agent, and provide the weather agent as a function tool.
-AIAgent agent = agentClient.CreateAIAgent(
+AIAgent agent = aiProjectClient.CreateAIAgent(
name: MainName,
model: deploymentName,
instructions: MainInstructions,
@@ -43,5 +43,5 @@ AgentThread thread = agent.GetNewThread();
Console.WriteLine(await agent.RunAsync("What is the weather like in Amsterdam?", thread));
// Cleanup by agent name removes the agent versions created.
-await agentClient.DeleteAgentAsync(agent.Name);
-await agentClient.DeleteAgentAsync(weatherAgent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(weatherAgent.Name);
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/FoundryAgents_Step12_Middleware.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/FoundryAgents_Step12_Middleware.csproj
index dfacd205df..4de5d131d9 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/FoundryAgents_Step12_Middleware.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/FoundryAgents_Step12_Middleware.csproj
@@ -11,7 +11,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/Program.cs
index 7be84d99b0..0a00e9107c 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step12_Middleware/Program.cs
@@ -7,7 +7,7 @@
using System.ComponentModel;
using System.Text.RegularExpressions;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -20,7 +20,7 @@ const string AssistantInstructions = "You are an AI assistant that helps people
const string AssistantName = "InformationAssistant";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
[Description("Get the weather for a given location.")]
static string GetWeather([Description("The location to get the weather for.")] string location)
@@ -34,7 +34,7 @@ AITool dateTimeTool = AIFunctionFactory.Create(GetDateTime, name: nameof(GetDate
AITool getWeatherTool = AIFunctionFactory.Create(GetWeather, name: nameof(GetWeather));
// Define the agent you want to create. (Prompt Agent in this case)
-AIAgent originalAgent = agentClient.CreateAIAgent(
+AIAgent originalAgent = aiProjectClient.CreateAIAgent(
name: AssistantName,
model: deploymentName,
instructions: AssistantInstructions,
@@ -69,7 +69,7 @@ Console.WriteLine($"Function calling response: {functionCallResponse}");
// Special per-request middleware agent.
Console.WriteLine("\n\n=== Example 4: Middleware with human in the loop function approval ===");
-AIAgent humamInTheLoopAgent = agentClient.CreateAIAgent(
+AIAgent humanInTheLoopAgent = aiProjectClient.CreateAIAgent(
name: "HumanInTheLoopAgent",
model: deploymentName,
instructions: "You are an Human in the loop testing AI assistant that helps people find information.",
@@ -78,13 +78,13 @@ AIAgent humamInTheLoopAgent = agentClient.CreateAIAgent(
tools: [new ApprovalRequiredAIFunction(AIFunctionFactory.Create(GetWeather, name: nameof(GetWeather)))]);
// Using the ConsolePromptingApprovalMiddleware for a specific request to handle user approval during function calls.
-AgentRunResponse response = await humamInTheLoopAgent
+AgentRunResponse response = await humanInTheLoopAgent
.AsBuilder()
.Use(ConsolePromptingApprovalMiddleware, null)
.Build()
.RunAsync("What's the current time and the weather in Seattle?");
-Console.WriteLine($"HumamInTheLoopAgent agent middleware response: {response}");
+Console.WriteLine($"HumanInTheLoopAgent agent middleware response: {response}");
// Function invocation middleware that logs before and after function calls.
async ValueTask
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step13_Plugins/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step13_Plugins/Program.cs
index 441f98b090..b55f38b66b 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step13_Plugins/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step13_Plugins/Program.cs
@@ -9,7 +9,7 @@
// as AI functions. The AsAITools method of the plugin class shows how to specify
// which methods should be exposed to the AI agent.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -30,11 +30,11 @@ services.AddSingleton(); // The plugin depends on WeatherProvider a
IServiceProvider serviceProvider = services.BuildServiceProvider();
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Define the agent with plugin tools
// Define the agent you want to create. (Prompt Agent in this case)
-AIAgent agent = agentClient.CreateAIAgent(
+AIAgent agent = aiProjectClient.CreateAIAgent(
name: AssistantName,
model: deploymentName,
instructions: AssistantInstructions,
@@ -46,7 +46,7 @@ AgentThread thread = agent.GetNewThread();
Console.WriteLine(await agent.RunAsync("Tell me current time and weather in Seattle.", thread));
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agent.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agent.Name);
///
/// The agent plugin that provides weather and current time information.
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/FoundryAgents_Step14_CodeInterpreter.csproj b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/FoundryAgents_Step14_CodeInterpreter.csproj
index 1b3fd881a3..1c8496b239 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/FoundryAgents_Step14_CodeInterpreter.csproj
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/FoundryAgents_Step14_CodeInterpreter.csproj
@@ -12,7 +12,7 @@
-
+
diff --git a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/Program.cs b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/Program.cs
index 9a00124200..0a70ca76df 100644
--- a/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/Program.cs
+++ b/dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step14_CodeInterpreter/Program.cs
@@ -3,7 +3,8 @@
// This sample shows how to use Code Interpreter Tool with AI Agents.
using System.Text;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -18,11 +19,11 @@ const string AgentNameMEAI = "CoderAgent-MEAI";
const string AgentNameNative = "CoderAgent-NATIVE";
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
-AgentClient agentClient = new(new Uri(endpoint), new AzureCliCredential());
+AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
// Option 1 - Using HostedCodeInterpreterTool + AgentOptions (MEAI + AgentFramework)
// Create the server side agent version
-AIAgent agentOption1 = await agentClient.CreateAIAgentAsync(
+AIAgent agentOption1 = await aiProjectClient.CreateAIAgentAsync(
model: deploymentName,
name: AgentNameMEAI,
instructions: AgentInstructions,
@@ -30,7 +31,7 @@ AIAgent agentOption1 = await agentClient.CreateAIAgentAsync(
// Option 2 - Using PromptAgentDefinition SDK native type
// Create the server side agent version
-AIAgent agentOption2 = await agentClient.CreateAIAgentAsync(
+AIAgent agentOption2 = await aiProjectClient.CreateAIAgentAsync(
name: AgentNameNative,
creationOptions: new AgentVersionCreationOptions(
new PromptAgentDefinition(model: deploymentName)
@@ -85,5 +86,5 @@ foreach (AIAnnotation annotation in response.Messages.SelectMany(m => m.Contents
}
// Cleanup by agent name removes the agent version created.
-await agentClient.DeleteAgentAsync(agentOption1.Name);
-await agentClient.DeleteAgentAsync(agentOption2.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agentOption1.Name);
+await aiProjectClient.Agents.DeleteAgentAsync(agentOption2.Name);
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/CustomerSupport/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/CustomerSupport/Program.cs
index 3984e957f3..f18b8b4658 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/CustomerSupport/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/CustomerSupport/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
@@ -60,34 +61,34 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration, TicketingPlugin plugin)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "SelfServiceAgent",
agentDefinition: DefineSelfServiceAgent(configuration),
agentDescription: "Service agent for CustomerSupport workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "TicketingAgent",
agentDefinition: DefineTicketingAgent(configuration, plugin),
agentDescription: "Ticketing agent for CustomerSupport workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "TicketRoutingAgent",
agentDefinition: DefineTicketRoutingAgent(configuration, plugin),
agentDescription: "Routing agent for CustomerSupport workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "WindowsSupportAgent",
agentDefinition: DefineWindowsSupportAgent(configuration, plugin),
agentDescription: "Windows support agent for CustomerSupport workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "TicketResolutionAgent",
agentDefinition: DefineResolutionAgent(configuration, plugin),
agentDescription: "Resolution agent for CustomerSupport workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "TicketEscalationAgent",
agentDefinition: TicketEscalationAgent(configuration, plugin),
agentDescription: "Escalate agent for human support");
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/DeepResearch/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/DeepResearch/Program.cs
index 7f83aa5a0f..7aaa61b398 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/DeepResearch/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/DeepResearch/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
@@ -46,39 +47,39 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "ResearchAgent",
agentDefinition: DefineResearchAgent(configuration),
agentDescription: "Planner agent for DeepResearch workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "PlannerAgent",
agentDefinition: DefinePlannerAgent(configuration),
agentDescription: "Planner agent for DeepResearch workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "ManagerAgent",
agentDefinition: DefineManagerAgent(configuration),
agentDescription: "Manager agent for DeepResearch workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "SummaryAgent",
agentDefinition: DefineSummaryAgent(configuration),
agentDescription: "Summary agent for DeepResearch workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "KnowledgeAgent",
agentDefinition: DefineKnowledgeAgent(configuration),
agentDescription: "Research agent for DeepResearch workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "CoderAgent",
agentDefinition: DefineCoderAgent(configuration),
agentDescription: "Coder agent for DeepResearch workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "WeatherAgent",
agentDefinition: DefineWeatherAgent(configuration),
agentDescription: "Weather agent for DeepResearch workflow");
@@ -271,10 +272,10 @@ internal sealed class Program
Tools =
{
AgentTool.CreateOpenApiTool(
- new OpenApiFunctionDefinition(
+ new OpenAPIFunctionDefinition(
"weather-forecast",
BinaryData.FromString(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "wttr.json"))),
- new OpenApiAnonymousAuthDetails()))
+ new OpenAPIAnonymousAuthenticationDetails()))
}
};
}
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/FunctionTools/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/FunctionTools/Program.cs
index 93174dd23e..bc092a7600 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/FunctionTools/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/FunctionTools/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
@@ -55,9 +56,9 @@ internal sealed class Program
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration, AIFunction[] functions)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "MenuAgent",
agentDefinition: DefineMenuAgent(configuration, functions),
agentDescription: "Provides information about the restaurant menu");
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/HostedWorkflow/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/HostedWorkflow/Program.cs
index 600e0247c7..ff45cbc0c2 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/HostedWorkflow/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/HostedWorkflow/Program.cs
@@ -3,7 +3,8 @@
// Uncomment this to enable JSON checkpointing to the local file system.
//#define CHECKPOINT_JSON
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -34,23 +35,26 @@ internal sealed class Program
Uri foundryEndpoint = new(configuration.GetValue(Application.Settings.FoundryEndpoint));
// Create the agent service client
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
// Ensure sample agents exist in Foundry.
- await CreateAgentsAsync(agentClient, configuration);
+ await CreateAgentsAsync(aiProjectClient, configuration);
// Ensure workflow agent exists in Foundry.
- AgentVersion agentVersion = await CreateWorkflowAsync(agentClient, configuration);
+ AgentVersion agentVersion = await CreateWorkflowAsync(aiProjectClient, configuration);
string workflowInput = GetWorkflowInput(args);
- AIAgent agent = agentClient.GetAIAgent(agentVersion);
+ AIAgent agent = aiProjectClient.GetAIAgent(agentVersion);
AgentThread thread = agent.GetNewThread();
- AgentConversation conversation =
- await agentClient.GetConversationClient()
- .CreateConversationAsync().ConfigureAwait(false);
+ ProjectConversation conversation =
+ await aiProjectClient
+ .GetProjectOpenAIClient()
+ .GetProjectConversationsClient()
+ .CreateProjectConversationAsync()
+ .ConfigureAwait(false);
Console.WriteLine($"CONVERSATION: {conversation.Id}");
@@ -77,7 +81,7 @@ internal sealed class Program
}
}
- private static async Task CreateWorkflowAsync(AgentClient agentClient, IConfiguration configuration)
+ private static async Task CreateWorkflowAsync(AIProjectClient agentClient, IConfiguration configuration)
{
string workflowYaml = File.ReadAllText("MathChat.yaml");
@@ -90,7 +94,7 @@ internal sealed class Program
agentDescription: "The student attempts to solve the input problem and the teacher provides guidance.");
}
- private static async Task CreateAgentsAsync(AgentClient agentClient, IConfiguration configuration)
+ private static async Task CreateAgentsAsync(AIProjectClient agentClient, IConfiguration configuration)
{
await agentClient.CreateAgentAsync(
agentName: "StudentAgent",
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/InputArguments/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/InputArguments/Program.cs
index b5cd21bfcf..9aab54b4cf 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/InputArguments/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/InputArguments/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
@@ -46,19 +47,19 @@ internal sealed class Program
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration)
{
- AgentClient agentsClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentsClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "LocationTriageAgent",
agentDefinition: DefineLocationTriageAgent(configuration),
agentDescription: "Chats with the user to solicit a location of interest.");
- await agentsClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "LocationCaptureAgent",
agentDefinition: DefineLocationCaptureAgent(configuration),
agentDescription: "Evaluate the status of soliciting the location.");
- await agentsClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "LocationAwareAgent",
agentDefinition: DefineLocationAwareAgent(configuration),
agentDescription: "Chats with the user with location awareness.");
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/Marketing/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/Marketing/Program.cs
index 664c96d309..229658310d 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/Marketing/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/Marketing/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -45,19 +46,19 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "AnalystAgent",
agentDefinition: DefineAnalystAgent(configuration),
agentDescription: "Analyst agent for Marketing workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "WriterAgent",
agentDefinition: DefineWriterAgent(configuration),
agentDescription: "Writer agent for Marketing workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "EditorAgent",
agentDefinition: DefineEditorAgent(configuration),
agentDescription: "Editor agent for Marketing workflow");
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/StudentTeacher/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/StudentTeacher/Program.cs
index 8650094a55..7422e29f63 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/StudentTeacher/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/StudentTeacher/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -45,14 +46,14 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "StudentAgent",
agentDefinition: DefineStudentAgent(configuration),
agentDescription: "Student agent for MathChat workflow");
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "TeacherAgent",
agentDefinition: DefineTeacherAgent(configuration),
agentDescription: "Teacher agent for MathChat workflow");
diff --git a/dotnet/samples/GettingStarted/Workflows/Declarative/ToolApproval/Program.cs b/dotnet/samples/GettingStarted/Workflows/Declarative/ToolApproval/Program.cs
index 53d338b76f..3ccfc46d88 100644
--- a/dotnet/samples/GettingStarted/Workflows/Declarative/ToolApproval/Program.cs
+++ b/dotnet/samples/GettingStarted/Workflows/Declarative/ToolApproval/Program.cs
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
@@ -46,9 +47,9 @@ internal sealed class Program
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "DocumentSearchAgent",
agentDefinition: DefineSearchAgent(configuration),
agentDescription: "Searches documents on Microsoft Learn");
diff --git a/dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIAgentChatClient.cs b/dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClient.cs
similarity index 61%
rename from dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIAgentChatClient.cs
rename to dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClient.cs
index 02e0bf1e51..2a5ace7a0a 100644
--- a/dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIAgentChatClient.cs
+++ b/dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClient.cs
@@ -1,12 +1,10 @@
// Copyright (c) Microsoft. All rights reserved.
-using System.ClientModel.Primitives;
using System.Runtime.CompilerServices;
-using System.Text;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Microsoft.Extensions.AI;
using Microsoft.Shared.Diagnostics;
-using OpenAI;
using OpenAI.Responses;
#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
@@ -17,10 +15,10 @@ namespace Microsoft.Agents.AI.AzureAI;
/// Provides a chat client implementation that integrates with Azure AI Agents, enabling chat interactions using
/// Azure-specific agent capabilities.
///
-internal sealed class AzureAIAgentChatClient : DelegatingChatClient
+internal sealed class AzureAIProjectChatClient : DelegatingChatClient
{
private readonly ChatClientMetadata? _metadata;
- private readonly AgentClient _agentClient;
+ private readonly AIProjectClient _agentClient;
private readonly AgentVersion? _agentVersion;
private readonly AgentRecord? _agentRecord;
private readonly ChatOptions? _chatOptions;
@@ -32,51 +30,48 @@ internal sealed class AzureAIAgentChatClient : DelegatingChatClient
private const string NoOpModel = "no-op";
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// An instance of to interact with Azure AI Agents services.
+ /// An instance of to interact with Azure AI Agents services.
/// An instance of representing the specific agent to use.
/// The default model to use for the agent, if applicable.
/// An instance of representing the options on how the agent was predefined.
- /// An optional for configuring the underlying OpenAI client.
///
- /// The provided should be decorated with a for proper functionality.
+ /// The provided should be decorated with a for proper functionality.
///
- internal AzureAIAgentChatClient(AgentClient agentClient, AgentReference agentReference, string? defaultModelId, ChatOptions? chatOptions, OpenAIClientOptions? openAIClientOptions = null)
- : base(Throw.IfNull(agentClient)
- .GetOpenAIClient(openAIClientOptions)
+ internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, AgentReference agentReference, string? defaultModelId, ChatOptions? chatOptions)
+ : base(Throw.IfNull(aiProjectClient)
+ .GetProjectOpenAIClient()
.GetOpenAIResponseClient(defaultModelId ?? NoOpModel)
.AsIChatClient())
{
- this._agentClient = agentClient;
+ this._agentClient = aiProjectClient;
this._agentReference = Throw.IfNull(agentReference);
this._metadata = new ChatClientMetadata("azure.ai.agents", defaultModelId: defaultModelId);
this._chatOptions = chatOptions;
}
///
- /// Initializes a new instance of the class.
+ /// Initializes a new instance of the class.
///
- /// An instance of to interact with Azure AI Agents services.
+ /// An instance of to interact with Azure AI Agents services.
/// An instance of representing the specific agent to use.
/// An instance of representing the options on how the agent was predefined.
- /// An optional for configuring the underlying OpenAI client.
///
- /// The provided should be decorated with a for proper functionality.
+ /// The provided should be decorated with a for proper functionality.
///
- internal AzureAIAgentChatClient(AgentClient agentClient, AgentRecord agentRecord, ChatOptions? chatOptions, OpenAIClientOptions? openAIClientOptions = null)
- : this(agentClient, Throw.IfNull(agentRecord).Versions.Latest, chatOptions, openAIClientOptions)
+ internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, AgentRecord agentRecord, ChatOptions? chatOptions)
+ : this(aiProjectClient, Throw.IfNull(agentRecord).Versions.Latest, chatOptions)
{
this._agentRecord = agentRecord;
}
- internal AzureAIAgentChatClient(AgentClient agentClient, AgentVersion agentVersion, ChatOptions? chatOptions, OpenAIClientOptions? openAIClientOptions = null)
+ internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, AgentVersion agentVersion, ChatOptions? chatOptions)
: this(
- agentClient,
- new AgentReference(Throw.IfNull(agentVersion).Name) { Version = agentVersion.Version },
+ aiProjectClient,
+ new AgentReference(Throw.IfNull(agentVersion).Name, agentVersion.Version),
(agentVersion.Definition as PromptAgentDefinition)?.Model,
- chatOptions,
- openAIClientOptions)
+ chatOptions)
{
this._agentVersion = agentVersion;
}
@@ -86,7 +81,7 @@ internal sealed class AzureAIAgentChatClient : DelegatingChatClient
{
return (serviceKey is null && serviceType == typeof(ChatClientMetadata))
? this._metadata
- : (serviceKey is null && serviceType == typeof(AgentClient))
+ : (serviceKey is null && serviceType == typeof(AIProjectClient))
? this._agentClient
: (serviceKey is null && serviceType == typeof(AgentVersion))
? this._agentVersion
@@ -142,27 +137,12 @@ internal sealed class AzureAIAgentChatClient : DelegatingChatClient
responseCreationOptions = new ResponseCreationOptions();
}
- this.SetAgentReference(responseCreationOptions);
+ ResponseCreationOptionsExtensions.set_Agent(responseCreationOptions, this._agentReference);
+ ResponseCreationOptionsExtensions.set_Model(responseCreationOptions, null);
return responseCreationOptions;
};
return agentEnabledChatOptions;
}
-
- // Since the SetAdditionalProperty/SetAgentReference/SetConversationReference extensions in Azure.AI.Agents does not yet support the recent updates in OpenAI 2.6.0
- // The methods below are copied and adapted to the new OpenAI SDK 2.6.0 structure where the Patch property is now exposed directly on ResponseCreationOptions and
- // may be removed once the Azure.AI.Agents package is updated to support OpenAI SDK 2.6+.
-#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
- private static void SetAdditionalProperty(ResponseCreationOptions responseCreationOptions, string key, BinaryData value)
- {
- responseCreationOptions.Patch.Set([.. "$."u8, .. Encoding.UTF8.GetBytes(key)], value);
- }
-
- private void SetAgentReference(ResponseCreationOptions responseCreationOptions)
- {
- SetAdditionalProperty(responseCreationOptions, "agent", ModelReaderWriter.Write(this._agentReference, new ModelReaderWriterOptions("W"), AzureAIAgentsContext.Default));
- responseCreationOptions.Patch.Remove([.. "$."u8, .. Encoding.UTF8.GetBytes("model")]);
- }
-#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
}
diff --git a/dotnet/src/Microsoft.Agents.AI.AzureAI/AgentClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs
similarity index 81%
rename from dotnet/src/Microsoft.Agents.AI.AzureAI/AgentClientExtensions.cs
rename to dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs
index 34f7820a23..0ec5f593fd 100644
--- a/dotnet/src/Microsoft.Agents.AI.AzureAI/AgentClientExtensions.cs
+++ b/dotnet/src/Microsoft.Agents.AI.AzureAI/AzureAIProjectChatClientExtensions.cs
@@ -8,6 +8,7 @@ using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
+using Azure.AI.Projects.OpenAI;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.AzureAI;
using Microsoft.Extensions.AI;
@@ -18,43 +19,41 @@ using OpenAI.Responses;
#pragma warning disable MEAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
#pragma warning disable OPENAI001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
-namespace Azure.AI.Agents;
+namespace Azure.AI.Projects;
///
-/// Provides extension methods for .
+/// Provides extension methods for .
///
-public static partial class AgentClientExtensions
+public static partial class AzureAIProjectChatClientExtensions
{
///
- /// Retrieves an existing server side agent, wrapped as a using the provided .
+ /// Retrieves an existing server side agent, wrapped as a using the provided .
///
- /// The to create the with. Cannot be .
+ /// The to create the with. Cannot be .
/// The representing the name and version of the server side agent to create a for. Cannot be .
/// The tools to use when interacting with the agent. This is required when using prompt agent definitions with tools.
/// Provides a way to customize the creation of the underlying used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A instance that can be used to perform operations based on the latest version of the named Azure AI Agent.
- /// Thrown when or is .
+ /// Thrown when or is .
/// The agent with the specified name was not found.
///
/// When retrieving an agent by using an , minimal information will be available about the agent in the instance level, and any logic that relies
/// on to retrieve information about the agent like will receive as the result.
///
public static ChatClientAgent GetAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
AgentReference agentReference,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(agentReference);
ThrowIfInvalidAgentName(agentReference.Name);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentReference,
new ChatClientAgentOptions()
{
@@ -63,114 +62,104 @@ public static partial class AgentClientExtensions
ChatOptions = new() { Tools = tools },
},
clientFactory,
- openAIClientOptions,
services);
}
///
- /// Retrieves an existing server side agent, wrapped as a using the provided .
+ /// Retrieves an existing server side agent, wrapped as a using the provided .
///
- /// The to create the with. Cannot be .
+ /// The to create the with. Cannot be .
/// The name of the server side agent to create a for. Cannot be or whitespace.
/// The tools to use when interacting with the agent. This is required when using prompt agent definitions with tools.
/// Provides a way to customize the creation of the underlying used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// The to monitor for cancellation requests. The default is .
/// A instance that can be used to perform operations based on the latest version of the named Azure AI Agent.
- /// Thrown when or is .
+ /// Thrown when or is .
/// Thrown when is empty or whitespace, or when the agent with the specified name was not found.
/// The agent with the specified name was not found.
public static ChatClientAgent GetAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
ThrowIfInvalidAgentName(name);
- AgentRecord agentRecord = GetAgentRecordByName(agentClient, name, cancellationToken);
+ AgentRecord agentRecord = GetAgentRecordByName(aiProjectClient, name, cancellationToken);
return GetAIAgent(
- agentClient,
+ aiProjectClient,
agentRecord,
tools,
clientFactory,
- openAIClientOptions,
services);
}
///
- /// Asynchronously retrieves an existing server side agent, wrapped as a using the provided .
+ /// Asynchronously retrieves an existing server side agent, wrapped as a using the provided .
///
- /// The to create the with. Cannot be .
+ /// The to create the with. Cannot be .
/// The name of the server side agent to create a for. Cannot be or whitespace.
/// The tools to use when interacting with the agent. This is required when using prompt agent definitions with tools.
/// Provides a way to customize the creation of the underlying used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// The to monitor for cancellation requests. The default is .
/// A instance that can be used to perform operations based on the latest version of the named Azure AI Agent.
- /// Thrown when or is .
+ /// Thrown when or is .
/// Thrown when is empty or whitespace, or when the agent with the specified name was not found.
/// The agent with the specified name was not found.
public static async Task GetAIAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
ThrowIfInvalidAgentName(name);
- AgentRecord agentRecord = await GetAgentRecordByNameAsync(agentClient, name, cancellationToken).ConfigureAwait(false);
+ AgentRecord agentRecord = await GetAgentRecordByNameAsync(aiProjectClient, name, cancellationToken).ConfigureAwait(false);
return GetAIAgent(
- agentClient,
+ aiProjectClient,
agentRecord,
tools,
clientFactory,
- openAIClientOptions,
services);
}
///
/// Gets a runnable agent instance from the provided agent record.
///
- /// The client used to interact with Azure AI Agents. Cannot be .
+ /// The client used to interact with Azure AI Agents. Cannot be .
/// The agent record to be converted. The latest version will be used. Cannot be .
/// The tools to use when interacting with the agent. This is required when using prompt agent definitions with tools.
/// Provides a way to customize the creation of the underlying used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A instance that can be used to perform operations based on the latest version of the Azure AI Agent.
- /// Thrown when or is .
+ /// Thrown when or is .
public static ChatClientAgent GetAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
AgentRecord agentRecord,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(agentRecord);
var allowDeclarativeMode = tools is not { Count: > 0 };
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentRecord,
tools,
clientFactory,
- openAIClientOptions,
!allowDeclarativeMode,
services);
}
@@ -178,57 +167,52 @@ public static partial class AgentClientExtensions
///
/// Gets a runnable agent instance from a containing metadata about an Azure AI Agent.
///
- /// The client used to interact with Azure AI Agents. Cannot be .
+ /// The client used to interact with Azure AI Agents. Cannot be .
/// The agent version to be converted. Cannot be .
/// In-process invocable tools to be provided. If no tools are provided manual handling will be necessary to invoke in-process tools.
/// Provides a way to customize the creation of the underlying used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A instance that can be used to perform operations based on the provided version of the Azure AI Agent.
- /// Thrown when or is .
+ /// Thrown when or is .
public static ChatClientAgent GetAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
AgentVersion agentVersion,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(agentVersion);
var allowDeclarativeMode = tools is not { Count: > 0 };
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
tools,
clientFactory,
- openAIClientOptions,
!allowDeclarativeMode,
services);
}
///
- /// Creates a new Prompt AI Agent using the provided and options.
+ /// Creates a new Prompt AI Agent using the provided and options.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The options for creating the agent. Cannot be .
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A to cancel the operation if needed.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when or is .
+ /// Thrown when or is .
public static ChatClientAgent GetAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
ChatClientAgentOptions options,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(options);
if (string.IsNullOrWhiteSpace(options.Name))
@@ -238,40 +222,37 @@ public static partial class AgentClientExtensions
ThrowIfInvalidAgentName(options.Name);
- AgentRecord agentRecord = GetAgentRecordByName(agentClient, options.Name, cancellationToken);
+ AgentRecord agentRecord = GetAgentRecordByName(aiProjectClient, options.Name, cancellationToken);
var agentVersion = agentRecord.Versions.Latest;
var agentOptions = CreateChatClientAgentOptions(agentVersion, options, requireInvocableTools: true);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
agentOptions,
clientFactory,
- openAIClientOptions,
services);
}
///
- /// Creates a new Prompt AI Agent using the provided and options.
+ /// Creates a new Prompt AI Agent using the provided and options.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The options for creating the agent. Cannot be .
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A to cancel the operation if needed.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when or is .
+ /// Thrown when or is .
public static async Task GetAIAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
ChatClientAgentOptions options,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(options);
if (string.IsNullOrWhiteSpace(options.Name))
@@ -281,61 +262,57 @@ public static partial class AgentClientExtensions
ThrowIfInvalidAgentName(options.Name);
- AgentRecord agentRecord = await GetAgentRecordByNameAsync(agentClient, options.Name, cancellationToken).ConfigureAwait(false);
+ AgentRecord agentRecord = await GetAgentRecordByNameAsync(aiProjectClient, options.Name, cancellationToken).ConfigureAwait(false);
var agentVersion = agentRecord.Versions.Latest;
var agentOptions = CreateChatClientAgentOptions(agentVersion, options, requireInvocableTools: true);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
agentOptions,
clientFactory,
- openAIClientOptions,
services);
}
///
/// Creates a new Prompt AI agent using the specified configuration parameters.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The name for the agent.
/// The name of the model to use for the agent. Cannot be or whitespace.
/// The instructions that guide the agent's behavior. Cannot be or whitespace.
/// The description for the agent.
/// The tools to use when interacting with the agent, this is required when using prompt agent definitions with tools.
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A token to monitor for cancellation requests.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when , , or is .
+ /// Thrown when , , or is .
/// Thrown when or is empty or whitespace.
/// When using prompt agent definitions with tools the parameter needs to be provided.
public static ChatClientAgent CreateAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
string model,
string instructions,
string? description = null,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
ThrowIfInvalidAgentName(name);
Throw.IfNullOrWhitespace(model);
Throw.IfNullOrWhitespace(instructions);
return CreateAIAgent(
- agentClient,
+ aiProjectClient,
name,
tools,
new AgentVersionCreationOptions(new PromptAgentDefinition(model) { Instructions = instructions }) { Description = description },
clientFactory,
- openAIClientOptions,
services,
cancellationToken);
}
@@ -343,71 +320,66 @@ public static partial class AgentClientExtensions
///
/// Creates a new Prompt AI agent using the specified configuration parameters.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The name for the agent.
/// The name of the model to use for the agent. Cannot be or whitespace.
/// The instructions that guide the agent's behavior. Cannot be or whitespace.
/// The description for the agent.
/// The tools to use when interacting with the agent, this is required when using prompt agent definitions with tools.
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A token to monitor for cancellation requests.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when , , or is .
+ /// Thrown when , , or is .
/// Thrown when or is empty or whitespace.
/// When using prompt agent definitions with tools the parameter needs to be provided.
public static Task CreateAIAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
string model,
string instructions,
string? description = null,
IList? tools = null,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
ThrowIfInvalidAgentName(name);
Throw.IfNullOrWhitespace(model);
Throw.IfNullOrWhitespace(instructions);
return CreateAIAgentAsync(
- agentClient,
+ aiProjectClient,
name,
tools,
new AgentVersionCreationOptions(new PromptAgentDefinition(model) { Instructions = instructions }) { Description = description },
clientFactory,
- openAIClientOptions,
services,
cancellationToken);
}
///
- /// Creates a new Prompt AI Agent using the provided and options.
+ /// Creates a new Prompt AI Agent using the provided and options.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The name of the model to use for the agent. Cannot be or whitespace.
/// The options for creating the agent. Cannot be .
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A to cancel the operation if needed.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when or is .
+ /// Thrown when or is .
/// Thrown when is empty or whitespace, or when the agent name is not provided in the options.
public static ChatClientAgent CreateAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string model,
ChatClientAgentOptions options,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(options);
Throw.IfNullOrWhitespace(model);
const bool RequireInvocableTools = true;
@@ -441,42 +413,39 @@ public static partial class AgentClientExtensions
creationOptions.Description = options.Description;
}
- AgentVersion agentVersion = CreateAgentVersionWithProtocol(agentClient, options.Name, creationOptions, cancellationToken);
+ AgentVersion agentVersion = CreateAgentVersionWithProtocol(aiProjectClient, options.Name, creationOptions, cancellationToken);
var agentOptions = CreateChatClientAgentOptions(agentVersion, options, RequireInvocableTools);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
agentOptions,
clientFactory,
- openAIClientOptions,
services);
}
///
- /// Creates a new Prompt AI Agent using the provided and options.
+ /// Creates a new Prompt AI Agent using the provided and options.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The name of the model to use for the agent. Cannot be or whitespace.
/// The options for creating the agent. Cannot be .
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// An optional to use for resolving services required by the instances being invoked.
/// A to cancel the operation if needed.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when or is .
+ /// Thrown when or is .
/// Thrown when is empty or whitespace, or when the agent name is not provided in the options.
public static async Task CreateAIAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string model,
ChatClientAgentOptions options,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
IServiceProvider? services = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
Throw.IfNull(options);
Throw.IfNullOrWhitespace(model);
const bool RequireInvocableTools = true;
@@ -510,53 +479,49 @@ public static partial class AgentClientExtensions
creationOptions.Description = options.Description;
}
- AgentVersion agentVersion = await CreateAgentVersionWithProtocolAsync(agentClient, options.Name, creationOptions, cancellationToken).ConfigureAwait(false);
+ AgentVersion agentVersion = await CreateAgentVersionWithProtocolAsync(aiProjectClient, options.Name, creationOptions, cancellationToken).ConfigureAwait(false);
var agentOptions = CreateChatClientAgentOptions(agentVersion, options, RequireInvocableTools);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
agentOptions,
clientFactory,
- openAIClientOptions,
services);
}
///
/// Creates a new AI agent using the specified agent definition and optional configuration parameters.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The name for the agent.
/// Settings that control the creation of the agent.
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// A token to monitor for cancellation requests.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when or is .
+ /// Thrown when or is .
///
/// When using this extension method with a the tools are only declarative and not invocable.
/// Invocation of any in-process tools will need to be handled manually.
///
public static ChatClientAgent CreateAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
AgentVersionCreationOptions creationOptions,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
ThrowIfInvalidAgentName(name);
Throw.IfNull(creationOptions);
return CreateAIAgent(
- agentClient,
+ aiProjectClient,
name,
tools: null,
creationOptions,
clientFactory,
- openAIClientOptions,
services: null,
cancellationToken);
}
@@ -565,90 +530,98 @@ public static partial class AgentClientExtensions
/// Asynchronously creates a new AI agent using the specified agent definition and optional configuration
/// parameters.
///
- /// The client used to manage and interact with AI agents. Cannot be .
+ /// The client used to manage and interact with AI agents. Cannot be .
/// The name for the agent.
/// Settings that control the creation of the agent.
/// A factory function to customize the creation of the chat client used by the agent.
- /// An optional for configuring the underlying OpenAI client.
/// A token to monitor for cancellation requests.
/// A instance that can be used to perform operations on the newly created agent.
- /// Thrown when or is .
+ /// Thrown when or is .
///
/// When using this extension method with a the tools are only declarative and not invocable.
/// Invocation of any in-process tools will need to be handled manually.
///
public static Task CreateAIAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
AgentVersionCreationOptions creationOptions,
Func? clientFactory = null,
- OpenAIClientOptions? openAIClientOptions = null,
CancellationToken cancellationToken = default)
{
- Throw.IfNull(agentClient);
+ Throw.IfNull(aiProjectClient);
ThrowIfInvalidAgentName(name);
Throw.IfNull(creationOptions);
return CreateAIAgentAsync(
- agentClient,
+ aiProjectClient,
name,
tools: null,
creationOptions,
clientFactory,
- openAIClientOptions,
services: null,
cancellationToken);
}
#region Private
+ private static readonly ModelReaderWriterOptions s_modelWriterOptionsWire = new("W");
+
///
/// Retrieves an agent record by name using the Protocol method with user-agent header.
///
- private static AgentRecord GetAgentRecordByName(AgentClient agentClient, string agentName, CancellationToken cancellationToken)
+ private static AgentRecord GetAgentRecordByName(AIProjectClient aiProjectClient, string agentName, CancellationToken cancellationToken)
{
- ClientResult protocolResponse = agentClient.GetAgent(agentName, cancellationToken.ToRequestOptions(false));
- return ClientResult.FromOptionalValue((AgentRecord)protocolResponse, protocolResponse.GetRawResponse()).Value
+ ClientResult protocolResponse = aiProjectClient.Agents.GetAgent(agentName, cancellationToken.ToRequestOptions(false));
+ var rawResponse = protocolResponse.GetRawResponse();
+ AgentRecord? result = ModelReaderWriter.Read(rawResponse.Content, s_modelWriterOptionsWire, AzureAIProjectsOpenAIContext.Default);
+ return ClientResult.FromOptionalValue(result, rawResponse).Value!
?? throw new InvalidOperationException($"Agent with name '{agentName}' not found.");
}
///
/// Asynchronously retrieves an agent record by name using the Protocol method with user-agent header.
///
- private static async Task GetAgentRecordByNameAsync(AgentClient agentClient, string agentName, CancellationToken cancellationToken)
+ private static async Task GetAgentRecordByNameAsync(AIProjectClient aiProjectClient, string agentName, CancellationToken cancellationToken)
{
- ClientResult protocolResponse = await agentClient.GetAgentAsync(agentName, cancellationToken.ToRequestOptions(false)).ConfigureAwait(false);
- return ClientResult.FromOptionalValue((AgentRecord)protocolResponse, protocolResponse.GetRawResponse()).Value
+ ClientResult protocolResponse = await aiProjectClient.Agents.GetAgentAsync(agentName, cancellationToken.ToRequestOptions(false)).ConfigureAwait(false);
+ var rawResponse = protocolResponse.GetRawResponse();
+ AgentRecord? result = ModelReaderWriter.Read(rawResponse.Content, s_modelWriterOptionsWire, AzureAIProjectsOpenAIContext.Default);
+ return ClientResult.FromOptionalValue(result, rawResponse).Value!
?? throw new InvalidOperationException($"Agent with name '{agentName}' not found.");
}
///
/// Creates an agent version using the Protocol method with user-agent header.
///
- private static AgentVersion CreateAgentVersionWithProtocol(AgentClient agentClient, string agentName, AgentVersionCreationOptions creationOptions, CancellationToken cancellationToken)
+ private static AgentVersion CreateAgentVersionWithProtocol(AIProjectClient aiProjectClient, string agentName, AgentVersionCreationOptions creationOptions, CancellationToken cancellationToken)
{
- using BinaryContent protocolRequest = BinaryContent.Create(ModelReaderWriter.Write(creationOptions, ModelReaderWriterOptions.Json, AzureAIAgentsContext.Default));
- ClientResult protocolResponse = agentClient.CreateAgentVersion(agentName, protocolRequest, cancellationToken.ToRequestOptions(false));
- return ClientResult.FromValue((AgentVersion)protocolResponse, protocolResponse.GetRawResponse()).Value;
+ using BinaryContent protocolRequest = BinaryContent.Create(ModelReaderWriter.Write(creationOptions, ModelReaderWriterOptions.Json, AzureAIProjectsContext.Default));
+ ClientResult protocolResponse = aiProjectClient.Agents.CreateAgentVersion(agentName, protocolRequest, cancellationToken.ToRequestOptions(false));
+
+ var rawResponse = protocolResponse.GetRawResponse();
+ AgentVersion? result = ModelReaderWriter.Read(rawResponse.Content, s_modelWriterOptionsWire, AzureAIProjectsOpenAIContext.Default);
+ return ClientResult.FromValue(result, rawResponse).Value!;
}
///
/// Asynchronously creates an agent version using the Protocol method with user-agent header.
///
- private static async Task CreateAgentVersionWithProtocolAsync(AgentClient agentClient, string agentName, AgentVersionCreationOptions creationOptions, CancellationToken cancellationToken)
+ private static async Task CreateAgentVersionWithProtocolAsync(AIProjectClient aiProjectClient, string agentName, AgentVersionCreationOptions creationOptions, CancellationToken cancellationToken)
{
- using BinaryContent protocolRequest = BinaryContent.Create(ModelReaderWriter.Write(creationOptions, ModelReaderWriterOptions.Json, AzureAIAgentsContext.Default));
- ClientResult protocolResponse = await agentClient.CreateAgentVersionAsync(agentName, protocolRequest, cancellationToken.ToRequestOptions(false)).ConfigureAwait(false);
- return ClientResult.FromValue((AgentVersion)protocolResponse, protocolResponse.GetRawResponse()).Value;
+ using BinaryContent protocolRequest = BinaryContent.Create(ModelReaderWriter.Write(creationOptions, ModelReaderWriterOptions.Json, AzureAIProjectsContext.Default));
+ ClientResult protocolResponse = await aiProjectClient.Agents.CreateAgentVersionAsync(agentName, protocolRequest, cancellationToken.ToRequestOptions(false)).ConfigureAwait(false);
+
+ var rawResponse = protocolResponse.GetRawResponse();
+ AgentVersion? result = ModelReaderWriter.Read(rawResponse.Content, s_modelWriterOptionsWire, AzureAIProjectsOpenAIContext.Default);
+ return ClientResult.FromValue(result, rawResponse).Value!;
}
private static ChatClientAgent CreateAIAgent(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
IList? tools,
AgentVersionCreationOptions creationOptions,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
IServiceProvider? services,
CancellationToken cancellationToken)
{
@@ -659,25 +632,23 @@ public static partial class AgentClientExtensions
ApplyToolsToAgentDefinition(creationOptions.Definition, tools);
}
- AgentVersion agentVersion = CreateAgentVersionWithProtocol(agentClient, name, creationOptions, cancellationToken);
+ AgentVersion agentVersion = CreateAgentVersionWithProtocol(aiProjectClient, name, creationOptions, cancellationToken);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
tools,
clientFactory,
- openAIClientOptions,
!allowDeclarativeMode,
services);
}
private static async Task CreateAIAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string name,
IList? tools,
AgentVersionCreationOptions creationOptions,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
IServiceProvider? services,
CancellationToken cancellationToken)
{
@@ -688,28 +659,26 @@ public static partial class AgentClientExtensions
ApplyToolsToAgentDefinition(creationOptions.Definition, tools);
}
- AgentVersion agentVersion = await CreateAgentVersionWithProtocolAsync(agentClient, name, creationOptions, cancellationToken).ConfigureAwait(false);
+ AgentVersion agentVersion = await CreateAgentVersionWithProtocolAsync(aiProjectClient, name, creationOptions, cancellationToken).ConfigureAwait(false);
return CreateChatClientAgent(
- agentClient,
+ aiProjectClient,
agentVersion,
tools,
clientFactory,
- openAIClientOptions,
!allowDeclarativeMode,
services);
}
/// This method creates an with the specified ChatClientAgentOptions.
private static ChatClientAgent CreateChatClientAgent(
- AgentClient agentClient,
+ AIProjectClient aiProjectClient,
AgentVersion agentVersion,
ChatClientAgentOptions agentOptions,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
IServiceProvider? services)
{
- IChatClient chatClient = new AzureAIAgentChatClient(agentClient, agentVersion, agentOptions.ChatOptions, openAIClientOptions);
+ IChatClient chatClient = new AzureAIProjectChatClient(aiProjectClient, agentVersion, agentOptions.ChatOptions);
if (clientFactory is not null)
{
@@ -721,14 +690,13 @@ public static partial class AgentClientExtensions
/// This method creates an with the specified ChatClientAgentOptions.
private static ChatClientAgent CreateChatClientAgent(
- AgentClient agentClient,
+ AIProjectClient aiProjectClient,
AgentRecord agentRecord,
ChatClientAgentOptions agentOptions,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
IServiceProvider? services)
{
- IChatClient chatClient = new AzureAIAgentChatClient(agentClient, agentRecord, agentOptions.ChatOptions, openAIClientOptions);
+ IChatClient chatClient = new AzureAIProjectChatClient(aiProjectClient, agentRecord, agentOptions.ChatOptions);
if (clientFactory is not null)
{
@@ -740,14 +708,13 @@ public static partial class AgentClientExtensions
/// This method creates an with the specified ChatClientAgentOptions.
private static ChatClientAgent CreateChatClientAgent(
- AgentClient agentClient,
+ AIProjectClient aiProjectClient,
AgentReference agentReference,
ChatClientAgentOptions agentOptions,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
IServiceProvider? services)
{
- IChatClient chatClient = new AzureAIAgentChatClient(agentClient, agentReference, defaultModelId: null, agentOptions.ChatOptions, openAIClientOptions);
+ IChatClient chatClient = new AzureAIProjectChatClient(aiProjectClient, agentReference, defaultModelId: null, agentOptions.ChatOptions);
if (clientFactory is not null)
{
@@ -759,36 +726,32 @@ public static partial class AgentClientExtensions
/// This method creates an with a auto-generated ChatClientAgentOptions from the specified configuration parameters.
private static ChatClientAgent CreateChatClientAgent(
- AgentClient AgentClient,
+ AIProjectClient AIProjectClient,
AgentVersion agentVersion,
IList? tools,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
bool requireInvocableTools,
IServiceProvider? services)
=> CreateChatClientAgent(
- AgentClient,
+ AIProjectClient,
agentVersion,
CreateChatClientAgentOptions(agentVersion, new ChatOptions() { Tools = tools }, requireInvocableTools),
clientFactory,
- openAIClientOptions,
services);
/// This method creates an with a auto-generated ChatClientAgentOptions from the specified configuration parameters.
private static ChatClientAgent CreateChatClientAgent(
- AgentClient AgentClient,
+ AIProjectClient AIProjectClient,
AgentRecord agentRecord,
IList? tools,
Func? clientFactory,
- OpenAIClientOptions? openAIClientOptions,
bool requireInvocableTools,
IServiceProvider? services)
=> CreateChatClientAgent(
- AgentClient,
+ AIProjectClient,
agentRecord,
CreateChatClientAgentOptions(agentRecord.Versions.Latest, new ChatOptions() { Tools = tools }, requireInvocableTools),
clientFactory,
- openAIClientOptions,
services);
///
diff --git a/dotnet/src/Microsoft.Agents.AI.AzureAI/Microsoft.Agents.AI.AzureAI.csproj b/dotnet/src/Microsoft.Agents.AI.AzureAI/Microsoft.Agents.AI.AzureAI.csproj
index 4c338717f7..3d59f9fce6 100644
--- a/dotnet/src/Microsoft.Agents.AI.AzureAI/Microsoft.Agents.AI.AzureAI.csproj
+++ b/dotnet/src/Microsoft.Agents.AI.AzureAI/Microsoft.Agents.AI.AzureAI.csproj
@@ -11,7 +11,8 @@
-
+
+
diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.AzureAI/AzureAgentProvider.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.AzureAI/AzureAgentProvider.cs
index 3045df8893..c4a613901c 100644
--- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.AzureAI/AzureAgentProvider.cs
+++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.AzureAI/AzureAgentProvider.cs
@@ -10,10 +10,10 @@ using System.Runtime.CompilerServices;
using System.Text.Json.Nodes;
using System.Threading;
using System.Threading.Tasks;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Core;
using Microsoft.Extensions.AI;
-using OpenAI;
using OpenAI.Responses;
namespace Microsoft.Agents.AI.Workflows.Declarative;
@@ -30,18 +30,18 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
private readonly Dictionary _versionCache = [];
private readonly Dictionary _agentCache = [];
- private AgentClient? _agentClient;
- private ConversationClient? _conversationClient;
+ private AIProjectClient? _agentClient;
+ private ProjectConversationsClient? _conversationClient;
///
- /// Optional options used when creating the .
+ /// Optional options used when creating the .
///
- public AgentClientOptions? AgentClientOptions { get; init; }
+ public AIProjectClientOptions? AIProjectClientOptions { get; init; }
///
/// Optional options used when invoking the .
///
- public OpenAIClientOptions? OpenAIClientOptions { get; init; }
+ public ProjectOpenAIClientOptions? OpenAIClientOptions { get; init; }
///
/// An optional instance to be used for making HTTP requests.
@@ -52,9 +52,9 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
///
public override async Task CreateConversationAsync(CancellationToken cancellationToken = default)
{
- AgentConversation conversation =
+ ProjectConversation conversation =
await this.GetConversationClient()
- .CreateConversationAsync(options: null, cancellationToken).ConfigureAwait(false);
+ .CreateProjectConversationAsync(options: null, cancellationToken).ConfigureAwait(false);
return conversation.Id;
}
@@ -63,7 +63,7 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
public override async Task CreateMessageAsync(string conversationId, ChatMessage conversationMessage, CancellationToken cancellationToken = default)
{
ReadOnlyCollection newItems =
- await this.GetConversationClient().CreateConversationItemsAsync(
+ await this.GetConversationClient().CreateProjectConversationItemsAsync(
conversationId,
items: GetResponseItems(),
include: null,
@@ -112,7 +112,9 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
{
JsonNode jsonNode = ConvertDictionaryToJson(inputArguments);
ResponseCreationOptions responseCreationOptions = new();
- responseCreationOptions.SetStructuredInputs(BinaryData.FromString(jsonNode.ToJsonString()));
+#pragma warning disable SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
+ responseCreationOptions.Patch.Set("$.structured_inputs"u8, BinaryData.FromString(jsonNode.ToJsonString()));
+#pragma warning restore SCME0001 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.
chatOptions.RawRepresentationFactory = (_) => responseCreationOptions;
}
@@ -138,12 +140,12 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
return targetAgent;
}
- AgentClient client = this.GetAgentClient();
+ AIProjectClient client = this.GetAgentClient();
if (string.IsNullOrEmpty(agentVersion))
{
AgentRecord agentRecord =
- await client.GetAgentAsync(
+ await client.Agents.GetAgentAsync(
agentName,
cancellationToken).ConfigureAwait(false);
@@ -152,7 +154,7 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
else
{
targetAgent =
- await client.GetAgentVersionAsync(
+ await client.Agents.GetAgentVersionAsync(
agentName,
agentVersion,
cancellationToken).ConfigureAwait(false);
@@ -170,9 +172,9 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
return agent;
}
- AgentClient client = this.GetAgentClient();
+ AIProjectClient client = this.GetAgentClient();
- agent = client.GetAIAgent(agentVersion, tools: null, clientFactory: null, this.OpenAIClientOptions, services: null);
+ agent = client.GetAIAgent(agentVersion, tools: null, clientFactory: null, services: null);
FunctionInvokingChatClient? functionInvokingClient = agent.GetService();
if (functionInvokingClient is not null)
@@ -203,7 +205,7 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
///
public override async Task GetMessageAsync(string conversationId, string messageId, CancellationToken cancellationToken = default)
{
- AgentResponseItem responseItem = await this.GetConversationClient().GetConversationItemAsync(conversationId, messageId, cancellationToken).ConfigureAwait(false);
+ AgentResponseItem responseItem = await this.GetConversationClient().GetProjectConversationItemAsync(conversationId, messageId, include: null, cancellationToken).ConfigureAwait(false);
ResponseItem[] items = [responseItem.AsOpenAIResponseItem()];
return items.AsChatMessages().Single();
}
@@ -218,7 +220,8 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
[EnumeratorCancellation] CancellationToken cancellationToken = default)
{
AgentListOrder order = newestFirst ? AgentListOrder.Ascending : AgentListOrder.Descending;
- await foreach (AgentResponseItem responseItem in this.GetConversationClient().GetConversationItemsAsync(conversationId, limit, order, after, before, itemType: null, cancellationToken).ConfigureAwait(false))
+
+ await foreach (AgentResponseItem responseItem in this.GetConversationClient().GetProjectConversationItemsAsync(conversationId, null, limit, order.ToString(), after, before, include: null, cancellationToken).ConfigureAwait(false))
{
ResponseItem[] items = [responseItem.AsOpenAIResponseItem()];
foreach (ChatMessage message in items.AsChatMessages())
@@ -228,18 +231,18 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
}
}
- private AgentClient GetAgentClient()
+ private AIProjectClient GetAgentClient()
{
if (this._agentClient is null)
{
- AgentClientOptions clientOptions = this.AgentClientOptions ?? new();
+ AIProjectClientOptions clientOptions = this.AIProjectClientOptions ?? new();
if (this.HttpClient is not null)
{
clientOptions.Transport = new HttpClientPipelineTransport(this.HttpClient);
}
- AgentClient newClient = new(projectEndpoint, projectCredentials, clientOptions);
+ AIProjectClient newClient = new(projectEndpoint, projectCredentials, clientOptions);
Interlocked.CompareExchange(ref this._agentClient, newClient, null);
}
@@ -247,11 +250,11 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj
return this._agentClient;
}
- private ConversationClient GetConversationClient()
+ private ProjectConversationsClient GetConversationClient()
{
if (this._conversationClient is null)
{
- ConversationClient conversationClient = this.GetAgentClient().GetConversationClient();
+ ProjectConversationsClient conversationClient = this.GetAgentClient().GetProjectOpenAIClient().GetProjectConversationsClient();
Interlocked.CompareExchange(ref this._conversationClient, conversationClient, null);
}
diff --git a/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs b/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs
index c9717590b8..e179058e69 100644
--- a/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs
+++ b/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs
@@ -4,14 +4,15 @@
using System;
using System.Threading.Tasks;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
namespace Shared.Foundry;
internal static class AgentFactory
{
public static async ValueTask CreateAgentAsync(
- this AgentClient agentClient,
+ this AIProjectClient aiProjectClient,
string agentName,
AgentDefinition agentDefinition,
string agentDescription)
@@ -27,7 +28,7 @@ internal static class AgentFactory
},
};
- AgentVersion agentVersion = await agentClient.CreateAgentVersionAsync(agentName, options).ConfigureAwait(false);
+ AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync(agentName, options).ConfigureAwait(false);
Console.ForegroundColor = ConsoleColor.Cyan;
try
diff --git a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AgentClientExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs
similarity index 81%
rename from dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AgentClientExtensionsTests.cs
rename to dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs
index f4d382339f..ede9b37919 100644
--- a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AgentClientExtensionsTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientExtensionsTests.cs
@@ -12,36 +12,36 @@ using System.Text;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Microsoft.Extensions.AI;
using Moq;
-using OpenAI;
using OpenAI.Responses;
namespace Microsoft.Agents.AI.AzureAI.UnitTests;
///
-/// Unit tests for the class.
+/// Unit tests for the class.
///
-public sealed class AgentClientExtensionsTests
+public sealed class AzureAIProjectChatClientExtensionsTests
{
- #region GetAIAgent(AgentClient, AgentRecord) Tests
+ #region GetAIAgent(AIProjectClient, AgentRecord) Tests
///
- /// Verify that GetAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that GetAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void GetAIAgent_WithAgentRecord_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act & Assert
var exception = Assert.Throws(() =>
client!.GetAIAgent(agentRecord));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -51,7 +51,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentRecord_WithNullAgentRecord_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -67,7 +67,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentRecord_CreatesValidAgent()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act
@@ -85,7 +85,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentRecord_WithClientFactory_AppliesFactoryCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
TestChatClient? testChatClient = null;
@@ -103,23 +103,23 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgent(AgentClient, AgentVersion) Tests
+ #region GetAIAgent(AIProjectClient, AgentVersion) Tests
///
- /// Verify that GetAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that GetAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void GetAIAgent_WithAgentVersion_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
AgentVersion agentVersion = this.CreateTestAgentVersion();
// Act & Assert
var exception = Assert.Throws(() =>
client!.GetAIAgent(agentVersion));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -129,7 +129,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentVersion_WithNullAgentVersion_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -145,7 +145,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentVersion_CreatesValidAgent()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
// Act
@@ -163,7 +163,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentVersion_WithClientFactory_AppliesFactoryCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
TestChatClient? testChatClient = null;
@@ -186,7 +186,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentVersion_WithRequireInvocableToolsTrue_EnforcesInvocableTools()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
var tools = new List
{
@@ -208,7 +208,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentVersion_WithRequireInvocableToolsFalse_AllowsDeclarativeFunctions()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
// Act - should not throw even without tools when requireInvocableTools is false
@@ -221,7 +221,7 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgent(AgentClient, ChatClientAgentOptions) Tests
+ #region GetAIAgent(AIProjectClient, ChatClientAgentOptions) Tests
///
/// Verify that GetAIAgent with ChatClientAgentOptions throws ArgumentNullException when client is null.
@@ -230,14 +230,14 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
var options = new ChatClientAgentOptions { Name = "test-agent" };
// Act & Assert
var exception = Assert.Throws(() =>
client!.GetAIAgent(options));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -247,7 +247,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_WithNullOptions_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -263,7 +263,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_WithoutName_ThrowsArgumentException()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var options = new ChatClientAgentOptions();
// Act & Assert
@@ -280,7 +280,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_CreatesValidAgent()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent");
var options = new ChatClientAgentOptions { Name = "test-agent" };
// Act
@@ -298,7 +298,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_WithClientFactory_AppliesFactoryCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent");
var options = new ChatClientAgentOptions { Name = "test-agent" };
TestChatClient? testChatClient = null;
@@ -316,7 +316,7 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgentAsync(AgentClient, ChatClientAgentOptions) Tests
+ #region GetAIAgentAsync(AIProjectClient, ChatClientAgentOptions) Tests
///
/// Verify that GetAIAgentAsync with ChatClientAgentOptions throws ArgumentNullException when client is null.
@@ -325,14 +325,14 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_WithOptions_WithNullClient_ThrowsArgumentNullExceptionAsync()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
var options = new ChatClientAgentOptions { Name = "test-agent" };
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
client!.GetAIAgentAsync(options));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -342,7 +342,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_WithOptions_WithNullOptions_ThrowsArgumentNullExceptionAsync()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -358,7 +358,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_WithOptions_CreatesValidAgentAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent");
var options = new ChatClientAgentOptions { Name = "test-agent" };
// Act
@@ -371,22 +371,22 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgent(AgentClient, string) Tests
+ #region GetAIAgent(AIProjectClient, string) Tests
///
- /// Verify that GetAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that GetAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void GetAIAgent_ByName_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
// Act & Assert
var exception = Assert.Throws(() =>
client!.GetAIAgent("test-agent"));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -396,7 +396,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_ByName_WithNullName_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -412,7 +412,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_ByName_WithEmptyName_ThrowsArgumentException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -428,12 +428,14 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_ByName_WithNonExistentAgent_ThrowsInvalidOperationException()
{
// Arrange
- var mockClient = new Mock();
- mockClient.Setup(c => c.GetAgent(It.IsAny(), It.IsAny()))
+ var mockAgentOperations = new Mock();
+ mockAgentOperations
+ .Setup(c => c.GetAgent(It.IsAny(), It.IsAny()))
.Returns(ClientResult.FromOptionalValue((AgentRecord)null!, new MockPipelineResponse(200, BinaryData.FromString("null"))));
- mockClient.Setup(x => x.GetOpenAIClient(It.IsAny()))
- .Returns(new OpenAIClient(new ApiKeyCredential("test-key")));
+ var mockClient = new Mock();
+ mockClient.SetupGet(x => x.Agents).Returns(mockAgentOperations.Object);
+ mockClient.Setup(x => x.GetConnection(It.IsAny())).Returns(new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None));
// Act & Assert
var exception = Assert.Throws(() =>
@@ -444,22 +446,22 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgentAsync(AgentClient, string) Tests
+ #region GetAIAgentAsync(AIProjectClient, string) Tests
///
- /// Verify that GetAIAgentAsync throws ArgumentNullException when AgentClient is null.
+ /// Verify that GetAIAgentAsync throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public async Task GetAIAgentAsync_ByName_WithNullClient_ThrowsArgumentNullExceptionAsync()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
client!.GetAIAgentAsync("test-agent"));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -469,7 +471,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_ByName_WithNullName_ThrowsArgumentNullExceptionAsync()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -485,12 +487,14 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_ByName_WithNonExistentAgent_ThrowsInvalidOperationExceptionAsync()
{
// Arrange
- var mockClient = new Mock();
- mockClient.Setup(c => c.GetAgentAsync(It.IsAny(), It.IsAny()))
+ var mockAgentOperations = new Mock();
+ mockAgentOperations
+ .Setup(c => c.GetAgentAsync(It.IsAny(), It.IsAny()))
.ReturnsAsync(ClientResult.FromOptionalValue((AgentRecord)null!, new MockPipelineResponse(200, BinaryData.FromString("null"))));
- mockClient.Setup(x => x.GetOpenAIClient(It.IsAny()))
- .Returns(new OpenAIClient(new ApiKeyCredential("test-key")));
+ var mockClient = new Mock();
+ mockClient.SetupGet(c => c.Agents).Returns(mockAgentOperations.Object);
+ mockClient.Setup(x => x.GetConnection(It.IsAny())).Returns(new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None));
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -501,7 +505,7 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgent(AgentClient, AgentRecord) with tools Tests
+ #region GetAIAgent(AIProjectClient, AgentRecord) with tools Tests
///
/// Verify that GetAIAgent with additional tools when the definition has no tools does not throw and results in an agent with no tools.
@@ -510,7 +514,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentRecordAndAdditionalTools_WhenDefinitionHasNoTools_ShouldNotThrow()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
var tools = new List
{
@@ -538,7 +542,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentRecordAndNullTools_WorksCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act
@@ -551,7 +555,7 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgentAsync(AgentClient, string) with tools Tests
+ #region GetAIAgentAsync(AIProjectClient, string) with tools Tests
///
/// Verify that GetAIAgentAsync with tools parameter creates an agent.
@@ -560,7 +564,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_WithNameAndTools_CreatesAgentAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var tools = new List
{
AIFunctionFactory.Create(() => "test", "test_function", "A test function")
@@ -576,22 +580,22 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region CreateAIAgent(AgentClient, string, string) Tests
+ #region CreateAIAgent(AIProjectClient, string, string) Tests
///
- /// Verify that CreateAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that CreateAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void CreateAIAgent_WithBasicParams_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
// Act & Assert
var exception = Assert.Throws(() =>
client!.CreateAIAgent("test-agent", "model", "instructions"));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -601,7 +605,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithBasicParams_WithNullName_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -612,16 +616,16 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region CreateAIAgent(AgentClient, string, AgentDefinition) Tests
+ #region CreateAIAgent(AIProjectClient, string, AgentDefinition) Tests
///
- /// Verify that CreateAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that CreateAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void CreateAIAgent_WithAgentDefinition_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
var definition = new PromptAgentDefinition("test-model");
var options = new AgentVersionCreationOptions(definition);
@@ -629,7 +633,7 @@ public sealed class AgentClientExtensionsTests
var exception = Assert.Throws(() =>
client!.CreateAIAgent("test-agent", options));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -639,7 +643,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithAgentDefinition_WithNullName_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
var definition = new PromptAgentDefinition("test-model");
var options = new AgentVersionCreationOptions(definition);
@@ -657,7 +661,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithAgentDefinition_WithNullDefinition_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -668,23 +672,23 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region CreateAIAgent(AgentClient, ChatClientAgentOptions, string) Tests
+ #region CreateAIAgent(AIProjectClient, ChatClientAgentOptions, string) Tests
///
- /// Verify that CreateAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that CreateAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void CreateAIAgent_WithOptions_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
var options = new ChatClientAgentOptions { Name = "test-agent" };
// Act & Assert
var exception = Assert.Throws(() =>
client!.CreateAIAgent("model", options));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -694,7 +698,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithOptions_WithNullOptions_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -710,7 +714,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithOptions_WithNullModel_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
var options = new ChatClientAgentOptions { Name = "test-agent" };
// Act & Assert
@@ -727,7 +731,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithOptions_WithoutName_ThrowsException()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var options = new ChatClientAgentOptions();
// Act & Assert
@@ -744,7 +748,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithModelAndOptions_CreatesValidAgent()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
var options = new ChatClientAgentOptions
{
Name = "test-agent",
@@ -767,7 +771,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithModelAndOptions_WithClientFactory_AppliesFactoryCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
var options = new ChatClientAgentOptions
{
Name = "test-agent",
@@ -795,7 +799,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithModelAndOptions_CreatesValidAgentAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
var options = new ChatClientAgentOptions
{
Name = "test-agent",
@@ -818,7 +822,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithModelAndOptions_WithClientFactory_AppliesFactoryCorrectlyAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Test instructions");
var options = new ChatClientAgentOptions
{
Name = "test-agent",
@@ -841,16 +845,16 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region CreateAIAgentAsync(AgentClient, string, AgentDefinition) Tests
+ #region CreateAIAgentAsync(AIProjectClient, string, AgentDefinition) Tests
///
- /// Verify that CreateAIAgentAsync throws ArgumentNullException when AgentClient is null.
+ /// Verify that CreateAIAgentAsync throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public async Task CreateAIAgentAsync_WithAgentDefinition_WithNullClient_ThrowsArgumentNullExceptionAsync()
{
// Arrange
- AgentClient? client = null;
+ AIProjectClient? client = null;
var definition = new PromptAgentDefinition("test-model");
var options = new AgentVersionCreationOptions(definition);
@@ -858,7 +862,7 @@ public sealed class AgentClientExtensionsTests
var exception = await Assert.ThrowsAsync(() =>
client!.CreateAIAgentAsync("agent-name", options));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -868,7 +872,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithAgentDefinition_WithNullDefinition_ThrowsArgumentNullExceptionAsync()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -888,7 +892,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithDefinition_CreatesAgentSuccessfully()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
var options = new AgentVersionCreationOptions(definition);
@@ -910,7 +914,7 @@ public sealed class AgentClientExtensionsTests
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
var definitionResponse = GeneratePromptDefinitionResponse(definition, null);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -930,7 +934,7 @@ public sealed class AgentClientExtensionsTests
{
// Arrange
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definition);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definition);
var options = new AgentVersionCreationOptions(definition);
@@ -956,7 +960,7 @@ public sealed class AgentClientExtensionsTests
// Create a response definition with the same tool
var definitionResponse = GeneratePromptDefinitionResponse(definition, definition.Tools.Select(t => t.AsAITool()).ToList());
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -999,7 +1003,7 @@ public sealed class AgentClientExtensionsTests
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399
- var client = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
// Act
var agent = await client.CreateAIAgentAsync(
@@ -1041,7 +1045,7 @@ public sealed class AgentClientExtensionsTests
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399
- var client = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
// Act
var agent = client.CreateAIAgent(
@@ -1068,7 +1072,7 @@ public sealed class AgentClientExtensionsTests
var definition = new PromptAgentDefinition("test-model");
var agentDefinitionResponse = GeneratePromptDefinitionResponse(definition, null);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: agentDefinitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: agentDefinitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1087,7 +1091,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_AdditionalAITools_WhenNotInTheDefinitionAreIgnored()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var agentVersion = this.CreateTestAgentVersion();
// Manually add tools to the definition to simulate inline tools
@@ -1123,7 +1127,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithParameterTools_AcceptsTools()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
var tools = new List
{
@@ -1156,7 +1160,7 @@ public sealed class AgentClientExtensionsTests
// Simulate agent definition response with the tools
var definitionResponse = GeneratePromptDefinitionResponse(definition, definition.Tools.Select(t => t.AsAITool()).ToList());
- AgentClient client = this.CreateTestAgentClient(agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1194,7 +1198,7 @@ public sealed class AgentClientExtensionsTests
definitionResponse.Tools.Add(tool);
}
- AgentClient client = this.CreateTestAgentClient(agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1222,33 +1226,30 @@ public sealed class AgentClientExtensionsTests
// Arrange
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test instructions" };
- var fabricParameters = new FabricDataAgentToolParameters();
- fabricParameters.ProjectConnections.Add(new ToolProjectConnection("connection-id"));
+ var fabricToolOptions = new FabricDataAgentToolOptions();
+ fabricToolOptions.ProjectConnections.Add(new ToolProjectConnection("connection-id"));
- var sharepointParameters = new SharepointGroundingToolParameters();
- sharepointParameters.ProjectConnections.Add(new ToolProjectConnection("connection-id"));
+ var sharepointOptions = new SharePointGroundingToolOptions();
+ sharepointOptions.ProjectConnections.Add(new ToolProjectConnection("connection-id"));
- var structuredOutputs = new StructuredOutputDefinition("name", "description", new Dictionary()
- {
- ["structured-1"] = BinaryData.FromString(AIJsonUtilities.CreateJsonSchema(new { id = "test" }.GetType()).ToString())
- }, false);
+ var structuredOutputs = new StructuredOutputDefinition("name", "description", BinaryData.FromString(AIJsonUtilities.CreateJsonSchema(new { id = "test" }.GetType()).ToString()), false);
// Add tools to the definition
definition.Tools.Add(ResponseTool.CreateFunctionTool("create_tool", BinaryData.FromString("{}"), strictModeEnabled: false));
definition.Tools.Add((ResponseTool)AgentTool.CreateBingCustomSearchTool(new BingCustomSearchToolParameters([new BingCustomSearchConfiguration("connection-id", "instance-name")])));
definition.Tools.Add((ResponseTool)AgentTool.CreateBrowserAutomationTool(new BrowserAutomationToolParameters(new BrowserAutomationToolConnectionParameters("id"))));
definition.Tools.Add(AgentTool.CreateA2ATool(new Uri("https://test-uri.microsoft.com")));
- definition.Tools.Add((ResponseTool)AgentTool.CreateBingGroundingTool(new BingGroundingSearchToolParameters([new BingGroundingSearchConfiguration("connection-id")])));
- definition.Tools.Add((ResponseTool)AgentTool.CreateMicrosoftFabricTool(fabricParameters));
- definition.Tools.Add((ResponseTool)AgentTool.CreateOpenApiTool(new OpenApiFunctionDefinition("name", BinaryData.FromString(OpenAPISpec), new OpenApiAnonymousAuthDetails())));
- definition.Tools.Add((ResponseTool)AgentTool.CreateSharepointTool(sharepointParameters));
+ definition.Tools.Add((ResponseTool)AgentTool.CreateBingGroundingTool(new BingGroundingSearchToolOptions([new BingGroundingSearchConfiguration("connection-id")])));
+ definition.Tools.Add((ResponseTool)AgentTool.CreateMicrosoftFabricTool(fabricToolOptions));
+ definition.Tools.Add((ResponseTool)AgentTool.CreateOpenApiTool(new OpenAPIFunctionDefinition("name", BinaryData.FromString(OpenAPISpec), new OpenAPIAnonymousAuthenticationDetails())));
+ definition.Tools.Add((ResponseTool)AgentTool.CreateSharepointTool(sharepointOptions));
definition.Tools.Add((ResponseTool)AgentTool.CreateStructuredOutputsTool(structuredOutputs));
- definition.Tools.Add((ResponseTool)AgentTool.CreateAzureAISearchTool(new AzureAISearchToolOptions([new AzureAISearchIndex() { IndexName = "name" }])));
+ definition.Tools.Add((ResponseTool)AgentTool.CreateAzureAISearchTool(new AzureAISearchToolOptions([new AzureAISearchToolIndex() { IndexName = "name" }])));
// Generate agent definition response with the tools
var definitionResponse = GeneratePromptDefinitionResponse(definition, definition.Tools.Select(t => t.AsAITool()).ToList());
- AgentClient client = this.CreateTestAgentClient(agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1281,7 +1282,7 @@ public sealed class AgentClientExtensionsTests
var definitionResponse = GeneratePromptDefinitionResponse(new PromptAgentDefinition("test-model") { Instructions = "Test instructions" }, tools);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
// Act
var agent = client.CreateAIAgent(
@@ -1309,7 +1310,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithDefinitionTools_CreatesAgentAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test instructions" };
definition.Tools.Add(ResponseTool.CreateFunctionTool("async_tool", BinaryData.FromString("{}"), strictModeEnabled: false));
@@ -1330,7 +1331,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_WithToolsParameter_CreatesAgentAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var tools = new List
{
AIFunctionFactory.Create(() => "async_get_result", "async_get_tool", "An async get tool")
@@ -1355,7 +1356,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithDeclarativeFunctionInDefinition_AcceptsDeclarativeFunction()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
// Create a declarative function (not invocable) using AIFunctionFactory.CreateDeclaration
@@ -1395,7 +1396,7 @@ public sealed class AgentClientExtensionsTests
var definitionResponse = new PromptAgentDefinition("test-model") { Instructions = "Test" };
definitionResponse.Tools.Add(declarativeFunction.AsOpenAIResponseTool() ?? throw new InvalidOperationException());
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1428,7 +1429,7 @@ public sealed class AgentClientExtensionsTests
var definitionResponse = new PromptAgentDefinition("test-model") { Instructions = "Test" };
definitionResponse.Tools.Add(functionTool);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1463,7 +1464,7 @@ public sealed class AgentClientExtensionsTests
var definitionResponse = new PromptAgentDefinition("test-model") { Instructions = "Test" };
definitionResponse.Tools.Add(functionTool);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1482,7 +1483,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithDeclarativeFunctionFromDefinition_AcceptsDeclarativeFunctionAsync()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
// Create a declarative function (not invocable) using AIFunctionFactory.CreateDeclaration
@@ -1522,7 +1523,7 @@ public sealed class AgentClientExtensionsTests
var definitionResponse = new PromptAgentDefinition("test-model") { Instructions = "Test" };
definitionResponse.Tools.Add(declarativeFunction.AsOpenAIResponseTool() ?? throw new InvalidOperationException());
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1548,7 +1549,7 @@ public sealed class AgentClientExtensionsTests
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test instructions" };
var definitionResponse = GeneratePromptDefinitionResponse(definition, null);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1570,7 +1571,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_PreservesCustomProperties()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Custom instructions", description: "Custom description");
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", instructions: "Custom instructions", description: "Custom description");
var options = new ChatClientAgentOptions
{
Name = "test-agent",
@@ -1604,7 +1605,7 @@ public sealed class AgentClientExtensionsTests
new PromptAgentDefinition("test-model") { Instructions = "Test" },
tools);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: definitionResponse);
var options = new ChatClientAgentOptions
{
@@ -1639,7 +1640,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_ByName_WithInvalidAgentName_ThrowsArgumentException(string invalidName)
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -1657,7 +1658,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_ByName_WithInvalidAgentName_ThrowsArgumentExceptionAsync(string invalidName)
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -1675,7 +1676,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithOptions_WithInvalidAgentName_ThrowsArgumentException(string invalidName)
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var options = new ChatClientAgentOptions { Name = invalidName };
// Act & Assert
@@ -1694,7 +1695,7 @@ public sealed class AgentClientExtensionsTests
public async Task GetAIAgentAsync_WithOptions_WithInvalidAgentName_ThrowsArgumentExceptionAsync(string invalidName)
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var options = new ChatClientAgentOptions { Name = invalidName };
// Act & Assert
@@ -1713,7 +1714,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithBasicParams_WithInvalidAgentName_ThrowsArgumentException(string invalidName)
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -1731,7 +1732,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithBasicParams_WithInvalidAgentName_ThrowsArgumentExceptionAsync(string invalidName)
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = await Assert.ThrowsAsync(() =>
@@ -1749,7 +1750,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithAgentDefinition_WithInvalidAgentName_ThrowsArgumentException(string invalidName)
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
var definition = new PromptAgentDefinition("test-model");
var options = new AgentVersionCreationOptions(definition);
@@ -1769,7 +1770,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithAgentDefinition_WithInvalidAgentName_ThrowsArgumentExceptionAsync(string invalidName)
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
var definition = new PromptAgentDefinition("test-model");
var options = new AgentVersionCreationOptions(definition);
@@ -1789,7 +1790,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithOptions_WithInvalidAgentName_ThrowsArgumentException(string invalidName)
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var options = new ChatClientAgentOptions { Name = invalidName };
// Act & Assert
@@ -1808,7 +1809,7 @@ public sealed class AgentClientExtensionsTests
public async Task CreateAIAgentAsync_WithOptions_WithInvalidAgentName_ThrowsArgumentExceptionAsync(string invalidName)
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var options = new ChatClientAgentOptions { Name = invalidName };
// Act & Assert
@@ -1827,8 +1828,8 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentReference_WithInvalidAgentName_ThrowsArgumentException(string invalidName)
{
// Arrange
- var mockClient = new Mock();
- var agentReference = new AgentReference(invalidName) { Version = "1" };
+ var mockClient = new Mock();
+ var agentReference = new AgentReference(invalidName, "1");
// Act & Assert
var exception = Assert.Throws(() =>
@@ -1849,7 +1850,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithClientFactory_WrapsUnderlyingChatClient()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
int factoryCallCount = 0;
@@ -1876,7 +1877,7 @@ public sealed class AgentClientExtensionsTests
public void CreateAIAgent_WithClientFactory_ReceivesCorrectUnderlyingClient()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
IChatClient? receivedClient = null;
@@ -1906,7 +1907,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_MultipleCallsWithClientFactory_CreatesIndependentClients()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act
@@ -1938,7 +1939,7 @@ public sealed class AgentClientExtensionsTests
const string AgentName = "test-agent";
const string Model = "test-model";
const string Instructions = "Test instructions";
- AgentClient client = this.CreateTestAgentClient(AgentName, Instructions);
+ AIProjectClient client = this.CreateTestAgentClient(AgentName, Instructions);
// Act
var agent = client.CreateAIAgent(
@@ -1965,7 +1966,7 @@ public sealed class AgentClientExtensionsTests
var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" };
var agentDefinitionResponse = GeneratePromptDefinitionResponse(definition, null);
- AgentClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: agentDefinitionResponse);
+ AIProjectClient client = this.CreateTestAgentClient(agentName: "test-agent", agentDefinitionResponse: agentDefinitionResponse);
var options = new AgentVersionCreationOptions(definition);
@@ -1995,14 +1996,16 @@ public sealed class AgentClientExtensionsTests
{
// Arrange
RequestOptions? capturedRequestOptions = null;
- var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
- mockAgentClient
+
+ var mockAgentOperations = new Mock();
+ mockAgentOperations
.Setup(x => x.GetAgent(It.IsAny(), It.IsAny()))
.Callback((name, options) => capturedRequestOptions = options)
.Returns(ClientResult.FromResponse(new MockPipelineResponse(200, BinaryData.FromString(TestDataUtil.GetAgentResponseJson()))));
- mockAgentClient.Setup(x => x.GetOpenAIClient(It.IsAny()))
- .Returns(new OpenAIClient(new ApiKeyCredential("test-key")));
+ var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
+ mockAgentClient.SetupGet(x => x.Agents).Returns(mockAgentOperations.Object);
+ mockAgentClient.Setup(x => x.GetConnection(It.IsAny())).Returns(new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None));
// Act
var agent = mockAgentClient.Object.GetAIAgent("test-agent");
@@ -2020,15 +2023,16 @@ public sealed class AgentClientExtensionsTests
{
// Arrange
RequestOptions? capturedRequestOptions = null;
- var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
- mockAgentClient
+
+ var mockAgentOperations = new Mock();
+ mockAgentOperations
.Setup(x => x.GetAgentAsync(It.IsAny(), It.IsAny()))
.Callback((name, options) => capturedRequestOptions = options)
.Returns(Task.FromResult(ClientResult.FromResponse(new MockPipelineResponse(200, BinaryData.FromString(TestDataUtil.GetAgentResponseJson())))));
- mockAgentClient.Setup(x => x.GetOpenAIClient(It.IsAny()))
- .Returns(new OpenAIClient(new ApiKeyCredential("test-key")));
-
+ var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
+ mockAgentClient.SetupGet(x => x.Agents).Returns(mockAgentOperations.Object);
+ mockAgentClient.Setup(x => x.GetConnection(It.IsAny())).Returns(new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None));
// Act
var agent = await mockAgentClient.Object.GetAIAgentAsync("test-agent");
@@ -2045,14 +2049,16 @@ public sealed class AgentClientExtensionsTests
{
// Arrange
RequestOptions? capturedRequestOptions = null;
- var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
- mockAgentClient
+
+ var mockAgentOperations = new Mock();
+ mockAgentOperations
.Setup(x => x.CreateAgentVersion(It.IsAny(), It.IsAny(), It.IsAny()))
.Callback((name, content, options) => capturedRequestOptions = options)
.Returns(ClientResult.FromResponse(new MockPipelineResponse(200, BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJson()))));
- mockAgentClient.Setup(x => x.GetOpenAIClient(It.IsAny()))
- .Returns(new OpenAIClient(new ApiKeyCredential("test-key")));
+ var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
+ mockAgentClient.SetupGet(x => x.Agents).Returns(mockAgentOperations.Object);
+ mockAgentClient.Setup(x => x.GetConnection(It.IsAny())).Returns(new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None));
var agentOptions = new ChatClientAgentOptions { Name = "test-agent" };
@@ -2072,14 +2078,16 @@ public sealed class AgentClientExtensionsTests
{
// Arrange
RequestOptions? capturedRequestOptions = null;
- var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
- mockAgentClient
+
+ var mockAgentOperations = new Mock();
+ mockAgentOperations
.Setup(x => x.CreateAgentVersionAsync(It.IsAny(), It.IsAny(), It.IsAny()))
.Callback((name, content, options) => capturedRequestOptions = options)
.Returns(Task.FromResult(ClientResult.FromResponse(new MockPipelineResponse(200, BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJson())))));
- mockAgentClient.Setup(x => x.GetOpenAIClient(It.IsAny()))
- .Returns(new OpenAIClient(new ApiKeyCredential("test-key")));
+ var mockAgentClient = new Mock(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider());
+ mockAgentClient.SetupGet(x => x.Agents).Returns(mockAgentOperations.Object);
+ mockAgentClient.Setup(x => x.GetConnection(It.IsAny())).Returns(new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None));
var agentOptions = new ChatClientAgentOptions { Name = "test-agent" };
@@ -2110,13 +2118,13 @@ public sealed class AgentClientExtensionsTests
#pragma warning restore CA5399
// Arrange
- var agentClient = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var aiProjectClient = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
var agentOptions = new ChatClientAgentOptions { Name = "test-agent" };
// Act
- var agent1 = agentClient.CreateAIAgent("test", agentOptions);
- var agent2 = await agentClient.CreateAIAgentAsync("test", agentOptions);
+ var agent1 = aiProjectClient.CreateAIAgent("test", agentOptions);
+ var agent2 = await aiProjectClient.CreateAIAgentAsync("test", agentOptions);
// Assert
Assert.NotNull(agent1);
@@ -2142,11 +2150,11 @@ public sealed class AgentClientExtensionsTests
#pragma warning restore CA5399
// Arrange
- var agentClient = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var aiProjectClient = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
// Act
- var agent1 = agentClient.GetAIAgent("test");
- var agent2 = await agentClient.GetAIAgentAsync("test");
+ var agent1 = aiProjectClient.GetAIAgent("test");
+ var agent2 = await aiProjectClient.GetAIAgentAsync("test");
// Assert
Assert.NotNull(agent1);
@@ -2155,23 +2163,23 @@ public sealed class AgentClientExtensionsTests
#endregion
- #region GetAIAgent(AgentClient, AgentReference) Tests
+ #region GetAIAgent(AIProjectClient, AgentReference) Tests
///
- /// Verify that GetAIAgent throws ArgumentNullException when AgentClient is null.
+ /// Verify that GetAIAgent throws ArgumentNullException when AIProjectClient is null.
///
[Fact]
public void GetAIAgent_WithAgentReference_WithNullClient_ThrowsArgumentNullException()
{
// Arrange
- AgentClient? client = null;
- var agentReference = new AgentReference("test-name") { Version = "1" };
+ AIProjectClient? client = null;
+ var agentReference = new AgentReference("test-name", "1");
// Act & Assert
var exception = Assert.Throws(() =>
client!.GetAIAgent(agentReference));
- Assert.Equal("agentClient", exception.ParamName);
+ Assert.Equal("aiProjectClient", exception.ParamName);
}
///
@@ -2181,7 +2189,7 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentReference_WithNullAgentReference_ThrowsArgumentNullException()
{
// Arrange
- var mockClient = new Mock();
+ var mockClient = new Mock();
// Act & Assert
var exception = Assert.Throws(() =>
@@ -2197,8 +2205,8 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentReference_CreatesValidAgent()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-name") { Version = "1" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-name", "1");
// Act
var agent = client.GetAIAgent(agentReference);
@@ -2216,8 +2224,8 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentReference_WithClientFactory_AppliesFactoryCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-name") { Version = "1" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-name", "1");
TestChatClient? testChatClient = null;
// Act
@@ -2239,8 +2247,8 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentReference_SetsAgentIdCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-name") { Version = "2" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-name", "2");
// Act
var agent = client.GetAIAgent(agentReference);
@@ -2257,8 +2265,8 @@ public sealed class AgentClientExtensionsTests
public void GetAIAgent_WithAgentReference_WithTools_IncludesToolsInChatOptions()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-name") { Version = "1" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-name", "1");
var tools = new List
{
AIFunctionFactory.Create(() => "test", "test_function", "A test function")
@@ -2286,7 +2294,7 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentRecord_ReturnsAgentRecord()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act
@@ -2305,8 +2313,8 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentReference_ReturnsNullForAgentRecord()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-name") { Version = "1" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-name", "1");
// Act
var agent = client.GetAIAgent(agentReference);
@@ -2327,7 +2335,7 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentVersion_ReturnsAgentVersion()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
// Act
@@ -2346,8 +2354,8 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentReference_ReturnsNullForAgentVersion()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-name") { Version = "1" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-name", "1");
// Act
var agent = client.GetAIAgent(agentReference);
@@ -2368,7 +2376,7 @@ public sealed class AgentClientExtensionsTests
public void ChatClientMetadata_WithAgentRecord_IsPopulatedCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act
@@ -2387,7 +2395,7 @@ public sealed class AgentClientExtensionsTests
public void ChatClientMetadata_WithPromptAgentDefinition_SetsDefaultModelIdFromModel()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
var definition = new PromptAgentDefinition("gpt-4-turbo")
{
Instructions = "Test instructions"
@@ -2412,7 +2420,7 @@ public sealed class AgentClientExtensionsTests
public void ChatClientMetadata_WithAgentVersion_IsPopulatedCorrectly()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
// Act
@@ -2436,8 +2444,8 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentReference_ReturnsAgentReference()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("test-agent") { Version = "1.0" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("test-agent", "1.0");
// Act
var agent = client.GetAIAgent(agentReference);
@@ -2456,7 +2464,7 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentRecord_ReturnsAlsoAgentReference()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentRecord agentRecord = this.CreateTestAgentRecord();
// Act
@@ -2475,7 +2483,7 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentVersion_ReturnsAlsoAgentReference()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
+ AIProjectClient client = this.CreateTestAgentClient();
AgentVersion agentVersion = this.CreateTestAgentVersion();
// Act
@@ -2494,8 +2502,8 @@ public sealed class AgentClientExtensionsTests
public void GetService_WithAgentReference_ReturnsCorrectVersionInformation()
{
// Arrange
- AgentClient client = this.CreateTestAgentClient();
- var agentReference = new AgentReference("versioned-agent") { Version = "3.5" };
+ AIProjectClient client = this.CreateTestAgentClient();
+ var agentReference = new AgentReference("versioned-agent", "3.5");
// Act
var agent = client.GetAIAgent(agentReference);
@@ -2512,7 +2520,7 @@ public sealed class AgentClientExtensionsTests
#region Helper Methods
///
- /// Creates a test AgentClient with fake behavior.
+ /// Creates a test AIProjectClient with fake behavior.
///
private FakeAgentClient CreateTestAgentClient(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null)
{
@@ -2566,74 +2574,84 @@ public sealed class AgentClientExtensionsTests
}
///
- /// Fake AgentClient for testing.
+ /// Fake AIProjectClient for testing.
///
- private sealed class FakeAgentClient : AgentClient
+ private sealed class FakeAgentClient : AIProjectClient
{
- private readonly string? _agentName;
- private readonly string? _instructions;
- private readonly string? _description;
- private readonly AgentDefinition? _agentDefinition;
-
public FakeAgentClient(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null)
{
- this._agentName = agentName;
- this._instructions = instructions;
- this._description = description;
- this._agentDefinition = agentDefinitionResponse;
+ this.Agents = new FakeAIProjectAgentsOperations(agentName, instructions, description, agentDefinitionResponse);
}
- public override OpenAIClient GetOpenAIClient(OpenAIClientOptions? options = null)
+ public override ClientConnection GetConnection(string connectionId)
{
- return new OpenAIClient(new ApiKeyCredential("test-key"), options);
+ return new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None);
}
- public override ClientResult GetAgent(string agentName, RequestOptions options)
- {
- var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson)));
- }
+ public override AIProjectAgentsOperations Agents { get; }
- public override ClientResult GetAgent(string agentName, CancellationToken cancellationToken = default)
+ private sealed class FakeAIProjectAgentsOperations : AIProjectAgentsOperations
{
- var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200));
- }
+ private readonly string? _agentName;
+ private readonly string? _instructions;
+ private readonly string? _description;
+ private readonly AgentDefinition? _agentDefinition;
- public override Task GetAgentAsync(string agentName, RequestOptions options)
- {
- var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson))));
- }
+ public FakeAIProjectAgentsOperations(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null)
+ {
+ this._agentName = agentName;
+ this._instructions = instructions;
+ this._description = description;
+ this._agentDefinition = agentDefinitionResponse;
+ }
- public override Task> GetAgentAsync(string agentName, CancellationToken cancellationToken = default)
- {
- var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)));
- }
+ public override ClientResult GetAgent(string agentName, RequestOptions options)
+ {
+ var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson)));
+ }
- public override ClientResult CreateAgentVersion(string agentName, BinaryContent content, RequestOptions? options = null)
- {
- var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson)));
- }
+ public override ClientResult GetAgent(string agentName, CancellationToken cancellationToken = default)
+ {
+ var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200));
+ }
- public override ClientResult CreateAgentVersion(string agentName, AgentVersionCreationOptions? options = null, CancellationToken cancellationToken = default)
- {
- var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200));
- }
+ public override Task GetAgentAsync(string agentName, RequestOptions options)
+ {
+ var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson))));
+ }
- public override Task CreateAgentVersionAsync(string agentName, BinaryContent content, RequestOptions? options = null)
- {
- var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson))));
- }
+ public override Task> GetAgentAsync(string agentName, CancellationToken cancellationToken = default)
+ {
+ var responseJson = TestDataUtil.GetAgentResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)));
+ }
- public override Task> CreateAgentVersionAsync(string agentName, AgentVersionCreationOptions? options = null, CancellationToken cancellationToken = default)
- {
- var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
- return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)));
+ public override ClientResult CreateAgentVersion(string agentName, BinaryContent content, RequestOptions? options = null)
+ {
+ var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson)));
+ }
+
+ public override ClientResult CreateAgentVersion(string agentName, AgentVersionCreationOptions? options = null, CancellationToken cancellationToken = default)
+ {
+ var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200));
+ }
+
+ public override Task CreateAgentVersionAsync(string agentName, BinaryContent content, RequestOptions? options = null)
+ {
+ var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson))));
+ }
+
+ public override Task> CreateAgentVersionAsync(string agentName, AgentVersionCreationOptions? options = null, CancellationToken cancellationToken = default)
+ {
+ var responseJson = TestDataUtil.GetAgentVersionResponseJson(this._agentName, this._agentDefinition, this._instructions, this._description);
+ return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)));
+ }
}
}
diff --git a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIChatClientTests.cs b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs
similarity index 86%
rename from dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIChatClientTests.cs
rename to dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs
index 8e5be6065a..647beb4451 100644
--- a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIChatClientTests.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/AzureAIProjectChatClientTests.cs
@@ -6,11 +6,11 @@ using System.Net;
using System.Net.Http;
using System.Text;
using System.Threading.Tasks;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
namespace Microsoft.Agents.AI.AzureAI.UnitTests;
-public class AzureAIChatClientTests
+public class AzureAIProjectChatClientTests
{
///
/// Verify that when the ChatOptions has a "conv_" prefixed conversation ID, the chat client uses conversation in the http requests via the chat client
@@ -43,7 +43,7 @@ public class AzureAIChatClientTests
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399
- var client = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
var agent = await client.GetAIAgentAsync(
new ChatClientAgentOptions
@@ -51,7 +51,7 @@ public class AzureAIChatClientTests
Name = "test-agent",
Instructions = "Test instructions",
ChatOptions = new() { ConversationId = "conv_12345" }
- }, openAIClientOptions: new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ });
// Act
var thread = agent.GetNewThread();
@@ -93,14 +93,14 @@ public class AzureAIChatClientTests
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399
- var client = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
var agent = await client.GetAIAgentAsync(
new ChatClientAgentOptions
{
Name = "test-agent",
Instructions = "Test instructions",
- }, openAIClientOptions: new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ });
// Act
var thread = agent.GetNewThread();
@@ -142,7 +142,7 @@ public class AzureAIChatClientTests
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399
- var client = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
var agent = await client.GetAIAgentAsync(
new ChatClientAgentOptions
@@ -150,7 +150,7 @@ public class AzureAIChatClientTests
Name = "test-agent",
Instructions = "Test instructions",
ChatOptions = new() { ConversationId = "conv_should_not_use_default" }
- }, openAIClientOptions: new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ });
// Act
var thread = agent.GetNewThread();
@@ -192,14 +192,14 @@ public class AzureAIChatClientTests
using var httpClient = new HttpClient(httpHandler);
#pragma warning restore CA5399
- var client = new AgentClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ var client = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) });
var agent = await client.GetAIAgentAsync(
new ChatClientAgentOptions
{
Name = "test-agent",
Instructions = "Test instructions",
- }, openAIClientOptions: new() { Transport = new HttpClientPipelineTransport(httpClient) });
+ });
// Act
var thread = agent.GetNewThread();
diff --git a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/TestDataUtil.cs b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/TestDataUtil.cs
index 6305e58b89..c65d10de43 100644
--- a/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/TestDataUtil.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.AzureAI.UnitTests/TestDataUtil.cs
@@ -2,7 +2,7 @@
using System.ClientModel.Primitives;
using System.IO;
-using Azure.AI.Agents;
+using Azure.AI.Projects.OpenAI;
namespace Microsoft.Agents.AI.AzureAI.UnitTests;
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/AgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/AgentProvider.cs
index 1ea1690458..daec465020 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/AgentProvider.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/AgentProvider.cs
@@ -3,7 +3,7 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
-using Azure.AI.Agents;
+using Azure.AI.Projects.OpenAI;
using Microsoft.Extensions.Configuration;
namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents;
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/FunctionToolAgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/FunctionToolAgentProvider.cs
index d9e9544e08..4ac24c440a 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/FunctionToolAgentProvider.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/FunctionToolAgentProvider.cs
@@ -2,7 +2,8 @@
using System;
using System.Collections.Generic;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
@@ -23,10 +24,10 @@ internal sealed class FunctionToolAgentProvider(IConfiguration configuration) :
AIFunctionFactory.Create(menuPlugin.GetItemPrice),
];
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "MenuAgent",
agentDefinition: this.DefineMenuAgent(functions),
agentDescription: "Provides information about the restaurant menu");
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MarketingAgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MarketingAgentProvider.cs
index f8a4a02e5c..a983794759 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MarketingAgentProvider.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MarketingAgentProvider.cs
@@ -2,7 +2,8 @@
using System;
using System.Collections.Generic;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -13,22 +14,22 @@ internal sealed class MarketingAgentProvider(IConfiguration configuration) : Age
{
protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "AnalystAgent",
agentDefinition: this.DefineAnalystAgent(),
agentDescription: "Analyst agent for Marketing workflow");
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "WriterAgent",
agentDefinition: this.DefineWriterAgent(),
agentDescription: "Writer agent for Marketing workflow");
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "EditorAgent",
agentDefinition: this.DefineEditorAgent(),
agentDescription: "Editor agent for Marketing workflow");
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MathChatAgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MathChatAgentProvider.cs
index a86f75d96a..27cdca3515 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MathChatAgentProvider.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/MathChatAgentProvider.cs
@@ -2,7 +2,8 @@
using System;
using System.Collections.Generic;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -13,16 +14,16 @@ internal sealed class MathChatAgentProvider(IConfiguration configuration) : Agen
{
protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "StudentAgent",
agentDefinition: this.DefineStudentAgent(),
agentDescription: "Student agent for MathChat workflow");
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "TeacherAgent",
agentDefinition: this.DefineTeacherAgent(),
agentDescription: "Teacher agent for MathChat workflow");
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/PoemAgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/PoemAgentProvider.cs
index 9ee7797edf..9706c6227c 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/PoemAgentProvider.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/PoemAgentProvider.cs
@@ -2,7 +2,8 @@
using System;
using System.Collections.Generic;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -13,10 +14,10 @@ internal sealed class PoemAgentProvider(IConfiguration configuration) : AgentPro
{
protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint)
{
- AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
+ AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
yield return
- await agentClient.CreateAgentAsync(
+ await aiProjectClient.CreateAgentAsync(
agentName: "PoemAgent",
agentDefinition: this.DefinePoemAgent(),
agentDescription: "Authors original poems");
diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/TestAgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/TestAgentProvider.cs
index 0f129e174a..078b6321c0 100644
--- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/TestAgentProvider.cs
+++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/TestAgentProvider.cs
@@ -2,7 +2,8 @@
using System;
using System.Collections.Generic;
-using Azure.AI.Agents;
+using Azure.AI.Projects;
+using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -13,10 +14,10 @@ internal sealed class TestAgentProvider(IConfiguration configuration) : AgentPro
{
protected override async IAsyncEnumerable