From b0613a8cebdee0e67f81acb1553d9cc1f9318c2b Mon Sep 17 00:00:00 2001 From: Roger Barreto <19890735+rogerbarreto@users.noreply.github.com> Date: Thu, 2 Apr 2026 15:02:29 +0100 Subject: [PATCH] .NET: Bump Azure.AI.Projects to 2.0.0 GA (#5060) * Bump Azure.AI.Projects to 2.0.0 GA - Update Azure.AI.Projects from 2.0.0-beta.2 to 2.0.0 in CPM - Update Azure.Identity from 1.19.0 to 1.20.0 (transitive dep) - Update System.ClientModel from 1.9.0 to 1.10.0 (transitive dep) - Rename types per Azure.AI.Projects.Agents 2.0.0 breaking changes: - AgentVersion -> ProjectsAgentVersion - AgentRecord -> ProjectsAgentRecord - AgentDefinition -> ProjectsAgentDefinition - AgentVersionCreationOptions -> ProjectsAgentVersionCreationOptions - PromptAgentDefinition -> DeclarativeAgentDefinition - AgentTool -> ProjectsAgentTool - AgentsClient -> AgentAdministrationClient - .Agents property -> .AgentAdministrationClient - Add using Azure.AI.Projects.Memory namespace (types moved) - Update AGENTS.md with BOM and output capture conventions * Address PR review feedback - Rename AIProjectClient parameter to aiProjectClient in AsChatClientAgent overloads - Fix XML doc: ProjectsAgentTool namespace from Azure.AI.Projects.OpenAI to Azure.AI.Projects.Agents - Rename test method to reflect DeclarativeAgentDefinition terminology --- dotnet/AGENTS.md | 3 +- dotnet/Directory.Packages.props | 6 +- .../Agent_With_AzureAIProject/Program.cs | 14 +- .../Program.cs | 8 +- .../Agents/Agent_Step07_AsMcpTool/Program.cs | 6 +- .../Program.cs | 8 +- .../Agent_Step22_MemorySearch/Program.cs | 1 + .../FoundryAgent_Hosted_MCP/Program.cs | 14 +- .../Agents/FoundryAgent/Program.cs | 12 +- .../Declarative/CustomerSupport/Program.cs | 12 +- .../Declarative/DeepResearch/Program.cs | 20 +- .../Declarative/FunctionTools/Program.cs | 4 +- .../Declarative/HostedWorkflow/Program.cs | 8 +- .../Declarative/InputArguments/Program.cs | 6 +- .../Declarative/InvokeFunctionTool/Program.cs | 4 +- .../Declarative/InvokeMcpTool/Program.cs | 4 +- .../Declarative/Marketing/Program.cs | 8 +- .../Declarative/StudentTeacher/Program.cs | 4 +- .../Declarative/ToolApproval/Program.cs | 2 +- .../A2AServer/HostAgentFactory.cs | 2 +- .../AzureAIProjectChatClient.cs | 20 +- .../AzureAIProjectChatClientExtensions.cs | 36 +-- .../FoundryAITool.cs | 24 +- .../Memory/FoundryMemoryProvider.cs | 1 + .../Memory/MemoryStoreExtensions.cs | 1 + .../AzureAgentProvider.cs | 16 +- .../src/Shared/Foundry/Agents/AgentFactory.cs | 8 +- .../FoundryVersionedAgentCreateTests.cs | 50 ++-- .../FoundryVersionedAgentFixture.cs | 32 +-- .../Memory/FoundryMemoryProviderTests.cs | 1 + ...AzureAIProjectChatClientExtensionsTests.cs | 258 +++++++++--------- .../TestDataUtil.cs | 16 +- .../Agents/AgentProvider.cs | 4 +- .../Agents/FunctionToolAgentProvider.cs | 6 +- .../Agents/MarketingAgentProvider.cs | 10 +- .../Agents/MathChatAgentProvider.cs | 6 +- .../Agents/PoemAgentProvider.cs | 4 +- .../Agents/TestAgentProvider.cs | 4 +- .../Agents/VisionAgentProvider.cs | 4 +- 39 files changed, 326 insertions(+), 321 deletions(-) diff --git a/dotnet/AGENTS.md b/dotnet/AGENTS.md index 4cb4b67e5f..1281bbb0c0 100644 --- a/dotnet/AGENTS.md +++ b/dotnet/AGENTS.md @@ -29,7 +29,8 @@ using types like `IChatClient`, `FunctionInvokingChatClient`, `AITool`, `AIFunct ## Key Conventions -- **Encoding**: All new files must be saved with UTF-8 encoding with BOM (Byte Order Mark). This is required for `dotnet format` to work correctly. +- **Command output capture**: When running `dotnet build`, `dotnet test`, `dotnet format`, or similar commands, redirect output to a temp file first (e.g., `dotnet build --tl:off 2>&1 | Out-File $env:TEMP\build.log`), then analyze the file as needed. This avoids re-running expensive commands when the initial analysis misses something. +- **Encoding**: All new files must be saved with UTF-8 encoding with BOM (Byte Order Mark). This is required for `dotnet format` to work correctly. When using PowerShell `Set-Content`, always pass `-Encoding UTF8BOM` to preserve the BOM (e.g., `Set-Content $file $content -NoNewline -Encoding UTF8BOM`). - **Copyright header**: `// Copyright (c) Microsoft. All rights reserved.` at top of all `.cs` files - **XML docs**: Required for all public methods and classes - **Async**: Use `Async` suffix for methods returning `Task`/`ValueTask` diff --git a/dotnet/Directory.Packages.props b/dotnet/Directory.Packages.props index e0ed40023f..1d3c2608b9 100644 --- a/dotnet/Directory.Packages.props +++ b/dotnet/Directory.Packages.props @@ -19,10 +19,10 @@ - + - + @@ -35,7 +35,7 @@ - + diff --git a/dotnet/samples/02-agents/AgentProviders/Agent_With_AzureAIProject/Program.cs b/dotnet/samples/02-agents/AgentProviders/Agent_With_AzureAIProject/Program.cs index 355f4e1380..f5321c4350 100644 --- a/dotnet/samples/02-agents/AgentProviders/Agent_With_AzureAIProject/Program.cs +++ b/dotnet/samples/02-agents/AgentProviders/Agent_With_AzureAIProject/Program.cs @@ -20,10 +20,10 @@ const string JokerName = "JokerAgent"; var aiProjectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()); // Define the agent you want to create. (Prompt Agent in this case) -var agentVersionCreationOptions = new AgentVersionCreationOptions(new PromptAgentDefinition(model: deploymentName) { Instructions = "You are good at telling jokes." }); +var agentVersionCreationOptions = new ProjectsAgentVersionCreationOptions(new DeclarativeAgentDefinition(model: deploymentName) { Instructions = "You are good at telling jokes." }); // 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 createdAgentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options: agentVersionCreationOptions); +var createdAgentVersion = aiProjectClient.AgentAdministrationClient.CreateAgentVersion(agentName: JokerName, options: agentVersionCreationOptions); // Note: // agentVersion.Id = ":", @@ -34,15 +34,15 @@ var createdAgentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: J FoundryAgent existingJokerAgent = aiProjectClient.AsAIAgent(createdAgentVersion); // You can also create another AIAgent version by providing the same name with a different definition. -AgentVersion newJokerAgentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync( +ProjectsAgentVersion newJokerAgentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( JokerName, - new AgentVersionCreationOptions(new PromptAgentDefinition(model: deploymentName) { Instructions = "You are extremely hilarious at telling jokes." })); + new ProjectsAgentVersionCreationOptions(new DeclarativeAgentDefinition(model: deploymentName) { Instructions = "You are extremely hilarious at telling jokes." })); FoundryAgent newJokerAgent = aiProjectClient.AsAIAgent(newJokerAgentVersion); // You can also get the AIAgent latest version just providing its name. -AgentRecord jokerAgentRecord = await aiProjectClient.Agents.GetAgentAsync(JokerName); +ProjectsAgentRecord jokerAgentRecord = await aiProjectClient.AgentAdministrationClient.GetAgentAsync(JokerName); FoundryAgent jokerAgentLatest = aiProjectClient.AsAIAgent(jokerAgentRecord); -AgentVersion latestAgentVersion = jokerAgentRecord.GetLatestVersion(); +ProjectsAgentVersion latestAgentVersion = jokerAgentRecord.GetLatestVersion(); // The AIAgent version can be accessed via the GetService method. Console.WriteLine($"Latest agent version id: {latestAgentVersion.Id}"); @@ -55,4 +55,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.", session)); // Cleanup by agent name removes both agent versions created. -aiProjectClient.Agents.DeleteAgent(existingJokerAgent.Name); +aiProjectClient.AgentAdministrationClient.DeleteAgent(existingJokerAgent.Name); diff --git a/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step04_FoundryServiceRAG/Program.cs b/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step04_FoundryServiceRAG/Program.cs index 7eb5bd5a39..c68310eae5 100644 --- a/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step04_FoundryServiceRAG/Program.cs +++ b/dotnet/samples/02-agents/AgentWithRAG/AgentWithRAG_Step04_FoundryServiceRAG/Program.cs @@ -44,10 +44,10 @@ ClientResult vectorStoreCreate = await vectorStoreClient.CreateVect FileSearchTool fileSearchTool = new([vectorStoreCreate.Value.Id]); #pragma warning restore OPENAI001 -AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync( +ProjectsAgentVersion agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( "AskContoso", - new AgentVersionCreationOptions( - new PromptAgentDefinition(model: deploymentName) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(model: deploymentName) { Instructions = "You are a helpful support specialist for Contoso Outdoors. Answer questions using the provided context and cite the source document when available.", Tools = { fileSearchTool } @@ -68,4 +68,4 @@ Console.WriteLine(await agent.RunAsync("What is the best way to maintain the Tra // Cleanup await fileClient.DeleteFileAsync(uploadResult.Value.Id); await vectorStoreClient.DeleteVectorStoreAsync(vectorStoreCreate.Value.Id); -await aiProjectClient.Agents.DeleteAgentAsync(agent.Name); +await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(agent.Name); diff --git a/dotnet/samples/02-agents/Agents/Agent_Step07_AsMcpTool/Program.cs b/dotnet/samples/02-agents/Agents/Agent_Step07_AsMcpTool/Program.cs index a63063b6a5..5ab4406abd 100644 --- a/dotnet/samples/02-agents/Agents/Agent_Step07_AsMcpTool/Program.cs +++ b/dotnet/samples/02-agents/Agents/Agent_Step07_AsMcpTool/Program.cs @@ -19,10 +19,10 @@ var deploymentName = Environment.GetEnvironmentVariable("AZURE_AI_MODEL_DEPLOYME var aiProjectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()); // Create a server side agent and expose it as an AIAgent. -AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync( +ProjectsAgentVersion agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( "Joker", - new AgentVersionCreationOptions( - new PromptAgentDefinition(model: deploymentName) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(model: deploymentName) { Instructions = "You are good at telling jokes, and you always start each joke with 'Aye aye, captain!'.", }) diff --git a/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step00_FoundryAgentLifecycle/Program.cs b/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step00_FoundryAgentLifecycle/Program.cs index 16c219e144..9a22d1cddf 100644 --- a/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step00_FoundryAgentLifecycle/Program.cs +++ b/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step00_FoundryAgentLifecycle/Program.cs @@ -18,10 +18,10 @@ const string JokerName = "JokerAgent"; AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential()); // Create a server-side agent version using the native SDK. -AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync( +ProjectsAgentVersion agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( JokerName, - new AgentVersionCreationOptions( - new PromptAgentDefinition(model: deploymentName) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(model: deploymentName) { Instructions = "You are good at telling jokes.", })); @@ -33,4 +33,4 @@ FoundryAgent agent = aiProjectClient.AsAIAgent(agentVersion); Console.WriteLine(await agent.RunAsync("Tell me a joke about a pirate.")); // Cleanup: deletes the agent and all its versions. -await aiProjectClient.Agents.DeleteAgentAsync(agent.Name); +await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(agent.Name); diff --git a/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step22_MemorySearch/Program.cs b/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step22_MemorySearch/Program.cs index f2b447e52e..b00cc2f801 100644 --- a/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step22_MemorySearch/Program.cs +++ b/dotnet/samples/02-agents/AgentsWithFoundry/Agent_Step22_MemorySearch/Program.cs @@ -7,6 +7,7 @@ using Azure.AI.Extensions.OpenAI; using Azure.AI.Projects; using Azure.AI.Projects.Agents; +using Azure.AI.Projects.Memory; using Azure.Identity; using Microsoft.Agents.AI; using Microsoft.Agents.AI.Foundry; diff --git a/dotnet/samples/02-agents/ModelContextProtocol/FoundryAgent_Hosted_MCP/Program.cs b/dotnet/samples/02-agents/ModelContextProtocol/FoundryAgent_Hosted_MCP/Program.cs index ffd576d273..7d64ad9399 100644 --- a/dotnet/samples/02-agents/ModelContextProtocol/FoundryAgent_Hosted_MCP/Program.cs +++ b/dotnet/samples/02-agents/ModelContextProtocol/FoundryAgent_Hosted_MCP/Program.cs @@ -31,10 +31,10 @@ var mcpTool = ResponseTool.CreateMcpTool( toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.NeverRequireApproval)); // Create a server side agent with the mcp tool, and expose it as an AIAgent. -AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync( +ProjectsAgentVersion agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( "MicrosoftLearnAgent", - new AgentVersionCreationOptions( - new PromptAgentDefinition(model: model) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(model: model) { Instructions = "You answer questions by searching the Microsoft Learn content only.", Tools = { mcpTool } @@ -47,7 +47,7 @@ AgentSession session = await agent.CreateSessionAsync(); Console.WriteLine(await agent.RunAsync("Please summarize the Azure AI Agent documentation related to MCP Tool calling?", session)); // Cleanup for sample purposes. -aiProjectClient.Agents.DeleteAgent(agent.Name); +aiProjectClient.AgentAdministrationClient.DeleteAgent(agent.Name); // **** MCP Tool with Approval Required **** // ***************************************** @@ -61,10 +61,10 @@ var mcpToolWithApproval = ResponseTool.CreateMcpTool( toolCallApprovalPolicy: new McpToolCallApprovalPolicy(GlobalMcpToolCallApprovalPolicy.AlwaysRequireApproval)); // Create an agent with the MCP tool that requires approval. -AgentVersion agentVersionWithApproval = await aiProjectClient.Agents.CreateAgentVersionAsync( +ProjectsAgentVersion agentVersionWithApproval = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( "MicrosoftLearnAgentWithApproval", - new AgentVersionCreationOptions( - new PromptAgentDefinition(model: model) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(model: model) { Instructions = "You answer questions by searching the Microsoft Learn content only.", Tools = { mcpToolWithApproval } diff --git a/dotnet/samples/03-workflows/Agents/FoundryAgent/Program.cs b/dotnet/samples/03-workflows/Agents/FoundryAgent/Program.cs index 1ecbbae08e..458c280ca1 100644 --- a/dotnet/samples/03-workflows/Agents/FoundryAgent/Program.cs +++ b/dotnet/samples/03-workflows/Agents/FoundryAgent/Program.cs @@ -58,9 +58,9 @@ public static class Program finally { // Cleanup the agents created for the sample. - await aiProjectClient.Agents.DeleteAgentAsync(frenchAgent.Name); - await aiProjectClient.Agents.DeleteAgentAsync(spanishAgent.Name); - await aiProjectClient.Agents.DeleteAgentAsync(englishAgent.Name); + await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(frenchAgent.Name); + await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(spanishAgent.Name); + await aiProjectClient.AgentAdministrationClient.DeleteAgentAsync(englishAgent.Name); } } @@ -76,10 +76,10 @@ public static class Program AIProjectClient aiProjectClient, string model) { - AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync( + ProjectsAgentVersion agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync( $"{targetLanguage} Translator", - new AgentVersionCreationOptions( - new PromptAgentDefinition(model: model) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(model: model) { Instructions = $"You are a translation assistant that translates the provided text to {targetLanguage}.", })); diff --git a/dotnet/samples/03-workflows/Declarative/CustomerSupport/Program.cs b/dotnet/samples/03-workflows/Declarative/CustomerSupport/Program.cs index 5b0458f23d..fe7db42611 100644 --- a/dotnet/samples/03-workflows/Declarative/CustomerSupport/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/CustomerSupport/Program.cs @@ -97,7 +97,7 @@ internal sealed class Program agentDescription: "Escalate agent for human support"); } - private static PromptAgentDefinition DefineSelfServiceAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineSelfServiceAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -144,7 +144,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineTicketingAgent(IConfiguration configuration, TicketingPlugin plugin) => + private static DeclarativeAgentDefinition DefineTicketingAgent(IConfiguration configuration, TicketingPlugin plugin) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -208,7 +208,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineTicketRoutingAgent(IConfiguration configuration, TicketingPlugin plugin) => + private static DeclarativeAgentDefinition DefineTicketRoutingAgent(IConfiguration configuration, TicketingPlugin plugin) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -253,7 +253,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineWindowsSupportAgent(IConfiguration configuration, TicketingPlugin plugin) => + private static DeclarativeAgentDefinition DefineWindowsSupportAgent(IConfiguration configuration, TicketingPlugin plugin) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -323,7 +323,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineResolutionAgent(IConfiguration configuration, TicketingPlugin plugin) => + private static DeclarativeAgentDefinition DefineResolutionAgent(IConfiguration configuration, TicketingPlugin plugin) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -357,7 +357,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition TicketEscalationAgent(IConfiguration configuration, TicketingPlugin plugin) => + private static DeclarativeAgentDefinition TicketEscalationAgent(IConfiguration configuration, TicketingPlugin plugin) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/03-workflows/Declarative/DeepResearch/Program.cs b/dotnet/samples/03-workflows/Declarative/DeepResearch/Program.cs index e415c7aad0..bbf388737d 100644 --- a/dotnet/samples/03-workflows/Declarative/DeepResearch/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/DeepResearch/Program.cs @@ -88,7 +88,7 @@ internal sealed class Program agentDescription: "Weather agent for DeepResearch workflow"); } - private static PromptAgentDefinition DefineResearchAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineResearchAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -114,13 +114,13 @@ internal sealed class Program """, Tools = { - //AgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available + //ProjectsAgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available // new BingGroundingSearchToolParameters( // [new BingGroundingSearchConfiguration(this.GetSetting(Settings.FoundryGroundingTool))])) } }; - private static PromptAgentDefinition DefinePlannerAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefinePlannerAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = // TODO: Use Structured Inputs / Prompt Template @@ -139,7 +139,7 @@ internal sealed class Program """ }; - private static PromptAgentDefinition DefineManagerAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineManagerAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = // TODO: Use Structured Inputs / Prompt Template @@ -225,7 +225,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineSummaryAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineSummaryAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -240,18 +240,18 @@ internal sealed class Program """ }; - private static PromptAgentDefinition DefineKnowledgeAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineKnowledgeAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Tools = { - //AgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available + //ProjectsAgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available // new BingGroundingSearchToolParameters( // [new BingGroundingSearchConfiguration(this.GetSetting(Settings.FoundryGroundingTool))])) } }; - private static PromptAgentDefinition DefineCoderAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineCoderAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -265,7 +265,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineWeatherAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineWeatherAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -274,7 +274,7 @@ internal sealed class Program """, Tools = { - AgentTool.CreateOpenApiTool( + ProjectsAgentTool.CreateOpenApiTool( new OpenApiFunctionDefinition( "weather-forecast", BinaryData.FromString(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "wttr.json"))), diff --git a/dotnet/samples/03-workflows/Declarative/FunctionTools/Program.cs b/dotnet/samples/03-workflows/Declarative/FunctionTools/Program.cs index a1bd9de8f9..8413dfb5ec 100644 --- a/dotnet/samples/03-workflows/Declarative/FunctionTools/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/FunctionTools/Program.cs @@ -67,9 +67,9 @@ internal sealed class Program agentDescription: "Provides information about the restaurant menu"); } - private static PromptAgentDefinition DefineMenuAgent(IConfiguration configuration, AIFunction[] functions) + private static DeclarativeAgentDefinition DefineMenuAgent(IConfiguration configuration, AIFunction[] functions) { - PromptAgentDefinition agentDefinition = + DeclarativeAgentDefinition agentDefinition = new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/03-workflows/Declarative/HostedWorkflow/Program.cs b/dotnet/samples/03-workflows/Declarative/HostedWorkflow/Program.cs index 1d688531df..a871d233ca 100644 --- a/dotnet/samples/03-workflows/Declarative/HostedWorkflow/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/HostedWorkflow/Program.cs @@ -46,7 +46,7 @@ internal sealed class Program await CreateAgentsAsync(aiProjectClient, configuration); // Ensure workflow agent exists in Foundry. - AgentVersion agentVersion = await CreateWorkflowAsync(aiProjectClient, configuration); + ProjectsAgentVersion agentVersion = await CreateWorkflowAsync(aiProjectClient, configuration); string workflowInput = GetWorkflowInput(args); @@ -86,7 +86,7 @@ internal sealed class Program } } - private static async Task CreateWorkflowAsync(AIProjectClient agentClient, IConfiguration configuration) + private static async Task CreateWorkflowAsync(AIProjectClient agentClient, IConfiguration configuration) { string workflowYaml = File.ReadAllText("MathChat.yaml"); @@ -114,7 +114,7 @@ internal sealed class Program agentDescription: "Teacher agent for MathChat workflow"); } - private static PromptAgentDefinition DefineStudentAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineStudentAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -127,7 +127,7 @@ internal sealed class Program """ }; - private static PromptAgentDefinition DefineTeacherAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineTeacherAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/03-workflows/Declarative/InputArguments/Program.cs b/dotnet/samples/03-workflows/Declarative/InputArguments/Program.cs index 0a6f99f920..4fccbcbc35 100644 --- a/dotnet/samples/03-workflows/Declarative/InputArguments/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/InputArguments/Program.cs @@ -68,7 +68,7 @@ internal sealed class Program agentDescription: "Chats with the user with location awareness."); } - private static PromptAgentDefinition DefineLocationTriageAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineLocationTriageAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -79,7 +79,7 @@ internal sealed class Program """ }; - private static PromptAgentDefinition DefineLocationCaptureAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineLocationCaptureAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -128,7 +128,7 @@ internal sealed class Program } }; - private static PromptAgentDefinition DefineLocationAwareAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineLocationAwareAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { // Parameterized instructions reference the "location" input argument. diff --git a/dotnet/samples/03-workflows/Declarative/InvokeFunctionTool/Program.cs b/dotnet/samples/03-workflows/Declarative/InvokeFunctionTool/Program.cs index 8875d204f2..7d8323a45a 100644 --- a/dotnet/samples/03-workflows/Declarative/InvokeFunctionTool/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/InvokeFunctionTool/Program.cs @@ -63,9 +63,9 @@ internal sealed class Program agentDescription: "Provides information about the restaurant menu"); } - private static PromptAgentDefinition DefineMenuAgent(IConfiguration configuration, AIFunction[] functions) + private static DeclarativeAgentDefinition DefineMenuAgent(IConfiguration configuration, AIFunction[] functions) { - PromptAgentDefinition agentDefinition = + DeclarativeAgentDefinition agentDefinition = new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/03-workflows/Declarative/InvokeMcpTool/Program.cs b/dotnet/samples/03-workflows/Declarative/InvokeMcpTool/Program.cs index 7da862df92..560b6d25ca 100644 --- a/dotnet/samples/03-workflows/Declarative/InvokeMcpTool/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/InvokeMcpTool/Program.cs @@ -125,9 +125,9 @@ internal sealed class Program agentDescription: "Provides information based on search results"); } - private static PromptAgentDefinition DefineSearchAgent(IConfiguration configuration) + private static DeclarativeAgentDefinition DefineSearchAgent(IConfiguration configuration) { - return new PromptAgentDefinition(configuration.GetValue(Application.Settings.FoundryModel)) + return new DeclarativeAgentDefinition(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = """ diff --git a/dotnet/samples/03-workflows/Declarative/Marketing/Program.cs b/dotnet/samples/03-workflows/Declarative/Marketing/Program.cs index 5d73edd26d..1f4585c2c7 100644 --- a/dotnet/samples/03-workflows/Declarative/Marketing/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/Marketing/Program.cs @@ -67,7 +67,7 @@ internal sealed class Program agentDescription: "Editor agent for Marketing workflow"); } - private static PromptAgentDefinition DefineAnalystAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineAnalystAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -79,13 +79,13 @@ internal sealed class Program """, Tools = { - //AgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available + //ProjectsAgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available // new BingGroundingSearchToolParameters( // [new BingGroundingSearchConfiguration(configuration[Application.Settings.FoundryGroundingTool])])) } }; - private static PromptAgentDefinition DefineWriterAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineWriterAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -96,7 +96,7 @@ internal sealed class Program """ }; - private static PromptAgentDefinition DefineEditorAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineEditorAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/03-workflows/Declarative/StudentTeacher/Program.cs b/dotnet/samples/03-workflows/Declarative/StudentTeacher/Program.cs index 4f1d31a2ea..8cbee41e63 100644 --- a/dotnet/samples/03-workflows/Declarative/StudentTeacher/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/StudentTeacher/Program.cs @@ -62,7 +62,7 @@ internal sealed class Program agentDescription: "Teacher agent for MathChat workflow"); } - private static PromptAgentDefinition DefineStudentAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineStudentAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = @@ -75,7 +75,7 @@ internal sealed class Program """ }; - private static PromptAgentDefinition DefineTeacherAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineTeacherAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/03-workflows/Declarative/ToolApproval/Program.cs b/dotnet/samples/03-workflows/Declarative/ToolApproval/Program.cs index 9e9bd65b6b..61b751d39c 100644 --- a/dotnet/samples/03-workflows/Declarative/ToolApproval/Program.cs +++ b/dotnet/samples/03-workflows/Declarative/ToolApproval/Program.cs @@ -58,7 +58,7 @@ internal sealed class Program agentDescription: "Searches documents on Microsoft Learn"); } - private static PromptAgentDefinition DefineSearchAgent(IConfiguration configuration) => + private static DeclarativeAgentDefinition DefineSearchAgent(IConfiguration configuration) => new(configuration.GetValue(Application.Settings.FoundryModel)) { Instructions = diff --git a/dotnet/samples/05-end-to-end/A2AClientServer/A2AServer/HostAgentFactory.cs b/dotnet/samples/05-end-to-end/A2AClientServer/A2AServer/HostAgentFactory.cs index 13c01be156..d5f1c9a88d 100644 --- a/dotnet/samples/05-end-to-end/A2AClientServer/A2AServer/HostAgentFactory.cs +++ b/dotnet/samples/05-end-to-end/A2AClientServer/A2AServer/HostAgentFactory.cs @@ -20,7 +20,7 @@ internal static class HostAgentFactory // latency issues, unintended credential probing, and potential security risks from fallback mechanisms. var aiProjectClient = new AIProjectClient(new Uri(endpoint), new DefaultAzureCredential()); - AgentRecord agentRecord = await aiProjectClient.Agents.GetAgentAsync(agentName); + ProjectsAgentRecord agentRecord = await aiProjectClient.AgentAdministrationClient.GetAgentAsync(agentName); AIAgent agent = aiProjectClient.AsAIAgent(agentRecord, tools: tools); AgentCard agentCard = agentType.ToUpperInvariant() switch diff --git a/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClient.cs b/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClient.cs index b33af228b2..c9a121bfc4 100644 --- a/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClient.cs +++ b/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClient.cs @@ -25,8 +25,8 @@ internal sealed class AzureAIProjectChatClient : DelegatingChatClient { private readonly ChatClientMetadata? _metadata; private readonly AIProjectClient _agentClient; - private readonly AgentVersion? _agentVersion; - private readonly AgentRecord? _agentRecord; + private readonly ProjectsAgentVersion? _agentVersion; + private readonly ProjectsAgentRecord? _agentRecord; private readonly ChatOptions? _chatOptions; private readonly AgentReference _agentReference; @@ -56,34 +56,34 @@ internal sealed class AzureAIProjectChatClient : DelegatingChatClient /// Initializes a new instance of the class. /// /// An instance of to interact with Azure AI Agents services. - /// An instance of representing the specific agent to use. + /// An instance of representing the specific agent to use. /// An instance of representing the options on how the agent was predefined. /// /// The provided should be decorated with a for proper functionality. /// - internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, AgentRecord agentRecord, ChatOptions? chatOptions) + internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, ProjectsAgentRecord agentRecord, ChatOptions? chatOptions) : this(aiProjectClient, Throw.IfNull(agentRecord).GetLatestVersion(), chatOptions) { this._agentRecord = agentRecord; } - internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, AgentVersion agentVersion, ChatOptions? chatOptions) + internal AzureAIProjectChatClient(AIProjectClient aiProjectClient, ProjectsAgentVersion agentVersion, ChatOptions? chatOptions) : this( aiProjectClient, CreateAgentReference(Throw.IfNull(agentVersion)), - (agentVersion.Definition as PromptAgentDefinition)?.Model, + (agentVersion.Definition as DeclarativeAgentDefinition)?.Model, chatOptions) { this._agentVersion = agentVersion; } /// - /// Creates an from an . + /// Creates an from an . /// Uses the agent version's version if available, otherwise defaults to "latest". /// /// The agent version to create a reference from. /// An for the specified agent version. - private static AgentReference CreateAgentReference(AgentVersion agentVersion) + private static AgentReference CreateAgentReference(ProjectsAgentVersion agentVersion) { // If the version is null, empty, or whitespace, use "latest" as the default. // This handles cases where hosted agents (like MCP agents) may not have a version assigned. @@ -98,9 +98,9 @@ internal sealed class AzureAIProjectChatClient : DelegatingChatClient ? this._metadata : (serviceKey is null && serviceType == typeof(AIProjectClient)) ? this._agentClient - : (serviceKey is null && serviceType == typeof(AgentVersion)) + : (serviceKey is null && serviceType == typeof(ProjectsAgentVersion)) ? this._agentVersion - : (serviceKey is null && serviceType == typeof(AgentRecord)) + : (serviceKey is null && serviceType == typeof(ProjectsAgentRecord)) ? this._agentRecord : (serviceKey is null && serviceType == typeof(AgentReference)) ? this._agentReference diff --git a/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs index d83299de90..4383cfb6d4 100644 --- a/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Foundry/AzureAIProjectChatClientExtensions.cs @@ -38,7 +38,7 @@ public static partial class AzureAIProjectChatClientExtensions /// The agent with the specified name was not found. /// /// When instantiating a 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. + /// on to retrieve information about the agent like will receive as the result. /// public static FoundryAgent AsAIAgent( this AIProjectClient aiProjectClient, @@ -67,7 +67,7 @@ public static partial class AzureAIProjectChatClientExtensions } /// - /// Uses an existing server side agent, wrapped as a using the provided and . + /// Uses an existing server side agent, wrapped as a using the provided and . /// /// 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 . @@ -78,7 +78,7 @@ public static partial class AzureAIProjectChatClientExtensions /// Thrown when or is . public static FoundryAgent AsAIAgent( this AIProjectClient aiProjectClient, - AgentRecord agentRecord, + ProjectsAgentRecord agentRecord, IList? tools = null, Func? clientFactory = null, IServiceProvider? services = null) @@ -100,7 +100,7 @@ public static partial class AzureAIProjectChatClientExtensions } /// - /// Uses an existing server side agent, wrapped as a using the provided and . + /// Uses an existing server side agent, wrapped as a using the provided and . /// /// The client used to interact with Azure AI Agents. Cannot be . /// The agent version to be converted. Cannot be . @@ -111,7 +111,7 @@ public static partial class AzureAIProjectChatClientExtensions /// Thrown when or is . public static FoundryAgent AsAIAgent( this AIProjectClient aiProjectClient, - AgentVersion agentVersion, + ProjectsAgentVersion agentVersion, IList? tools = null, Func? clientFactory = null, IServiceProvider? services = null) @@ -206,7 +206,7 @@ public static partial class AzureAIProjectChatClientExtensions /// Creates a with the specified options. private static ChatClientAgent CreateChatClientAgent( AIProjectClient aiProjectClient, - AgentVersion agentVersion, + ProjectsAgentVersion agentVersion, ChatClientAgentOptions agentOptions, Func? clientFactory, IServiceProvider? services) @@ -249,7 +249,7 @@ public static partial class AzureAIProjectChatClientExtensions /// This method creates an with the specified ChatClientAgentOptions. private static ChatClientAgent AsChatClientAgent( AIProjectClient aiProjectClient, - AgentVersion agentVersion, + ProjectsAgentVersion agentVersion, ChatClientAgentOptions agentOptions, Func? clientFactory, IServiceProvider? services) @@ -258,7 +258,7 @@ public static partial class AzureAIProjectChatClientExtensions /// This method creates an with the specified ChatClientAgentOptions. private static ChatClientAgent AsChatClientAgent( AIProjectClient aiProjectClient, - AgentRecord agentRecord, + ProjectsAgentRecord agentRecord, ChatClientAgentOptions agentOptions, Func? clientFactory, IServiceProvider? services) @@ -293,14 +293,14 @@ public static partial class AzureAIProjectChatClientExtensions /// This method creates an with a auto-generated ChatClientAgentOptions from the specified configuration parameters. private static ChatClientAgent AsChatClientAgent( - AIProjectClient AIProjectClient, - AgentVersion agentVersion, + AIProjectClient aiProjectClient, + ProjectsAgentVersion agentVersion, IList? tools, Func? clientFactory, bool requireInvocableTools, IServiceProvider? services) => AsChatClientAgent( - AIProjectClient, + aiProjectClient, agentVersion, CreateChatClientAgentOptions(agentVersion, new ChatOptions() { Tools = tools }, requireInvocableTools), clientFactory, @@ -308,21 +308,21 @@ public static partial class AzureAIProjectChatClientExtensions /// This method creates an with a auto-generated ChatClientAgentOptions from the specified configuration parameters. private static ChatClientAgent AsChatClientAgent( - AIProjectClient AIProjectClient, - AgentRecord agentRecord, + AIProjectClient aiProjectClient, + ProjectsAgentRecord agentRecord, IList? tools, Func? clientFactory, bool requireInvocableTools, IServiceProvider? services) => AsChatClientAgent( - AIProjectClient, + aiProjectClient, agentRecord, CreateChatClientAgentOptions(agentRecord.GetLatestVersion(), new ChatOptions() { Tools = tools }, requireInvocableTools), clientFactory, services); /// - /// This method creates for the specified and the provided tools. + /// This method creates for the specified and the provided tools. /// /// The agent version. /// The to use when interacting with the agent. @@ -334,12 +334,12 @@ public static partial class AzureAIProjectChatClientExtensions /// This method rebuilds the agent options from the agent definition returned by the version and combine with the in-proc tools when provided /// this ensures that all required tools are provided and the definition of the agent options are consistent with the agent definition coming from the server. /// - private static ChatClientAgentOptions CreateChatClientAgentOptions(AgentVersion agentVersion, ChatOptions? chatOptions, bool requireInvocableTools) + private static ChatClientAgentOptions CreateChatClientAgentOptions(ProjectsAgentVersion agentVersion, ChatOptions? chatOptions, bool requireInvocableTools) { var agentDefinition = agentVersion.Definition; List? agentTools = null; - if (agentDefinition is PromptAgentDefinition { Tools: { Count: > 0 } definitionTools }) + if (agentDefinition is DeclarativeAgentDefinition { Tools: { Count: > 0 } definitionTools }) { // Check if no tools were provided while the agent definition requires in-proc tools. if (requireInvocableTools && chatOptions?.Tools is not { Count: > 0 } && definitionTools.Any(t => t is FunctionTool)) @@ -395,7 +395,7 @@ public static partial class AzureAIProjectChatClientExtensions Description = agentVersion.Description, }; - if (agentDefinition is PromptAgentDefinition promptAgentDefinition) + if (agentDefinition is DeclarativeAgentDefinition promptAgentDefinition) { agentOptions.ChatOptions ??= chatOptions?.Clone() ?? new(); agentOptions.ChatOptions.Instructions = promptAgentDefinition.Instructions; diff --git a/dotnet/src/Microsoft.Agents.AI.Foundry/FoundryAITool.cs b/dotnet/src/Microsoft.Agents.AI.Foundry/FoundryAITool.cs index 79e221f02f..7721f8c013 100644 --- a/dotnet/src/Microsoft.Agents.AI.Foundry/FoundryAITool.cs +++ b/dotnet/src/Microsoft.Agents.AI.Foundry/FoundryAITool.cs @@ -17,12 +17,12 @@ namespace Microsoft.Agents.AI.Foundry; /// /// /// -/// This class wraps (Azure.AI.Projects.OpenAI) and (OpenAI SDK) factory methods, +/// This class wraps (Azure.AI.Projects.Agents) and (OpenAI SDK) factory methods, /// returning directly — eliminating the need for manual casting and .AsAITool() calls. /// /// /// Instead of writing: -/// ((ResponseTool)AgentTool.CreateOpenApiTool(definition)).AsAITool() +/// ((ResponseTool)ProjectsAgentTool.CreateOpenApiTool(definition)).AsAITool() /// You can write: /// FoundryAITool.CreateOpenApiTool(definition) /// @@ -37,7 +37,7 @@ public static class FoundryAITool /// An wrapping the provided response tool. public static AITool FromResponseTool(ResponseTool responseTool) => responseTool.AsAITool(); - // --- Azure.AI.Projects.OpenAI AgentTool factories --- + // --- Azure.AI.Projects.OpenAI ProjectsAgentTool factories --- /// /// Creates an for OpenAPI tool invocations. @@ -45,7 +45,7 @@ public static class FoundryAITool /// The OpenAPI function definition specifying the API endpoint, schema, and authentication. /// An that calls the specified OpenAPI endpoint. public static AITool CreateOpenApiTool(OpenApiFunctionDefinition definition) - => ((ResponseTool)AgentTool.CreateOpenApiTool(definition)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateOpenApiTool(definition)).AsAITool(); /// /// Creates an for Bing Grounding search. @@ -53,7 +53,7 @@ public static class FoundryAITool /// The Bing Grounding search configuration options. /// An for Bing Grounding search. public static AITool CreateBingGroundingTool(BingGroundingSearchToolOptions options) - => ((ResponseTool)AgentTool.CreateBingGroundingTool(options)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateBingGroundingTool(options)).AsAITool(); /// /// Creates an for Bing Custom Search. @@ -61,7 +61,7 @@ public static class FoundryAITool /// The Bing Custom Search configuration parameters. /// An for Bing Custom Search. public static AITool CreateBingCustomSearchTool(BingCustomSearchToolOptions parameters) - => ((ResponseTool)AgentTool.CreateBingCustomSearchTool(parameters)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateBingCustomSearchTool(parameters)).AsAITool(); /// /// Creates an for Microsoft Fabric data agent. @@ -69,7 +69,7 @@ public static class FoundryAITool /// The Fabric data agent configuration options. /// An for Microsoft Fabric. public static AITool CreateMicrosoftFabricTool(FabricDataAgentToolOptions options) - => ((ResponseTool)AgentTool.CreateMicrosoftFabricTool(options)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateMicrosoftFabricTool(options)).AsAITool(); /// /// Creates an for SharePoint grounding. @@ -77,7 +77,7 @@ public static class FoundryAITool /// The SharePoint grounding configuration options. /// An for SharePoint grounding. public static AITool CreateSharepointTool(SharePointGroundingToolOptions options) - => ((ResponseTool)AgentTool.CreateSharepointTool(options)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateSharepointTool(options)).AsAITool(); /// /// Creates an for Azure AI Search. @@ -85,7 +85,7 @@ public static class FoundryAITool /// Optional Azure AI Search configuration options. /// An for Azure AI Search. public static AITool CreateAzureAISearchTool(AzureAISearchToolOptions? options = null) - => ((ResponseTool)AgentTool.CreateAzureAISearchTool(options)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateAzureAISearchTool(options)).AsAITool(); /// /// Creates an for browser automation. @@ -93,7 +93,7 @@ public static class FoundryAITool /// The browser automation configuration parameters. /// An for browser automation. public static AITool CreateBrowserAutomationTool(BrowserAutomationToolOptions parameters) - => ((ResponseTool)AgentTool.CreateBrowserAutomationTool(parameters)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateBrowserAutomationTool(parameters)).AsAITool(); /// /// Creates an for structured output capture. @@ -101,7 +101,7 @@ public static class FoundryAITool /// The structured output definition. /// An for structured output capture. public static AITool CreateStructuredOutputsTool(StructuredOutputDefinition outputs) - => ((ResponseTool)AgentTool.CreateStructuredOutputsTool(outputs)).AsAITool(); + => ((ResponseTool)ProjectsAgentTool.CreateStructuredOutputsTool(outputs)).AsAITool(); /// /// Creates an for Agent-to-Agent (A2A) communication. @@ -110,7 +110,7 @@ public static class FoundryAITool /// Optional path to the agent card. /// An for A2A communication. public static AITool CreateA2ATool(Uri baseUri, string? agentCardPath = null) - => AgentTool.CreateA2ATool(baseUri, agentCardPath).AsAITool(); + => ProjectsAgentTool.CreateA2ATool(baseUri, agentCardPath).AsAITool(); // --- OpenAI SDK ResponseTool factories --- diff --git a/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs b/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs index cc92c40a41..ffae51cefc 100644 --- a/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs +++ b/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/FoundryMemoryProvider.cs @@ -9,6 +9,7 @@ using System.Text.Json.Serialization; using System.Threading; using System.Threading.Tasks; using Azure.AI.Projects; +using Azure.AI.Projects.Memory; using Microsoft.Extensions.AI; using Microsoft.Extensions.Compliance.Redaction; using Microsoft.Extensions.Logging; diff --git a/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/MemoryStoreExtensions.cs b/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/MemoryStoreExtensions.cs index a696a33e5a..3d988639e8 100644 --- a/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/MemoryStoreExtensions.cs +++ b/dotnet/src/Microsoft.Agents.AI.Foundry/Memory/MemoryStoreExtensions.cs @@ -4,6 +4,7 @@ using System.ClientModel; using System.Threading; using System.Threading.Tasks; using Azure.AI.Projects; +using Azure.AI.Projects.Memory; namespace Microsoft.Agents.AI.Foundry; diff --git a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.Foundry/AzureAgentProvider.cs b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.Foundry/AzureAgentProvider.cs index 6db870f8ec..98e8b7f53f 100644 --- a/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.Foundry/AzureAgentProvider.cs +++ b/dotnet/src/Microsoft.Agents.AI.Workflows.Declarative.Foundry/AzureAgentProvider.cs @@ -28,7 +28,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative; /// The credentials used to authenticate with the Foundry project. This must be a valid instance of . public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential projectCredentials) : ResponseAgentProvider { - private readonly Dictionary _versionCache = []; + private readonly Dictionary _versionCache = []; private readonly Dictionary _agentCache = []; private AIProjectClient? _agentClient; @@ -99,7 +99,7 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj IDictionary? inputArguments, [EnumeratorCancellation] CancellationToken cancellationToken = default) { - AgentVersion agentVersionResult = await this.QueryAgentAsync(agentId, agentVersion, cancellationToken).ConfigureAwait(false); + ProjectsAgentVersion agentVersionResult = await this.QueryAgentAsync(agentId, agentVersion, cancellationToken).ConfigureAwait(false); AIAgent agent = await this.GetAgentAsync(agentVersionResult, cancellationToken).ConfigureAwait(false); ChatOptions chatOptions = @@ -133,10 +133,10 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj } } - private async Task QueryAgentAsync(string agentName, string? agentVersion, CancellationToken cancellationToken = default) + private async Task QueryAgentAsync(string agentName, string? agentVersion, CancellationToken cancellationToken = default) { string agentKey = $"{agentName}:{agentVersion}"; - if (this._versionCache.TryGetValue(agentKey, out AgentVersion? targetAgent)) + if (this._versionCache.TryGetValue(agentKey, out ProjectsAgentVersion? targetAgent)) { return targetAgent; } @@ -145,8 +145,8 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj if (string.IsNullOrEmpty(agentVersion)) { - AgentRecord agentRecord = - await client.Agents.GetAgentAsync( + ProjectsAgentRecord agentRecord = + await client.AgentAdministrationClient.GetAgentAsync( agentName, cancellationToken).ConfigureAwait(false); @@ -155,7 +155,7 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj else { targetAgent = - await client.Agents.GetAgentVersionAsync( + await client.AgentAdministrationClient.GetAgentVersionAsync( agentName, agentVersion, cancellationToken).ConfigureAwait(false); @@ -166,7 +166,7 @@ public sealed class AzureAgentProvider(Uri projectEndpoint, TokenCredential proj return targetAgent; } - private async Task GetAgentAsync(AgentVersion agentVersion, CancellationToken cancellationToken = default) + private async Task GetAgentAsync(ProjectsAgentVersion agentVersion, CancellationToken cancellationToken = default) { if (this._agentCache.TryGetValue(agentVersion.Id, out AIAgent? agent)) { diff --git a/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs b/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs index c2a2770226..4a84192f60 100644 --- a/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs +++ b/dotnet/src/Shared/Foundry/Agents/AgentFactory.cs @@ -12,13 +12,13 @@ namespace Shared.Foundry; internal static class AgentFactory { - public static async ValueTask CreateAgentAsync( + public static async ValueTask CreateAgentAsync( this AIProjectClient aiProjectClient, string agentName, - AgentDefinition agentDefinition, + ProjectsAgentDefinition agentDefinition, string agentDescription) { - AgentVersionCreationOptions options = + ProjectsAgentVersionCreationOptions options = new(agentDefinition) { Description = agentDescription, @@ -29,7 +29,7 @@ internal static class AgentFactory }, }; - AgentVersion agentVersion = await aiProjectClient.Agents.CreateAgentVersionAsync(agentName, options).ConfigureAwait(false); + ProjectsAgentVersion agentVersion = await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync(agentName, options).ConfigureAwait(false); Console.ForegroundColor = ConsoleColor.Cyan; try diff --git a/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentCreateTests.cs b/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentCreateTests.cs index 160ab697f7..329973a194 100644 --- a/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentCreateTests.cs +++ b/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentCreateTests.cs @@ -17,7 +17,7 @@ namespace Foundry.IntegrationTests; /// /// Integration tests for versioned creation via -/// AIProjectClient.Agents.CreateAgentVersionAsync and AIProjectClient.AsAIAgent(AgentVersion). +/// AIProjectClient.AgentAdministrationClient.CreateAgentVersionAsync and AIProjectClient.AsAIAgent(ProjectsAgentVersion). /// public class FoundryVersionedAgentCreateTests { @@ -32,10 +32,10 @@ public class FoundryVersionedAgentCreateTests const string AgentInstructions = "You are an integration test agent"; // Act. - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( AgentName, - new AgentVersionCreationOptions( - new PromptAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = AgentInstructions }) @@ -53,17 +53,17 @@ public class FoundryVersionedAgentCreateTests Assert.Equal(AgentDescription, agent.Description); Assert.Equal(AgentInstructions, agent.GetService()!.Instructions); - var agentRecord = await this._client.Agents.GetAgentAsync(agent.Name); + var agentRecord = await this._client.AgentAdministrationClient.GetAgentAsync(agent.Name); Assert.NotNull(agentRecord); Assert.Equal(AgentName, agentRecord.Value.Name); - var definition = Assert.IsType(agentRecord.Value.GetLatestVersion().Definition); + var definition = Assert.IsType(agentRecord.Value.GetLatestVersion().Definition); Assert.Equal(AgentDescription, agentRecord.Value.GetLatestVersion().Description); Assert.Equal(AgentInstructions, definition.Instructions); } finally { // Cleanup. - await this._client.Agents.DeleteAgentAsync(agent.Name); + await this._client.AgentAdministrationClient.DeleteAgentAsync(agent.Name); } } @@ -95,15 +95,15 @@ public class FoundryVersionedAgentCreateTests var vectorStoreMetadata = await projectOpenAIClient.GetProjectVectorStoresClient().CreateVectorStoreAsync(options: new() { FileIds = { uploadedAgentFile.Id }, Name = "WordCodeLookup_VectorStore" }); // Act — create agent version with FileSearch tool via native SDK, then wrap with AsAIAgent. - var definition = new PromptAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + var definition = new DeclarativeAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = AgentInstructions, Tools = { ResponseTool.CreateFileSearchTool(vectorStoreIds: [vectorStoreMetadata.Value.Id]) } }; - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( AgentName, - new AgentVersionCreationOptions(definition)); + new ProjectsAgentVersionCreationOptions(definition)); var agent = this._client.AsAIAgent(agentVersion); @@ -117,7 +117,7 @@ public class FoundryVersionedAgentCreateTests finally { // Cleanup. - await this._client.Agents.DeleteAgentAsync(agent.Name); + await this._client.AgentAdministrationClient.DeleteAgentAsync(agent.Name); await projectOpenAIClient.GetProjectVectorStoresClient().DeleteVectorStoreAsync(vectorStoreMetadata.Value.Id); await projectOpenAIClient.GetProjectFilesClient().DeleteFileAsync(uploadedAgentFile.Id); File.Delete(searchFilePath); @@ -149,15 +149,15 @@ public class FoundryVersionedAgentCreateTests ); // Act — create agent version with CodeInterpreter tool via native SDK, then wrap with AsAIAgent. - var definition = new PromptAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + var definition = new DeclarativeAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = AgentInstructions, Tools = { ResponseTool.CreateCodeInterpreterTool(new CodeInterpreterToolContainer(CodeInterpreterToolContainerConfiguration.CreateAutomaticContainerConfiguration([uploadedCodeFile.Id]))) } }; - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( AgentName, - new AgentVersionCreationOptions(definition)); + new ProjectsAgentVersionCreationOptions(definition)); var agent = this._client.AsAIAgent(agentVersion); @@ -171,7 +171,7 @@ public class FoundryVersionedAgentCreateTests finally { // Cleanup. - await this._client.Agents.DeleteAgentAsync(agent.Name); + await this._client.AgentAdministrationClient.DeleteAgentAsync(agent.Name); await projectOpenAIClient.GetProjectFilesClient().DeleteFileAsync(uploadedCodeFile.Id); File.Delete(codeFilePath); } @@ -252,14 +252,14 @@ public class FoundryVersionedAgentCreateTests Description = "Retrieve information about countries by currency code" }; - var definition = new PromptAgentDefinition(model: TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + var definition = new DeclarativeAgentDefinition(model: TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = AgentInstructions, - Tools = { (ResponseTool)AgentTool.CreateOpenApiTool(openApiFunction) } + Tools = { (ResponseTool)ProjectsAgentTool.CreateOpenApiTool(openApiFunction) } }; - AgentVersionCreationOptions creationOptions = new(definition); - AgentVersion agentVersion = await this._client.Agents.CreateAgentVersionAsync(AgentName, creationOptions); + ProjectsAgentVersionCreationOptions creationOptions = new(definition); + ProjectsAgentVersion agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync(AgentName, creationOptions); try { @@ -269,7 +269,7 @@ public class FoundryVersionedAgentCreateTests // Assert the agent was created correctly and retains version metadata. Assert.NotNull(agent); Assert.Equal(AgentName, agent.Name); - var retrievedVersion = agent.GetService(); + var retrievedVersion = agent.GetService(); Assert.NotNull(retrievedVersion); // Step 3: Call RunAsync to trigger the server-side OpenAPI function. @@ -301,7 +301,7 @@ public class FoundryVersionedAgentCreateTests finally { // Cleanup. - await this._client.Agents.DeleteAgentAsync(AgentName); + await this._client.AgentAdministrationClient.DeleteAgentAsync(AgentName); } } @@ -317,15 +317,15 @@ public class FoundryVersionedAgentCreateTests // Create agent version with the function tool registered in the server-side definition, // then wrap with AsAIAgent passing the local AIFunction implementation. - var definition = new PromptAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + var definition = new DeclarativeAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = AgentInstructions, }; definition.Tools.Add(weatherFunction.AsOpenAIResponseTool()); - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( AgentName, - new AgentVersionCreationOptions(definition)); + new ProjectsAgentVersionCreationOptions(definition)); FoundryAgent agent = this._client.AsAIAgent(agentVersion, tools: [weatherFunction]); @@ -342,7 +342,7 @@ public class FoundryVersionedAgentCreateTests } finally { - await this._client.Agents.DeleteAgentAsync(agent.Name); + await this._client.AgentAdministrationClient.DeleteAgentAsync(agent.Name); } } } diff --git a/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentFixture.cs b/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentFixture.cs index 2c06404eb6..cceacfa40b 100644 --- a/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentFixture.cs +++ b/dotnet/tests/Foundry.IntegrationTests/FoundryVersionedAgentFixture.cs @@ -19,8 +19,8 @@ namespace Foundry.IntegrationTests; /// /// Integration test fixture that creates versioned Foundry agents via -/// AIProjectClient.Agents.CreateAgentVersionAsync and wraps them -/// with AIProjectClient.AsAIAgent(AgentVersion). +/// AIProjectClient.AgentAdministrationClient.CreateAgentVersionAsync and wraps them +/// with AIProjectClient.AsAIAgent(ProjectsAgentVersion). /// public class FoundryVersionedAgentFixture : IChatClientAgentFixture { @@ -121,7 +121,7 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture string instructions = "You are a helpful assistant.", IList? aiTools = null) { - var definition = new PromptAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + var definition = new DeclarativeAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = instructions }; @@ -139,9 +139,9 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture } } - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( GenerateUniqueAgentName(name), - new AgentVersionCreationOptions(definition)); + new ProjectsAgentVersionCreationOptions(definition)); return this._client.AsAIAgent(agentVersion, tools: aiTools).GetService()!; } @@ -150,15 +150,15 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture { options.Name ??= GenerateUniqueAgentName("HelpfulAssistant"); - var definition = new PromptAgentDefinition( + var definition = new DeclarativeAgentDefinition( options.ChatOptions?.ModelId ?? TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = options.ChatOptions?.Instructions }; - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( options.Name, - new AgentVersionCreationOptions(definition) { Description = options.Description }); + new ProjectsAgentVersionCreationOptions(definition) { Description = options.Description }); var agent = this._client.AsAIAgent(agentVersion, tools: options.ChatOptions?.Tools); @@ -169,7 +169,7 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture $"{baseName}-{Guid.NewGuid().ToString("N").Substring(0, 8)}"; public Task DeleteAgentAsync(ChatClientAgent agent) => - this._client.Agents.DeleteAgentAsync(agent.Name); + this._client.AgentAdministrationClient.DeleteAgentAsync(agent.Name); public async Task DeleteSessionAsync(AgentSession session) { @@ -201,7 +201,7 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture if (this._client is not null && this._agent is not null) { - return new ValueTask(this._client.Agents.DeleteAgentAsync(this._agent.Name)); + return new ValueTask(this._client.AgentAdministrationClient.DeleteAgentAsync(this._agent.Name)); } return default; @@ -211,10 +211,10 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture { this._client = new(new Uri(TestConfiguration.GetRequiredValue(TestSettings.AzureAIProjectEndpoint)), TestAzureCliCredentials.CreateAzureCliCredential()); - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( GenerateUniqueAgentName("HelpfulAssistant"), - new AgentVersionCreationOptions( - new PromptAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) + new ProjectsAgentVersionCreationOptions( + new DeclarativeAgentDefinition(TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = "You are a helpful assistant." })); @@ -227,15 +227,15 @@ public class FoundryVersionedAgentFixture : IChatClientAgentFixture this._client = new(new Uri(TestConfiguration.GetRequiredValue(TestSettings.AzureAIProjectEndpoint)), TestAzureCliCredentials.CreateAzureCliCredential()); options.Name ??= GenerateUniqueAgentName("HelpfulAssistant"); - var definition = new PromptAgentDefinition( + var definition = new DeclarativeAgentDefinition( options.ChatOptions?.ModelId ?? TestConfiguration.GetRequiredValue(TestSettings.AzureAIModelDeploymentName)) { Instructions = options.ChatOptions?.Instructions }; - var agentVersion = await this._client.Agents.CreateAgentVersionAsync( + var agentVersion = await this._client.AgentAdministrationClient.CreateAgentVersionAsync( options.Name, - new AgentVersionCreationOptions(definition) { Description = options.Description }); + new ProjectsAgentVersionCreationOptions(definition) { Description = options.Description }); this._agent = this._client.AsAIAgent(agentVersion, tools: options.ChatOptions?.Tools); } diff --git a/dotnet/tests/Foundry.IntegrationTests/Memory/FoundryMemoryProviderTests.cs b/dotnet/tests/Foundry.IntegrationTests/Memory/FoundryMemoryProviderTests.cs index 9b9b39cbdf..2904d207cd 100644 --- a/dotnet/tests/Foundry.IntegrationTests/Memory/FoundryMemoryProviderTests.cs +++ b/dotnet/tests/Foundry.IntegrationTests/Memory/FoundryMemoryProviderTests.cs @@ -3,6 +3,7 @@ using System; using System.Threading.Tasks; using Azure.AI.Projects; +using Azure.AI.Projects.Memory; using Azure.Identity; using Microsoft.Agents.AI; using Microsoft.Agents.AI.Foundry; diff --git a/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/AzureAIProjectChatClientExtensionsTests.cs b/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/AzureAIProjectChatClientExtensionsTests.cs index c362fb4ec6..e96cbdc487 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/AzureAIProjectChatClientExtensionsTests.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/AzureAIProjectChatClientExtensionsTests.cs @@ -187,7 +187,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests #endregion - #region AsAIAgent(AIProjectClient, AgentRecord) Tests + #region AsAIAgent(AIProjectClient, ProjectsAgentRecord) Tests /// /// Verify that AsAIAgent throws ArgumentNullException when AIProjectClient is null. @@ -197,7 +197,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient? client = null; - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act & Assert var exception = Assert.Throws(() => @@ -217,20 +217,20 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Act & Assert var exception = Assert.Throws(() => - mockClient.Object.AsAIAgent((AgentRecord)null!)); + mockClient.Object.AsAIAgent((ProjectsAgentRecord)null!)); Assert.Equal("agentRecord", exception.ParamName); } /// - /// Verify that AsAIAgent with AgentRecord creates a valid agent. + /// Verify that AsAIAgent with ProjectsAgentRecord creates a valid agent. /// [Fact] public void AsAIAgent_WithAgentRecord_CreatesValidAgent() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act var agent = client.AsAIAgent(agentRecord); @@ -243,14 +243,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that AsAIAgent with AgentRecord and clientFactory applies the factory. + /// Verify that AsAIAgent with ProjectsAgentRecord and clientFactory applies the factory. /// [Fact] public void AsAIAgent_WithAgentRecord_WithClientFactory_AppliesFactoryCorrectly() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); TestChatClient? testChatClient = null; // Act @@ -267,7 +267,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests #endregion - #region AsAIAgent(AIProjectClient, AgentVersion) Tests + #region AsAIAgent(AIProjectClient, ProjectsAgentVersion) Tests /// /// Verify that AsAIAgent throws ArgumentNullException when AIProjectClient is null. @@ -277,7 +277,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient? client = null; - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); // Act & Assert var exception = Assert.Throws(() => @@ -297,20 +297,20 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Act & Assert var exception = Assert.Throws(() => - mockClient.Object.AsAIAgent((AgentVersion)null!)); + mockClient.Object.AsAIAgent((ProjectsAgentVersion)null!)); Assert.Equal("agentVersion", exception.ParamName); } /// - /// Verify that AsAIAgent with AgentVersion creates a valid agent. + /// Verify that AsAIAgent with ProjectsAgentVersion creates a valid agent. /// [Fact] public void AsAIAgent_WithAgentVersion_CreatesValidAgent() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); // Act var agent = client.AsAIAgent(agentVersion); @@ -323,14 +323,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that AsAIAgent with AgentVersion and clientFactory applies the factory. + /// Verify that AsAIAgent with ProjectsAgentVersion and clientFactory applies the factory. /// [Fact] public void AsAIAgent_WithAgentVersion_WithClientFactory_AppliesFactoryCorrectly() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); TestChatClient? testChatClient = null; // Act @@ -353,7 +353,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); var tools = new List { AIFunctionFactory.Create(() => "test", "test_function", "A test function") @@ -375,7 +375,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); // Act - should not throw even without tools when requireInvocableTools is false var agent = client.AsAIAgent(agentVersion); @@ -439,7 +439,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests #endregion - #region AsAIAgent(AIProjectClient, AgentRecord) with tools Tests + #region AsAIAgent(AIProjectClient, ProjectsAgentRecord) with tools Tests /// /// Verify that AsAIAgent with additional tools when the definition has no tools does not throw and results in an agent with no tools. @@ -449,7 +449,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); var tools = new List { AIFunctionFactory.Create(() => "test", "test_function", "A test function") @@ -463,9 +463,9 @@ public sealed class AzureAIProjectChatClientExtensionsTests Assert.IsType(agent); var chatClient = agent.GetService(); Assert.NotNull(chatClient); - var agentVersion = chatClient.GetService(); + var agentVersion = chatClient.GetService(); Assert.NotNull(agentVersion); - var definition = Assert.IsType(agentVersion.Definition); + var definition = Assert.IsType(agentVersion.Definition); Assert.Empty(definition.Tools); } @@ -477,7 +477,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act var agent = client.AsAIAgent(agentRecord, tools: null); @@ -502,7 +502,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests var agentVersion = this.CreateTestAgentVersion(); // Manually add tools to the definition to simulate inline tools - if (agentVersion.Definition is PromptAgentDefinition promptDef) + if (agentVersion.Definition is DeclarativeAgentDefinition promptDef) { promptDef.Tools.Add(ResponseTool.CreateFunctionTool("inline_tool", BinaryData.FromString("{}"), strictModeEnabled: false)); } @@ -513,9 +513,9 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Act & Assert var agent = client.AsAIAgent(agentVersion, tools: [invocableInlineAITool, shouldBeIgnoredTool]); Assert.NotNull(agent); - var version = agent.GetService(); + var version = agent.GetService(); Assert.NotNull(version); - var definition = Assert.IsType(version.Definition); + var definition = Assert.IsType(version.Definition); Assert.NotEmpty(definition.Tools); Assert.NotNull(GetAgentChatOptions(agent)); Assert.NotNull(GetAgentChatOptions(agent)!.Tools); @@ -535,7 +535,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); var tools = new List { AIFunctionFactory.Create(() => "tool1", "param_tool_1", "First parameter tool"), @@ -550,7 +550,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests Assert.IsType(agent); var chatClient = agent.GetService(); Assert.NotNull(chatClient); - var agentVersion = chatClient.GetService(); + var agentVersion = chatClient.GetService(); Assert.NotNull(agentVersion); } @@ -565,7 +565,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests public async Task CreateAIAgentAsync_WithResponseToolsInDefinition_CreatesAgentSuccessfullyAsync() { // Arrange - var definition = new PromptAgentDefinition("test-model") { Instructions = "Test instructions" }; + var definition = new DeclarativeAgentDefinition("test-model") { Instructions = "Test instructions" }; var fabricToolOptions = new FabricDataAgentToolOptions(); fabricToolOptions.ProjectConnections.Add(new ToolProjectConnection("connection-id")); @@ -577,33 +577,33 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Add tools to the definition definition.Tools.Add(ResponseTool.CreateFunctionTool("create_tool", BinaryData.FromString("{}"), strictModeEnabled: false)); - definition.Tools.Add((ResponseTool)AgentTool.CreateBingCustomSearchTool(new BingCustomSearchToolOptions([new BingCustomSearchConfiguration("connection-id", "instance-name")]))); - definition.Tools.Add((ResponseTool)AgentTool.CreateBrowserAutomationTool(new BrowserAutomationToolOptions(new BrowserAutomationToolConnectionParameters("id")))); - definition.Tools.Add(AgentTool.CreateA2ATool(new Uri("https://test-uri.microsoft.com"))); - 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 AzureAISearchToolIndex() { IndexName = "name" }]))); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateBingCustomSearchTool(new BingCustomSearchToolOptions([new BingCustomSearchConfiguration("connection-id", "instance-name")]))); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateBrowserAutomationTool(new BrowserAutomationToolOptions(new BrowserAutomationToolConnectionParameters("id")))); + definition.Tools.Add(ProjectsAgentTool.CreateA2ATool(new Uri("https://test-uri.microsoft.com"))); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateBingGroundingTool(new BingGroundingSearchToolOptions([new BingGroundingSearchConfiguration("connection-id")]))); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateMicrosoftFabricTool(fabricToolOptions)); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateOpenApiTool(new OpenApiFunctionDefinition("name", BinaryData.FromString(OpenAPISpec), new OpenAPIAnonymousAuthenticationDetails()))); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateSharepointTool(sharepointOptions)); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.CreateStructuredOutputsTool(structuredOutputs)); + definition.Tools.Add((ResponseTool)ProjectsAgentTool.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()); using var testClient = CreateTestAgentClientWithHandler(agentDefinitionResponse: definitionResponse); - var options = new AgentVersionCreationOptions(definition); + var options = new ProjectsAgentVersionCreationOptions(definition); // Act - var agentVersion = (await testClient.Client.Agents.CreateAgentVersionAsync("test-agent", options)).Value; + var agentVersion = (await testClient.Client.AgentAdministrationClient.CreateAgentVersionAsync("test-agent", options)).Value; var agent = testClient.Client.AsAIAgent(agentVersion); // Assert Assert.NotNull(agent); Assert.IsType(agent); - var agentVersion2 = agent.GetService()!; + var agentVersion2 = agent.GetService()!; Assert.NotNull(agentVersion); - if (agentVersion2.Definition is PromptAgentDefinition promptDef) + if (agentVersion2.Definition is DeclarativeAgentDefinition promptDef) { Assert.NotEmpty(promptDef.Tools); Assert.Equal(10, promptDef.Tools.Count); @@ -624,19 +624,19 @@ public sealed class AzureAIProjectChatClientExtensionsTests functionDescription: "Gets the user's name, as used for friendly address." ); - var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" }; + var definition = new DeclarativeAgentDefinition("test-model") { Instructions = "Test" }; definition.Tools.Add(functionTool); // Generate response with the declarative function - var definitionResponse = new PromptAgentDefinition("test-model") { Instructions = "Test" }; + var definitionResponse = new DeclarativeAgentDefinition("test-model") { Instructions = "Test" }; definitionResponse.Tools.Add(functionTool); using var testClient = CreateTestAgentClientWithHandler(agentName: "test-agent", agentDefinitionResponse: definitionResponse); - var options = new AgentVersionCreationOptions(definition); + var options = new ProjectsAgentVersionCreationOptions(definition); // Act - var agentVersion = (await testClient.Client.Agents.CreateAgentVersionAsync("test-agent", options)).Value; + var agentVersion = (await testClient.Client.AgentAdministrationClient.CreateAgentVersionAsync("test-agent", options)).Value; var agent = testClient.Client.AsAIAgent(agentVersion); // Assert @@ -652,7 +652,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange using var testClient = CreateTestAgentClientWithHandler(); - var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" }; + var definition = new DeclarativeAgentDefinition("test-model") { Instructions = "Test" }; // Create a declarative function (not invocable) using AIFunctionFactory.CreateDeclaration using var doc = JsonDocument.Parse("{}"); @@ -661,10 +661,10 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Add to definition definition.Tools.Add(declarativeFunction.AsOpenAIResponseTool() ?? throw new InvalidOperationException()); - var options = new AgentVersionCreationOptions(definition); + var options = new ProjectsAgentVersionCreationOptions(definition); // Act - var agentVersion = (await testClient.Client.Agents.CreateAgentVersionAsync("test-agent", options)).Value; + var agentVersion = (await testClient.Client.AgentAdministrationClient.CreateAgentVersionAsync("test-agent", options)).Value; var agent = testClient.Client.AsAIAgent(agentVersion); // Assert @@ -679,7 +679,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests public async Task AsAIAgent_WithDeclarativeFunctionInDefinition_AcceptsDeclarativeFunctionAsync() { // Arrange - var definition = new PromptAgentDefinition("test-model") { Instructions = "Test" }; + var definition = new DeclarativeAgentDefinition("test-model") { Instructions = "Test" }; // Create a declarative function (not invocable) using AIFunctionFactory.CreateDeclaration using var doc = JsonDocument.Parse("{}"); @@ -689,15 +689,15 @@ public sealed class AzureAIProjectChatClientExtensionsTests definition.Tools.Add(declarativeFunction.AsOpenAIResponseTool() ?? throw new InvalidOperationException()); // Generate response with the declarative function - var definitionResponse = new PromptAgentDefinition("test-model") { Instructions = "Test" }; + var definitionResponse = new DeclarativeAgentDefinition("test-model") { Instructions = "Test" }; definitionResponse.Tools.Add(declarativeFunction.AsOpenAIResponseTool() ?? throw new InvalidOperationException()); using var testClient = CreateTestAgentClientWithHandler(agentName: "test-agent", agentDefinitionResponse: definitionResponse); - var options = new AgentVersionCreationOptions(definition); + var options = new ProjectsAgentVersionCreationOptions(definition); // Act - var agentVersion = (await testClient.Client.Agents.CreateAgentVersionAsync("test-agent", options)).Value; + var agentVersion = (await testClient.Client.AgentAdministrationClient.CreateAgentVersionAsync("test-agent", options)).Value; var agent = testClient.Client.AsAIAgent(agentVersion); // Assert @@ -758,7 +758,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); int factoryCallCount = 0; // Act @@ -785,7 +785,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act var agent1 = client.AsAIAgent( @@ -904,7 +904,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Arrange var aiProjectClient = new AIProjectClient(new Uri("https://test.openai.azure.com/"), new FakeAuthenticationTokenProvider(), new() { Transport = new HttpClientPipelineTransport(httpClient) }); - var agentVersion = (await aiProjectClient.Agents.CreateAgentVersionAsync("test-agent", new AgentVersionCreationOptions(new PromptAgentDefinition("test-model") { Instructions = "Test instructions" }))).Value; + var agentVersion = (await aiProjectClient.AgentAdministrationClient.CreateAgentVersionAsync("test-agent", new ProjectsAgentVersionCreationOptions(new DeclarativeAgentDefinition("test-model") { Instructions = "Test instructions" }))).Value; // Act var agent = aiProjectClient.AsAIAgent(agentVersion); @@ -1043,21 +1043,21 @@ public sealed class AzureAIProjectChatClientExtensionsTests #endregion - #region GetService Tests + #region GetService Tests /// - /// Verify that GetService returns AgentRecord for agents created from AgentRecord. + /// Verify that GetService returns ProjectsAgentRecord for agents created from ProjectsAgentRecord. /// [Fact] public void GetService_WithAgentRecord_ReturnsAgentRecord() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act var agent = client.AsAIAgent(agentRecord); - var retrievedRecord = agent.GetService(); + var retrievedRecord = agent.GetService(); // Assert Assert.NotNull(retrievedRecord); @@ -1065,7 +1065,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that GetService returns null for AgentRecord when agent is created from AgentReference. + /// Verify that GetService returns null for ProjectsAgentRecord when agent is created from AgentReference. /// [Fact] public void GetService_WithAgentReference_ReturnsNullForAgentRecord() @@ -1076,7 +1076,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Act var agent = client.AsAIAgent(agentReference); - var retrievedRecord = agent.GetService(); + var retrievedRecord = agent.GetService(); // Assert Assert.Null(retrievedRecord); @@ -1084,21 +1084,21 @@ public sealed class AzureAIProjectChatClientExtensionsTests #endregion - #region GetService Tests + #region GetService Tests /// - /// Verify that GetService returns AgentVersion for agents created from AgentVersion. + /// Verify that GetService returns ProjectsAgentVersion for agents created from ProjectsAgentVersion. /// [Fact] public void GetService_WithAgentVersion_ReturnsAgentVersion() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); // Act var agent = client.AsAIAgent(agentVersion); - var retrievedVersion = agent.GetService(); + var retrievedVersion = agent.GetService(); // Assert Assert.NotNull(retrievedVersion); @@ -1106,7 +1106,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that GetService returns null for AgentVersion when agent is created from AgentReference. + /// Verify that GetService returns null for ProjectsAgentVersion when agent is created from AgentReference. /// [Fact] public void GetService_WithAgentReference_ReturnsNullForAgentVersion() @@ -1117,7 +1117,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Act var agent = client.AsAIAgent(agentReference); - var retrievedVersion = agent.GetService(); + var retrievedVersion = agent.GetService(); // Assert Assert.Null(retrievedVersion); @@ -1128,14 +1128,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests #region ChatClientMetadata Tests /// - /// Verify that ChatClientMetadata is properly populated for agents created from AgentRecord. + /// Verify that ChatClientMetadata is properly populated for agents created from ProjectsAgentRecord. /// [Fact] public void ChatClientMetadata_WithAgentRecord_IsPopulatedCorrectly() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act var agent = client.AsAIAgent(agentRecord); @@ -1147,18 +1147,18 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that ChatClientMetadata.DefaultModelId is set from PromptAgentDefinition model property. + /// Verify that ChatClientMetadata.DefaultModelId is set from DeclarativeAgentDefinition model property. /// [Fact] - public void ChatClientMetadata_WithPromptAgentDefinition_SetsDefaultModelIdFromModel() + public void ChatClientMetadata_WithDeclarativeAgentDefinition_SetsDefaultModelIdFromModel() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - var definition = new PromptAgentDefinition("gpt-4-turbo") + var definition = new DeclarativeAgentDefinition("gpt-4-turbo") { Instructions = "Test instructions" }; - AgentRecord agentRecord = this.CreateTestAgentRecord(definition); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(definition); // Act var agent = client.AsAIAgent(agentRecord); @@ -1172,14 +1172,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that ChatClientMetadata is properly populated for agents created from AgentVersion. + /// Verify that ChatClientMetadata is properly populated for agents created from ProjectsAgentVersion. /// [Fact] public void ChatClientMetadata_WithAgentVersion_IsPopulatedCorrectly() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); // Act var agent = client.AsAIAgent(agentVersion); @@ -1188,7 +1188,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests // Assert Assert.NotNull(metadata); Assert.NotNull(metadata.DefaultModelId); - Assert.Equal((agentVersion.Definition as PromptAgentDefinition)!.Model, metadata.DefaultModelId); + Assert.Equal((agentVersion.Definition as DeclarativeAgentDefinition)!.Model, metadata.DefaultModelId); } #endregion @@ -1216,14 +1216,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that GetService returns null for AgentReference when agent is created from AgentRecord. + /// Verify that GetService returns null for AgentReference when agent is created from ProjectsAgentRecord. /// [Fact] public void GetService_WithAgentRecord_ReturnsAlsoAgentReference() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentRecord agentRecord = this.CreateTestAgentRecord(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecord(); // Act var agent = client.AsAIAgent(agentRecord); @@ -1235,14 +1235,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that GetService returns null for AgentReference when agent is created from AgentVersion. + /// Verify that GetService returns null for AgentReference when agent is created from ProjectsAgentVersion. /// [Fact] public void GetService_WithAgentVersion_ReturnsAlsoAgentReference() { // Arrange AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = this.CreateTestAgentVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersion(); // Act var agent = client.AsAIAgent(agentVersion); @@ -1278,14 +1278,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests #region Empty Version and ID Handling Tests /// - /// Verify that AsAIAgent with AgentRecord handles empty version by using "latest" as fallback. + /// Verify that AsAIAgent with ProjectsAgentRecord handles empty version by using "latest" as fallback. /// [Fact] public void AsAIAgent_WithAgentRecordEmptyVersion_CreatesAgentWithGeneratedId() { // Arrange AIProjectClient client = this.CreateTestAgentClientWithEmptyVersion(); - AgentRecord agentRecord = this.CreateTestAgentRecordWithEmptyVersion(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecordWithEmptyVersion(); // Act var agent = client.AsAIAgent(agentRecord); @@ -1297,14 +1297,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that AsAIAgent with AgentVersion handles empty version by using "latest" as fallback. + /// Verify that AsAIAgent with ProjectsAgentVersion handles empty version by using "latest" as fallback. /// [Fact] public void AsAIAgent_WithAgentVersionEmptyVersion_CreatesAgentWithGeneratedId() { // Arrange AIProjectClient client = this.CreateTestAgentClientWithEmptyVersion(); - AgentVersion agentVersion = this.CreateTestAgentVersionWithEmptyVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersionWithEmptyVersion(); // Act var agent = client.AsAIAgent(agentVersion); @@ -1316,14 +1316,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that AsAIAgent with AgentRecord handles whitespace-only version by using "latest" as fallback. + /// Verify that AsAIAgent with ProjectsAgentRecord handles whitespace-only version by using "latest" as fallback. /// [Fact] public void AsAIAgent_WithAgentRecordWhitespaceVersion_CreatesAgentWithGeneratedId() { // Arrange AIProjectClient client = this.CreateTestAgentClientWithWhitespaceVersion(); - AgentRecord agentRecord = this.CreateTestAgentRecordWithWhitespaceVersion(); + ProjectsAgentRecord agentRecord = this.CreateTestAgentRecordWithWhitespaceVersion(); // Act var agent = client.AsAIAgent(agentRecord); @@ -1335,14 +1335,14 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Verify that AsAIAgent with AgentVersion handles whitespace-only version by using "latest" as fallback. + /// Verify that AsAIAgent with ProjectsAgentVersion handles whitespace-only version by using "latest" as fallback. /// [Fact] public void AsAIAgent_WithAgentVersionWhitespaceVersion_CreatesAgentWithGeneratedId() { // Arrange AIProjectClient client = this.CreateTestAgentClientWithWhitespaceVersion(); - AgentVersion agentVersion = this.CreateTestAgentVersionWithWhitespaceVersion(); + ProjectsAgentVersion agentVersion = this.CreateTestAgentVersionWithWhitespaceVersion(); // Act var agent = client.AsAIAgent(agentVersion); @@ -1364,11 +1364,11 @@ public sealed class AzureAIProjectChatClientExtensionsTests public void AsAIAgent_WithServerHostedTools_AddsToolsToAgentOptions() { // Arrange - PromptAgentDefinition definition = new("test-model") { Instructions = "Test" }; + DeclarativeAgentDefinition definition = new("test-model") { Instructions = "Test" }; definition.Tools.Add(new HostedWebSearchTool().GetService() ?? new HostedWebSearchTool().AsOpenAIResponseTool()); AIProjectClient client = this.CreateTestAgentClient(); - AgentVersion agentVersion = ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJson(agentDefinition: definition)))!; + ProjectsAgentVersion agentVersion = ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJson(agentDefinition: definition)))!; // Act - no tools provided, but requireInvocableTools is false when no tools param is passed FoundryAgent agent = client.AsAIAgent(agentVersion); @@ -1385,7 +1385,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests /// /// Creates a test AIProjectClient with fake behavior. /// - private FakeAgentClient CreateTestAgentClient(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null) + private FakeAgentClient CreateTestAgentClient(string? agentName = null, string? instructions = null, string? description = null, ProjectsAgentDefinition? agentDefinitionResponse = null) { return new FakeAgentClient(agentName, instructions, description, agentDefinitionResponse); } @@ -1395,7 +1395,7 @@ public sealed class AzureAIProjectChatClientExtensionsTests /// Used for tests that exercise the protocol-method code path (CreateAgentVersion). /// The returned client must be disposed to clean up the underlying HttpClient/handler. /// - private static DisposableTestClient CreateTestAgentClientWithHandler(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null) + private static DisposableTestClient CreateTestAgentClientWithHandler(string? agentName = null, string? instructions = null, string? description = null, ProjectsAgentDefinition? agentDefinitionResponse = null) { var responseJson = TestDataUtil.GetAgentVersionResponseJson(agentName, agentDefinitionResponse, instructions, description); @@ -1439,59 +1439,59 @@ public sealed class AzureAIProjectChatClientExtensionsTests } /// - /// Creates a test AgentRecord for testing. + /// Creates a test ProjectsAgentRecord for testing. /// - private AgentRecord CreateTestAgentRecord(AgentDefinition? agentDefinition = null) + private ProjectsAgentRecord CreateTestAgentRecord(ProjectsAgentDefinition? agentDefinition = null) { - return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentResponseJson(agentDefinition: agentDefinition)))!; + return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentResponseJson(agentDefinition: agentDefinition)))!; } /// /// Creates a test AIProjectClient with empty version fields for testing hosted MCP agents. /// - private FakeAgentClient CreateTestAgentClientWithEmptyVersion(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null) + private FakeAgentClient CreateTestAgentClientWithEmptyVersion(string? agentName = null, string? instructions = null, string? description = null, ProjectsAgentDefinition? agentDefinitionResponse = null) { return new FakeAgentClient(agentName, instructions, description, agentDefinitionResponse, useEmptyVersion: true); } /// - /// Creates a test AgentRecord with empty version for testing hosted MCP agents. + /// Creates a test ProjectsAgentRecord with empty version for testing hosted MCP agents. /// - private AgentRecord CreateTestAgentRecordWithEmptyVersion(AgentDefinition? agentDefinition = null) + private ProjectsAgentRecord CreateTestAgentRecordWithEmptyVersion(ProjectsAgentDefinition? agentDefinition = null) { - return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentResponseJsonWithEmptyVersion(agentDefinition: agentDefinition)))!; + return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentResponseJsonWithEmptyVersion(agentDefinition: agentDefinition)))!; } /// - /// Creates a test AgentVersion with empty version for testing hosted MCP agents. + /// Creates a test ProjectsAgentVersion with empty version for testing hosted MCP agents. /// - private AgentVersion CreateTestAgentVersionWithEmptyVersion() + private ProjectsAgentVersion CreateTestAgentVersionWithEmptyVersion() { - return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJsonWithEmptyVersion()))!; + return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJsonWithEmptyVersion()))!; } /// /// Creates a test AIProjectClient with whitespace-only version fields for testing hosted MCP agents. /// - private FakeAgentClient CreateTestAgentClientWithWhitespaceVersion(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null) + private FakeAgentClient CreateTestAgentClientWithWhitespaceVersion(string? agentName = null, string? instructions = null, string? description = null, ProjectsAgentDefinition? agentDefinitionResponse = null) { return new FakeAgentClient(agentName, instructions, description, agentDefinitionResponse, versionMode: VersionMode.Whitespace); } /// - /// Creates a test AgentRecord with whitespace-only version for testing hosted MCP agents. + /// Creates a test ProjectsAgentRecord with whitespace-only version for testing hosted MCP agents. /// - private AgentRecord CreateTestAgentRecordWithWhitespaceVersion(AgentDefinition? agentDefinition = null) + private ProjectsAgentRecord CreateTestAgentRecordWithWhitespaceVersion(ProjectsAgentDefinition? agentDefinition = null) { - return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentResponseJsonWithWhitespaceVersion(agentDefinition: agentDefinition)))!; + return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentResponseJsonWithWhitespaceVersion(agentDefinition: agentDefinition)))!; } /// - /// Creates a test AgentVersion with whitespace-only version for testing hosted MCP agents. + /// Creates a test ProjectsAgentVersion with whitespace-only version for testing hosted MCP agents. /// - private AgentVersion CreateTestAgentVersionWithWhitespaceVersion() + private ProjectsAgentVersion CreateTestAgentVersionWithWhitespaceVersion() { - return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJsonWithWhitespaceVersion()))!; + return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJsonWithWhitespaceVersion()))!; } private const string OpenAPISpec = """ @@ -1525,11 +1525,11 @@ public sealed class AzureAIProjectChatClientExtensionsTests """; /// - /// Creates a test AgentVersion for testing. + /// Creates a test ProjectsAgentVersion for testing. /// - private AgentVersion CreateTestAgentVersion() + private ProjectsAgentVersion CreateTestAgentVersion() { - return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJson()))!; + return ModelReaderWriter.Read(BinaryData.FromString(TestDataUtil.GetAgentVersionResponseJson()))!; } /// @@ -1547,11 +1547,11 @@ public sealed class AzureAIProjectChatClientExtensionsTests /// private sealed class FakeAgentClient : AIProjectClient { - public FakeAgentClient(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null, bool useEmptyVersion = false, VersionMode versionMode = VersionMode.Normal) + public FakeAgentClient(string? agentName = null, string? instructions = null, string? description = null, ProjectsAgentDefinition? agentDefinitionResponse = null, bool useEmptyVersion = false, VersionMode versionMode = VersionMode.Normal) { // Handle backward compatibility with bool parameter var effectiveVersionMode = useEmptyVersion ? VersionMode.Empty : versionMode; - this.Agents = new FakeAgentsClient(agentName, instructions, description, agentDefinitionResponse, effectiveVersionMode); + this.AgentAdministrationClient = new FakeAgentsClient(agentName, instructions, description, agentDefinitionResponse, effectiveVersionMode); } public override ClientConnection GetConnection(string connectionId) @@ -1559,17 +1559,17 @@ public sealed class AzureAIProjectChatClientExtensionsTests return new ClientConnection("fake-connection-id", "http://localhost", ClientPipeline.Create(), CredentialKind.None); } - public override AgentsClient Agents { get; } + public override AgentAdministrationClient AgentAdministrationClient { get; } - private sealed class FakeAgentsClient : AgentsClient + private sealed class FakeAgentsClient : AgentAdministrationClient { private readonly string? _agentName; private readonly string? _instructions; private readonly string? _description; - private readonly AgentDefinition? _agentDefinition; + private readonly ProjectsAgentDefinition? _agentDefinition; private readonly VersionMode _versionMode; - public FakeAgentsClient(string? agentName = null, string? instructions = null, string? description = null, AgentDefinition? agentDefinitionResponse = null, VersionMode versionMode = VersionMode.Normal) + public FakeAgentsClient(string? agentName = null, string? instructions = null, string? description = null, ProjectsAgentDefinition? agentDefinitionResponse = null, VersionMode versionMode = VersionMode.Normal) { this._agentName = agentName; this._instructions = instructions; @@ -1601,44 +1601,44 @@ public sealed class AzureAIProjectChatClientExtensionsTests public override ClientResult GetAgent(string agentName, RequestOptions options) { var responseJson = this.GetAgentResponseJson(); - return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson))); + return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson))); } - public override ClientResult GetAgent(string agentName, CancellationToken cancellationToken = default) + public override ClientResult GetAgent(string agentName, CancellationToken cancellationToken = default) { var responseJson = this.GetAgentResponseJson(); - return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)); + return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)); } public override Task GetAgentAsync(string agentName, RequestOptions options) { var responseJson = this.GetAgentResponseJson(); - return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200, BinaryData.FromString(responseJson)))); + 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) + public override Task> GetAgentAsync(string agentName, CancellationToken cancellationToken = default) { var responseJson = this.GetAgentResponseJson(); - return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200))); + return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200))); } - public override ClientResult CreateAgentVersion(string agentName, AgentVersionCreationOptions? options = null, string? foundryFeatures = null, CancellationToken cancellationToken = default) + public override ClientResult CreateAgentVersion(string agentName, ProjectsAgentVersionCreationOptions? options = null, string? foundryFeatures = null, CancellationToken cancellationToken = default) { var responseJson = this.GetAgentVersionResponseJson(); - return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)); + return ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200)); } - public override Task> CreateAgentVersionAsync(string agentName, AgentVersionCreationOptions? options = null, string? foundryFeatures = null, CancellationToken cancellationToken = default) + public override Task> CreateAgentVersionAsync(string agentName, ProjectsAgentVersionCreationOptions? options = null, string? foundryFeatures = null, CancellationToken cancellationToken = default) { var responseJson = this.GetAgentVersionResponseJson(); - return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200))); + return Task.FromResult(ClientResult.FromValue(ModelReaderWriter.Read(BinaryData.FromString(responseJson))!, new MockPipelineResponse(200))); } } } - private static PromptAgentDefinition GeneratePromptDefinitionResponse(PromptAgentDefinition inputDefinition, List? tools) + private static DeclarativeAgentDefinition GeneratePromptDefinitionResponse(DeclarativeAgentDefinition inputDefinition, List? tools) { - var definitionResponse = new PromptAgentDefinition(inputDefinition.Model) { Instructions = inputDefinition.Instructions }; + var definitionResponse = new DeclarativeAgentDefinition(inputDefinition.Model) { Instructions = inputDefinition.Instructions }; if (tools is not null) { foreach (var tool in tools) diff --git a/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/TestDataUtil.cs b/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/TestDataUtil.cs index 0a541f5562..3460362efd 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/TestDataUtil.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Foundry.UnitTests/TestDataUtil.cs @@ -29,7 +29,7 @@ internal static class TestDataUtil /// /// Gets the agent response JSON with optional placeholder replacements applied. /// - public static string GetAgentResponseJson(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetAgentResponseJson(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_agentResponseJson; json = ApplyAgentName(json, agentName); @@ -42,7 +42,7 @@ internal static class TestDataUtil /// /// Gets the agent version response JSON with optional placeholder replacements applied. /// - public static string GetAgentVersionResponseJson(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetAgentVersionResponseJson(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_agentVersionResponseJson; json = ApplyAgentName(json, agentName); @@ -55,7 +55,7 @@ internal static class TestDataUtil /// /// Gets the agent version response JSON with empty version and ID fields for testing hosted agents like MCP agents. /// - public static string GetAgentVersionResponseJsonWithEmptyVersion(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetAgentVersionResponseJsonWithEmptyVersion(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_agentVersionResponseJson; json = ApplyAgentName(json, agentName); @@ -71,7 +71,7 @@ internal static class TestDataUtil /// /// Gets the agent response JSON with empty version and ID fields in the latest version for testing hosted agents like MCP agents. /// - public static string GetAgentResponseJsonWithEmptyVersion(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetAgentResponseJsonWithEmptyVersion(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_agentResponseJson; json = ApplyAgentName(json, agentName); @@ -87,7 +87,7 @@ internal static class TestDataUtil /// /// Gets the agent version response JSON with whitespace-only version and ID fields for testing hosted agents like MCP agents. /// - public static string GetAgentVersionResponseJsonWithWhitespaceVersion(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetAgentVersionResponseJsonWithWhitespaceVersion(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_agentVersionResponseJson; json = ApplyAgentName(json, agentName); @@ -103,7 +103,7 @@ internal static class TestDataUtil /// /// Gets the agent response JSON with whitespace-only version and ID fields in the latest version for testing hosted agents like MCP agents. /// - public static string GetAgentResponseJsonWithWhitespaceVersion(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetAgentResponseJsonWithWhitespaceVersion(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_agentResponseJson; json = ApplyAgentName(json, agentName); @@ -119,7 +119,7 @@ internal static class TestDataUtil /// /// Gets the OpenAI default response JSON with optional placeholder replacements applied. /// - public static string GetOpenAIDefaultResponseJson(string? agentName = null, AgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) + public static string GetOpenAIDefaultResponseJson(string? agentName = null, ProjectsAgentDefinition? agentDefinition = null, string? instructions = null, string? description = null) { var json = s_openAIDefaultResponseJson; json = ApplyAgentName(json, agentName); @@ -138,7 +138,7 @@ internal static class TestDataUtil return json; } - private static string ApplyAgentDefinition(string json, AgentDefinition? definition) + private static string ApplyAgentDefinition(string json, ProjectsAgentDefinition? definition) { return (definition is not null) ? json.Replace(AgentDefinitionPlaceholder, ModelReaderWriter.Write(definition).ToString()) 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 58e6b96d10..6fa684891f 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 @@ -35,13 +35,13 @@ internal abstract class AgentProvider(IConfiguration configuration) { Uri foundryEndpoint = new(this.GetSetting(TestSettings.AzureAIProjectEndpoint)); - await foreach (AgentVersion agent in this.CreateAgentsAsync(foundryEndpoint)) + await foreach (ProjectsAgentVersion agent in this.CreateAgentsAsync(foundryEndpoint)) { Console.WriteLine($"Created agent: {agent.Name}:{agent.Version}"); } } - protected abstract IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint); + protected abstract IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint); protected string GetSetting(string settingName) => configuration[settingName] ?? 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 05ad68fa3d..b6f4d7146a 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 @@ -14,7 +14,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents; internal sealed class FunctionToolAgentProvider(IConfiguration configuration) : AgentProvider(configuration) { - protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) + protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) { MenuPlugin menuPlugin = new(); AIFunction[] functions = @@ -33,9 +33,9 @@ internal sealed class FunctionToolAgentProvider(IConfiguration configuration) : agentDescription: "Provides information about the restaurant menu"); } - private PromptAgentDefinition DefineMenuAgent(AIFunction[] functions) + private DeclarativeAgentDefinition DefineMenuAgent(AIFunction[] functions) { - PromptAgentDefinition agentDefinition = + DeclarativeAgentDefinition agentDefinition = new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = 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 b25e921abe..8be61587e9 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 @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents; internal sealed class MarketingAgentProvider(IConfiguration configuration) : AgentProvider(configuration) { - protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) + protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) { AIProjectClient aiProjectClient = new(foundryEndpoint, TestAzureCliCredentials.CreateAzureCliCredential()); @@ -35,7 +35,7 @@ internal sealed class MarketingAgentProvider(IConfiguration configuration) : Age agentDescription: "Editor agent for Marketing workflow"); } - private PromptAgentDefinition DefineAnalystAgent() => + private DeclarativeAgentDefinition DefineAnalystAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = @@ -47,13 +47,13 @@ internal sealed class MarketingAgentProvider(IConfiguration configuration) : Age """, Tools = { - //AgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available + //ProjectsAgentTool.CreateBingGroundingTool( // TODO: Use Bing Grounding when available // new BingGroundingSearchToolParameters( // [new BingGroundingSearchConfiguration(this.GetSetting(Settings.FoundryGroundingTool))])) } }; - private PromptAgentDefinition DefineWriterAgent() => + private DeclarativeAgentDefinition DefineWriterAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = @@ -64,7 +64,7 @@ internal sealed class MarketingAgentProvider(IConfiguration configuration) : Age """ }; - private PromptAgentDefinition DefineEditorAgent() => + private DeclarativeAgentDefinition DefineEditorAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = 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 c65cc3ce57..8444734793 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 @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents; internal sealed class MathChatAgentProvider(IConfiguration configuration) : AgentProvider(configuration) { - protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) + protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) { AIProjectClient aiProjectClient = new(foundryEndpoint, TestAzureCliCredentials.CreateAzureCliCredential()); @@ -29,7 +29,7 @@ internal sealed class MathChatAgentProvider(IConfiguration configuration) : Agen agentDescription: "Teacher agent for MathChat workflow"); } - private PromptAgentDefinition DefineStudentAgent() => + private DeclarativeAgentDefinition DefineStudentAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = @@ -41,7 +41,7 @@ internal sealed class MathChatAgentProvider(IConfiguration configuration) : Agen """ }; - private PromptAgentDefinition DefineTeacherAgent() => + private DeclarativeAgentDefinition DefineTeacherAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = 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 6e3912a276..3c537f7c91 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 @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents; internal sealed class PoemAgentProvider(IConfiguration configuration) : AgentProvider(configuration) { - protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) + protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) { AIProjectClient aiProjectClient = new(foundryEndpoint, TestAzureCliCredentials.CreateAzureCliCredential()); @@ -23,7 +23,7 @@ internal sealed class PoemAgentProvider(IConfiguration configuration) : AgentPro agentDescription: "Authors original poems"); } - private PromptAgentDefinition DefinePoemAgent() => + private DeclarativeAgentDefinition DefinePoemAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions = 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 e1278e6fb7..2fc3ad5665 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 @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents; internal sealed class TestAgentProvider(IConfiguration configuration) : AgentProvider(configuration) { - protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) + protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) { AIProjectClient aiProjectClient = new(foundryEndpoint, TestAzureCliCredentials.CreateAzureCliCredential()); @@ -23,6 +23,6 @@ internal sealed class TestAgentProvider(IConfiguration configuration) : AgentPro agentDescription: "Basic agent"); } - private PromptAgentDefinition DefineMenuAgent() => + private DeclarativeAgentDefinition DefineMenuAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)); } diff --git a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/VisionAgentProvider.cs b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/VisionAgentProvider.cs index 027a67e254..8c3b35757e 100644 --- a/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/VisionAgentProvider.cs +++ b/dotnet/tests/Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests/Agents/VisionAgentProvider.cs @@ -12,7 +12,7 @@ namespace Microsoft.Agents.AI.Workflows.Declarative.IntegrationTests.Agents; internal sealed class VisionAgentProvider(IConfiguration configuration) : AgentProvider(configuration) { - protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) + protected override async IAsyncEnumerable CreateAgentsAsync(Uri foundryEndpoint) { AIProjectClient aiProjectClient = new(foundryEndpoint, TestAzureCliCredentials.CreateAzureCliCredential()); @@ -23,7 +23,7 @@ internal sealed class VisionAgentProvider(IConfiguration configuration) : AgentP agentDescription: "Use computer vision to describe an image or document."); } - private PromptAgentDefinition DefineVisionAgent() => + private DeclarativeAgentDefinition DefineVisionAgent() => new(this.GetSetting(TestSettings.AzureAIModelDeploymentName)) { Instructions =