Skip to content

Commit 0723f1d

Browse files
rogerbarretoCopilotwestey-m
authored
.NET: Foundry V2 - Update Sample and Docs for clear distinction between Classic/New Foundry Agents. (#2459)
* Address potential confusion around agent version vs API version * Address potential confusion around agent version vs API version * Add extra documentation for clarity * Remove V2 remainers * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> Co-authored-by: westey <[email protected]> * Apply suggestions from code review Co-authored-by: Copilot <[email protected]> --------- Co-authored-by: Copilot <[email protected]> Co-authored-by: westey <[email protected]>
1 parent a57b37d commit 0723f1d

File tree

5 files changed

+48
-22
lines changed

5 files changed

+48
-22
lines changed

dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIAgentsPersistent/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# Classic Foundry Agents
2+
3+
This sample demonstrates how to create an agent using the classic Foundry Agents experience.
4+
5+
# Classic vs New Foundry Agents
6+
7+
Below is a comparison between the classic and new Foundry Agents approaches:
8+
9+
[Migration Guide](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/how-to/migrate?view=foundry)
10+
111
# Prerequisites
212

313
Before you begin, ensure you have the following prerequisites:

dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/Program.cs

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,35 +10,34 @@
1010
var endpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.");
1111
var deploymentName = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
1212

13-
const string JokerInstructions = "You are good at telling jokes.";
1413
const string JokerName = "JokerAgent";
1514

1615
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
1716
var aiProjectClient = new AIProjectClient(new Uri(endpoint), new AzureCliCredential());
1817

1918
// Define the agent you want to create. (Prompt Agent in this case)
20-
var agentVersionCreationOptions = new AgentVersionCreationOptions(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions });
19+
var agentVersionCreationOptions = new AgentVersionCreationOptions(new PromptAgentDefinition(model: deploymentName) { Instructions = "You are good at telling jokes." });
2120
// Azure.AI.Agents SDK creates and manages agent by name and versions.
2221
// You can create a server side agent version with the Azure.AI.Agents SDK client below.
23-
var agentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options: agentVersionCreationOptions);
22+
var createdAgentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options: agentVersionCreationOptions);
2423

2524
// Note:
2625
// agentVersion.Id = "<agentName>:<versionNumber>",
2726
// agentVersion.Version = <versionNumber>,
2827
// agentVersion.Name = <agentName>
2928

30-
// You can retrieve an AIAgent for a already created server side agent version.
31-
AIAgent jokerAgentV1 = aiProjectClient.GetAIAgent(agentVersion);
29+
// You can retrieve an AIAgent for an already created server side agent version.
30+
AIAgent existingJokerAgent = aiProjectClient.GetAIAgent(createdAgentVersion);
3231

33-
// You can also create another AIAgent version (V2) by providing the same name with a different definition.
34-
AIAgent jokerAgentV2 = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions + "V2");
32+
// You can also create another AIAgent version by providing the same name with a different definition.
33+
AIAgent newJokerAgent = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: "You are extremely hilarious at telling jokes.");
3534

3635
// You can also get the AIAgent latest version just providing its name.
3736
AIAgent jokerAgentLatest = aiProjectClient.GetAIAgent(name: JokerName);
38-
var latestVersion = jokerAgentLatest.GetService<AgentVersion>()!;
37+
var latestAgentVersion = jokerAgentLatest.GetService<AgentVersion>()!;
3938

4039
// The AIAgent version can be accessed via the GetService method.
41-
Console.WriteLine($"Latest agent version id: {latestVersion.Id}");
40+
Console.WriteLine($"Latest agent version id: {latestAgentVersion.Id}");
4241

4342
// Once you have the AIAgent, you can invoke it like any other AIAgent.
4443
AgentThread thread = jokerAgentLatest.GetNewThread();
@@ -47,5 +46,5 @@
4746
// This will use the same thread to continue the conversation.
4847
Console.WriteLine(await jokerAgentLatest.RunAsync("Now tell me a joke about a cat and a dog using last joke as the anchor.", thread));
4948

50-
// Cleanup by agent name removes both agent versions created (jokerAgentV1 + jokerAgentV2).
51-
aiProjectClient.Agents.DeleteAgent(jokerAgentV1.Name);
49+
// Cleanup by agent name removes both agent versions created.
50+
aiProjectClient.Agents.DeleteAgent(existingJokerAgent.Name);

