Skip to content

Commit f6cd329

Browse files
authored
.NET: Post bugbash updates (#2279)
* Add missing README.md * Address bugbash comments * Address bugbash issues and suggestions
1 parent 1f0ffc1 commit f6cd329

File tree

18 files changed

+38
-501
lines changed

18 files changed

+38
-501
lines changed

dotnet/agent-framework-dotnet.slnx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,11 @@
103103
<Project Path="samples/GettingStarted/AgentWithRAG/AgentWithRAG_Step03_CustomRAGDataSource/AgentWithRAG_Step03_CustomRAGDataSource.csproj" />
104104
</Folder>
105105
<Folder Name="/Samples/GettingStarted/FoundryAgents/">
106+
<File Path="samples/GettingStarted/FoundryAgents/README.md" />
106107
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.1_Basics/FoundryAgents_Step01.1_Basics.csproj" />
107108
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/FoundryAgents_Step01.2_Running.csproj" />
108109
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step02_MultiturnConversation/FoundryAgents_Step02_MultiturnConversation.csproj" />
109-
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.1_UsingFunctionTools/FoundryAgents_Step03.1_UsingFunctionTools.csproj" />
110-
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI.csproj" />
110+
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step03_UsingFunctionTools/FoundryAgents_Step03_UsingFunctionTools.csproj" />
111111
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step04_UsingFunctionToolsWithApprovals/FoundryAgents_Step04_UsingFunctionToolsWithApprovals.csproj" />
112112
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step05_StructuredOutput/FoundryAgents_Step05_StructuredOutput.csproj" />
113113
<Project Path="samples/GettingStarted/FoundryAgents/FoundryAgents_Step06_PersistedConversations/FoundryAgents_Step06_PersistedConversations.csproj" />

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

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,15 @@
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 JokerInstructions = "You are good at telling jokes.";
14+
const string JokerInstructionsV1 = "You are good at telling jokes.";
15+
const string JokerInstructionsV2 = "You are extremely hilarious at telling jokes.";
1516
const string JokerName = "JokerAgent";
1617

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

2021
// Define the agent you want to create. (Prompt Agent in this case)
21-
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructions });
22+
AgentVersionCreationOptions options = new(new PromptAgentDefinition(model: deploymentName) { Instructions = JokerInstructionsV1 });
2223

2324
// Azure.AI.Agents SDK creates and manages agent by name and versions.
2425
// You can create a server side agent version with the Azure.AI.Agents SDK client below.
@@ -32,8 +33,8 @@
3233
// You can retrieve an AIAgent for an already created server side agent version.
3334
AIAgent jokerAgentV1 = aiProjectClient.GetAIAgent(agentVersion);
3435

35-
// You can also create another AIAgent version (V2) by providing the same name with a different definition.
36-
AIAgent jokerAgentV2 = aiProjectClient.CreateAIAgent(name: JokerName, model: deploymentName, instructions: JokerInstructions + "V2");
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);
3738

3839
// You can also get the AIAgent latest version by just providing its name.
3940
AIAgent jokerAgentLatest = aiProjectClient.GetAIAgent(name: JokerName);
@@ -43,11 +44,7 @@
4344
Console.WriteLine($"Latest agent version id: {latestVersion.Id}");
4445

4546
// Once you have the AIAgent, you can invoke it like any other AIAgent.
46-
AgentThread thread = jokerAgentLatest.GetNewThread();
47-
Console.WriteLine(await jokerAgentLatest.RunAsync("Tell me a joke about a pirate.", thread));
48-
49-
// This will use the same thread to continue the conversation.
50-
Console.WriteLine(await jokerAgentLatest.RunAsync("Now tell me a joke about a cat and a dog using last joke as the anchor.", thread));
47+
Console.WriteLine(await jokerAgentLatest.RunAsync("Tell me a joke about a pirate."));
5148

5249
// Cleanup by agent name removes both agent versions created (jokerAgentV1 + jokerAgentV2).
5350
await aiProjectClient.Agents.DeleteAgentAsync(jokerAgentV1.Name);

dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step01.2_Running/Program.cs

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,8 @@
2626
// You can retrieve an AIAgent for a already created server side agent version.
2727
AIAgent jokerAgent = aiProjectClient.GetAIAgent(agentVersion);
2828

29-
// Invoke the agent and output the text result.
30-
AgentThread thread = jokerAgent.GetNewThread();
31-
Console.WriteLine(await jokerAgent.RunAsync("Tell me a joke about a pirate.", thread));
32-
3329
// Invoke the agent with streaming support.
34-
thread = jokerAgent.GetNewThread();
35-
await foreach (AgentRunResponseUpdate update in jokerAgent.RunStreamingAsync("Tell me a joke about a pirate.", thread))
30+
await foreach (AgentRunResponseUpdate update in jokerAgent.RunStreamingAsync("Tell me a joke about a pirate."))
3631
{
3732
Console.WriteLine(update);
3833
}

dotnet/samples/GettingStarted/FoundryAgents/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI/FoundryAgents_Step03.2_UsingFunctionTools_FromOpenAPI.csproj

Lines changed: 0 additions & 27 deletions
This file was deleted.

0 commit comments

Comments
 (0)