.NET: Feature foundry agent/update breaking v2.0 to v1.2 (#2212)

* Migration WIP Checkpoint 1

* Build + UT + Workflow passing

* Address latest commits after break

* Revert rename in unrelated files

* Address PR comments

* Class renames
This commit is contained in:
Roger Barreto
2025-11-14 12:20:56 +00:00
committed by GitHub
parent 7c90690067
commit 0746d7751a
66 changed files with 652 additions and 669 deletions
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
@@ -60,34 +61,34 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration, TicketingPlugin plugin)
{
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "SelfServiceAgent",
agentDefinition: DefineSelfServiceAgent(configuration),
agentDescription: "Service agent for CustomerSupport workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "TicketingAgent",
agentDefinition: DefineTicketingAgent(configuration, plugin),
agentDescription: "Ticketing agent for CustomerSupport workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "TicketRoutingAgent",
agentDefinition: DefineTicketRoutingAgent(configuration, plugin),
agentDescription: "Routing agent for CustomerSupport workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "WindowsSupportAgent",
agentDefinition: DefineWindowsSupportAgent(configuration, plugin),
agentDescription: "Windows support agent for CustomerSupport workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "TicketResolutionAgent",
agentDefinition: DefineResolutionAgent(configuration, plugin),
agentDescription: "Resolution agent for CustomerSupport workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "TicketEscalationAgent",
agentDefinition: TicketEscalationAgent(configuration, plugin),
agentDescription: "Escalate agent for human support");
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
@@ -46,39 +47,39 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration)
{
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "ResearchAgent",
agentDefinition: DefineResearchAgent(configuration),
agentDescription: "Planner agent for DeepResearch workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "PlannerAgent",
agentDefinition: DefinePlannerAgent(configuration),
agentDescription: "Planner agent for DeepResearch workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "ManagerAgent",
agentDefinition: DefineManagerAgent(configuration),
agentDescription: "Manager agent for DeepResearch workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "SummaryAgent",
agentDefinition: DefineSummaryAgent(configuration),
agentDescription: "Summary agent for DeepResearch workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "KnowledgeAgent",
agentDefinition: DefineKnowledgeAgent(configuration),
agentDescription: "Research agent for DeepResearch workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "CoderAgent",
agentDefinition: DefineCoderAgent(configuration),
agentDescription: "Coder agent for DeepResearch workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "WeatherAgent",
agentDefinition: DefineWeatherAgent(configuration),
agentDescription: "Weather agent for DeepResearch workflow");
@@ -271,10 +272,10 @@ internal sealed class Program
Tools =
{
AgentTool.CreateOpenApiTool(
new OpenApiFunctionDefinition(
new OpenAPIFunctionDefinition(
"weather-forecast",
BinaryData.FromString(File.ReadAllText(Path.Combine(AppContext.BaseDirectory, "wttr.json"))),
new OpenApiAnonymousAuthDetails()))
new OpenAPIAnonymousAuthenticationDetails()))
}
};
}
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.Configuration;
@@ -55,9 +56,9 @@ internal sealed class Program
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration, AIFunction[] functions)
{
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "MenuAgent",
agentDefinition: DefineMenuAgent(configuration, functions),
agentDescription: "Provides information about the restaurant menu");
@@ -3,7 +3,8 @@
// Uncomment this to enable JSON checkpointing to the local file system.
//#define CHECKPOINT_JSON
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
@@ -34,23 +35,26 @@ internal sealed class Program
Uri foundryEndpoint = new(configuration.GetValue(Application.Settings.FoundryEndpoint));
// Create the agent service client
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
// Ensure sample agents exist in Foundry.
await CreateAgentsAsync(agentClient, configuration);
await CreateAgentsAsync(aiProjectClient, configuration);
// Ensure workflow agent exists in Foundry.
AgentVersion agentVersion = await CreateWorkflowAsync(agentClient, configuration);
AgentVersion agentVersion = await CreateWorkflowAsync(aiProjectClient, configuration);
string workflowInput = GetWorkflowInput(args);
AIAgent agent = agentClient.GetAIAgent(agentVersion);
AIAgent agent = aiProjectClient.GetAIAgent(agentVersion);
AgentThread thread = agent.GetNewThread();
AgentConversation conversation =
await agentClient.GetConversationClient()
.CreateConversationAsync().ConfigureAwait(false);
ProjectConversation conversation =
await aiProjectClient
.GetProjectOpenAIClient()
.GetProjectConversationsClient()
.CreateProjectConversationAsync()
.ConfigureAwait(false);
Console.WriteLine($"CONVERSATION: {conversation.Id}");
@@ -77,7 +81,7 @@ internal sealed class Program
}
}
private static async Task<AgentVersion> CreateWorkflowAsync(AgentClient agentClient, IConfiguration configuration)
private static async Task<AgentVersion> CreateWorkflowAsync(AIProjectClient agentClient, IConfiguration configuration)
{
string workflowYaml = File.ReadAllText("MathChat.yaml");
@@ -90,7 +94,7 @@ internal sealed class Program
agentDescription: "The student attempts to solve the input problem and the teacher provides guidance.");
}
private static async Task CreateAgentsAsync(AgentClient agentClient, IConfiguration configuration)
private static async Task CreateAgentsAsync(AIProjectClient agentClient, IConfiguration configuration)
{
await agentClient.CreateAgentAsync(
agentName: "StudentAgent",
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
@@ -46,19 +47,19 @@ internal sealed class Program
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration)
{
AgentClient agentsClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentsClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "LocationTriageAgent",
agentDefinition: DefineLocationTriageAgent(configuration),
agentDescription: "Chats with the user to solicit a location of interest.");
await agentsClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "LocationCaptureAgent",
agentDefinition: DefineLocationCaptureAgent(configuration),
agentDescription: "Evaluate the status of soliciting the location.");
await agentsClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "LocationAwareAgent",
agentDefinition: DefineLocationAwareAgent(configuration),
agentDescription: "Chats with the user with location awareness.");
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -45,19 +46,19 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration)
{
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "AnalystAgent",
agentDefinition: DefineAnalystAgent(configuration),
agentDescription: "Analyst agent for Marketing workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "WriterAgent",
agentDefinition: DefineWriterAgent(configuration),
agentDescription: "Writer agent for Marketing workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "EditorAgent",
agentDefinition: DefineEditorAgent(configuration),
agentDescription: "Editor agent for Marketing workflow");
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using Shared.Foundry;
@@ -45,14 +46,14 @@ internal sealed class Program
private static async Task CreateAgentsAsync(Uri foundryEndpoint, IConfiguration configuration)
{
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "StudentAgent",
agentDefinition: DefineStudentAgent(configuration),
agentDescription: "Student agent for MathChat workflow");
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "TeacherAgent",
agentDefinition: DefineTeacherAgent(configuration),
agentDescription: "Teacher agent for MathChat workflow");
@@ -1,6 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.
using Azure.AI.Agents;
using Azure.AI.Projects;
using Azure.AI.Projects.OpenAI;
using Azure.Identity;
using Microsoft.Extensions.Configuration;
using OpenAI.Responses;
@@ -46,9 +47,9 @@ internal sealed class Program
private static async Task CreateAgentAsync(Uri foundryEndpoint, IConfiguration configuration)
{
AgentClient agentClient = new(foundryEndpoint, new AzureCliCredential());
AIProjectClient aiProjectClient = new(foundryEndpoint, new AzureCliCredential());
await agentClient.CreateAgentAsync(
await aiProjectClient.CreateAgentAsync(
agentName: "DocumentSearchAgent",
agentDefinition: DefineSearchAgent(configuration),
agentDescription: "Searches documents on Microsoft Learn");