dotnet/samples/GettingStarted/AgentProviders/Agent_With_AzureAIProject/README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
# New Foundry Agents
2+
3+
This sample demonstrates how to create an agent using the new Foundry Agents experience.
4+
5+
# Classic vs New Foundry Agents
6+
7+
Below is a comparison between the classic and new Foundry Agents approaches:
8+
9+
[Migration Guide](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/how-to/migrate?view=foundry)
10+
111
# Prerequisites
212

313
Before you begin, ensure you have the following prerequisites:

dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/Program.cs

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,38 @@
1111
string endpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.");
1212
string deploymentName = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_DEPLOYMENT_NAME") ?? "gpt-4o-mini";
1313

14-
const string JokerInstructionsV1 = "You are good at telling jokes.";
15-
const string JokerInstructionsV2 = "You are extremely hilarious at telling jokes.";
1614
const string JokerName = "JokerAgent";
1715

1816
// Get a client to create/retrieve/delete server side agents with Azure Foundry Agents.
1917
AIProjectClient aiProjectClient = new(new Uri(endpoint), new AzureCliCredential());
2018

2119
// Define the agent you want to create. (Prompt Agent in this case)
22-
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructionsV1 });
20+
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = "You are good at telling jokes." });
2321

2422
// Azure.AI.Agents SDK creates and manages agent by name and versions.
2523
// You can create a server side agent version with the Azure.AI.Agents SDK client below.
26-
AgentVersion agentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options);
24+
AgentVersion createdAgentVersion = aiProjectClient.Agents.CreateAgentVersion(agentName: JokerName, options);
2725

2826
// Note:
2927
// agentVersion.Id = "<agentName>:<versionNumber>",
3028
// agentVersion.Version = <versionNumber>,
3129
// agentVersion.Name = <agentName>
3230

3331
// You can retrieve an AIAgent for an already created server side agent version.
34-
AIAgent jokerAgentV1 = aiProjectClient.GetAIAgent(agentVersion);
32+
AIAgent existingJokerAgent = aiProjectClient.GetAIAgent(createdAgentVersion);
3533

36-
// You can also create another AIAgent version (V2) by providing the same name with a different definition/instruction.
37-
AIAgent jokerAgentV2 = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructionsV2);
34+
// You can also create another AIAgent version by providing the same name with a different definition/instruction.
35+
AIAgent newJokerAgent = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: "You are extremely hilarious at telling jokes.");
3836

3937
// You can also get the AIAgent latest version by just providing its name.
4038
AIAgent jokerAgentLatest = aiProjectClient.GetAIAgent(name: JokerName);
41-
AgentVersion latestVersion = jokerAgentLatest.GetService<AgentVersion>()!;
39+
AgentVersion latestAgentVersion = jokerAgentLatest.GetService<AgentVersion>()!;
4240

4341
// The AIAgent version can be accessed via the GetService method.
44-
Console.WriteLine($"Latest agent version id: {latestVersion.Id}");
42+
Console.WriteLine($"Latest agent version id: {latestAgentVersion.Id}");
4543

4644
// Once you have the AIAgent, you can invoke it like any other AIAgent.
4745
Console.WriteLine(await jokerAgentLatest.RunAsync("Tell me a joke about a pirate."));
4846

49-
// Cleanup by agent name removes both agent versions created (jokerAgentV1 + jokerAgentV2).
50-
await aiProjectClient.Agents.DeleteAgentAsync(jokerAgentV1.Name);
47+
// Cleanup by agent name removes both agent versions created.
48+
await aiProjectClient.Agents.DeleteAgentAsync(existingJokerAgent.Name);

dotnet/samples/GettingStarted/FoundryAgents/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,15 @@ of Azure Foundry Agents and can be used with Azure Foundry as the AI provider.
66
These samples showcase how to work with agents managed through Azure Foundry, including agent creation,
77
versioning, multi-turn conversations, and advanced features like code interpretation and computer use.
88

9+
## Classic vs New Foundry Agents
10+
11+
> [!NOTE]
12+
> Recently, Azure Foundry introduced a new and improved experience for creating and managing AI agents, which is the target of these samples.
13+
14+
For more information about the previous classic agents and for what's new in Foundry Agents, see the [Foundry Agents migration documentation](https://learn.microsoft.com/en-us/azure/ai-foundry/agents/how-to/migrate?view=foundry).
15+
16+
For a sample demonstrating how to use classic Foundry Agents, see the following: [Agent with Azure AI Persistent](../AgentProviders/Agent_With_AzureAIAgentsPersistent/README.md).
17+
918
## Getting started with Foundry Agents prerequisites
1019

1120
Before you begin, ensure you have the following prerequisites:

0 commit comments

Comments
 (0)