Skip to content
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 80 additions & 76 deletions .github/upgrades/prompts/SemanticKernelToAgentFramework.md

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions dotnet/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@
<PackageVersion Include="JsonSchema.Net" Version="7.3.4" />
<PackageVersion Include="JsonSchema.Net.Generation" Version="5.0.2" />
<PackageVersion Include="Markdig" Version="0.40.0" />
<PackageVersion Include="Microsoft.Agents.AI.Abstractions" Version="1.0.0-preview.251009.1" />
<PackageVersion Include="Microsoft.Agents.AI.OpenAI" Version="1.0.0-preview.251009.1" />
<PackageVersion Include="Microsoft.Agents.AI.AzureAI" Version="1.0.0-preview.251009.1" />
<PackageVersion Include="Microsoft.Agents.AI.Workflows" Version="1.0.0-preview.251009.1" />
<PackageVersion Include="Microsoft.Agents.AI.Abstractions" Version="1.0.0" />
<PackageVersion Include="Microsoft.Agents.AI.Foundry" Version="1.0.0" />
<PackageVersion Include="Microsoft.Agents.AI.OpenAI" Version="1.0.0" />
<PackageVersion Include="Microsoft.Agents.AI.Workflows" Version="1.0.0" />
<PackageVersion Include="Microsoft.Agents.CopilotStudio.Client" Version="1.1.107-beta" />
<PackageVersion Include="Microsoft.AspNetCore.Mvc.Testing" Version="8.0.13" />
<PackageVersion Include="Microsoft.AspNetCore.OpenApi" Version="8.0.14" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" />
<PackageReference Include="Microsoft.Agents.AI.AzureAI" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" />
<PackageReference Include="Microsoft.Agents.AI.Workflows" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,13 +79,13 @@ async Task AFConcurrentAgentWorkflow()
var spanishAgent = GetAFTranslationAgent("Spanish", client);
var concurrentAgentWorkflow = AgentWorkflowBuilder.BuildConcurrent([frenchAgent, spanishAgent]);

await using StreamingRun run = await InProcessExecution.StreamAsync(concurrentAgentWorkflow, "Hello, world!");
await using StreamingRun run = await InProcessExecution.RunStreamingAsync(concurrentAgentWorkflow, "Hello, world!");
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));

string? lastExecutorId = null;
await foreach (WorkflowEvent evt in run.WatchStreamAsync().ConfigureAwait(false))
{
if (evt is AgentRunUpdateEvent e)
if (evt is AgentResponseUpdateEvent e)
{
if (string.IsNullOrEmpty(e.Update.Text))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" />
<PackageReference Include="Microsoft.Agents.AI.AzureAI" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" />
<PackageReference Include="Microsoft.Agents.AI.Workflows" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,13 +82,13 @@ async Task AFSequentialAgentWorkflow()
var sequentialAgentWorkflow = AgentWorkflowBuilder.BuildSequential(
[frenchAgent, spanishAgent, englishAgent]);

await using StreamingRun run = await InProcessExecution.StreamAsync(sequentialAgentWorkflow, "Hello, world!");
await using StreamingRun run = await InProcessExecution.RunStreamingAsync(sequentialAgentWorkflow, "Hello, world!");
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));

string? lastExecutorId = null;
await foreach (WorkflowEvent evt in run.WatchStreamAsync().ConfigureAwait(false))
{
if (evt is AgentRunUpdateEvent e)
if (evt is AgentResponseUpdateEvent e)
{
if (string.IsNullOrEmpty(e.Update.Text))
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<OutputType>Exe</OutputType>
Expand All @@ -11,7 +11,7 @@

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" />
<PackageReference Include="Microsoft.Agents.AI.AzureAI" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" />
<PackageReference Include="Microsoft.Agents.AI.Workflows" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) Microsoft. All rights reserved.

#pragma warning disable MAAIW001 // Experimental: HandoffWorkflowBuilder

using System.ComponentModel;
using System.Text.Json;
using Azure.AI.OpenAI;
Expand Down Expand Up @@ -207,13 +209,13 @@ async Task AFHandoffAgentWorkflow()
Console.WriteLine($"User: {query}");
messages.Add(new(ChatRole.User, query));

await using var run = await InProcessExecution.StreamAsync(handoffAgentWorkflow, messages);
await using var run = await InProcessExecution.RunStreamingAsync(handoffAgentWorkflow, messages);
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));

string? lastExecutorId = null;
await foreach (WorkflowEvent evt in run.WatchStreamAsync().ConfigureAwait(false))
{
if (evt is AgentRunUpdateEvent e)
if (evt is AgentResponseUpdateEvent e)
{
if (string.IsNullOrEmpty(e.Update.Text) && e.Update.Contents.Count == 0)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" />
<PackageReference Include="Microsoft.Agents.AI.AzureAI" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" />
<PackageReference Include="Microsoft.Agents.AI.Foundry" />
<PackageReference Include="Azure.AI.OpenAI" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
// Copyright (c) Microsoft. All rights reserved.

using Azure.AI.Agents.Persistent;
using Azure.AI.OpenAI;
using Azure.AI.Projects;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents.AzureAI;
using OpenAI.Responses;

#pragma warning disable OPENAI001 // ResponsesClient is experimental
#pragma warning disable SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var azureEndpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.");
Expand Down Expand Up @@ -67,7 +71,7 @@ async Task SKAgent_As_AFAgentAsync()

#pragma warning restore SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var thread = agent.GetNewThread();
var thread = await agent.CreateSessionAsync();
var agentOptions = new ChatClientAgentRunOptions(new() { MaxOutputTokens = 1000 });

var result = await agent.RunAsync(userInput, thread, agentOptions);
Expand All @@ -80,9 +84,9 @@ async Task SKAgent_As_AFAgentAsync()
}

// Clean up
if (thread is ChatClientAgentThread chatThread)
if (thread is ChatClientAgentSession chatSession)
{
await azureAgentClient.Threads.DeleteThreadAsync(chatThread.ConversationId);
await azureAgentClient.Threads.DeleteThreadAsync(chatSession.ConversationId);
}
await azureAgentClient.Administration.DeleteAgentAsync(agent.Id);
}
Expand All @@ -91,29 +95,23 @@ async Task AFAgentAsync()
{
Console.WriteLine("\n=== AF Agent ===\n");

var azureAgentClient = new PersistentAgentsClient(azureEndpoint, new AzureCliCredential());
// AF 1.0: Use AIProjectClient.AsAIAgent() from Microsoft.Agents.AI.Foundry
var projectClient = new AIProjectClient(new Uri(azureEndpoint), new AzureCliCredential());

var agent = await azureAgentClient.CreateAIAgentAsync(
var agent = projectClient.AsAIAgent(
deploymentName,
name: "GenerateStory",
instructions: "You are good at telling jokes.");
instructions: "You are good at telling jokes.",
name: "GenerateStory");

var thread = agent.GetNewThread();
var session = await agent.CreateSessionAsync();
var agentOptions = new ChatClientAgentRunOptions(new() { MaxOutputTokens = 1000 });

var result = await agent.RunAsync(userInput, thread, agentOptions);
var result = await agent.RunAsync(userInput, session, agentOptions);
Console.WriteLine(result);

Console.WriteLine("---");
await foreach (var update in agent.RunStreamingAsync(userInput, thread, agentOptions))
await foreach (var update in agent.RunStreamingAsync(userInput, session, agentOptions))
{
Console.Write(update);
}

// Clean up
if (thread is ChatClientAgentThread chatThread)
{
await azureAgentClient.Threads.DeleteThreadAsync(chatThread.ConversationId);
}
await azureAgentClient.Administration.DeleteAgentAsync(agent.Id);
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" />
<PackageReference Include="Microsoft.Agents.AI.AzureAI" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" />
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we using this? From the sample I would have thought we are only using foundry?

<PackageReference Include="Microsoft.Agents.AI.Foundry" />
<PackageReference Include="Azure.AI.OpenAI" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// Copyright (c) Microsoft. All rights reserved.

using System.ComponentModel;
using Azure.AI.OpenAI;
using Azure.AI.Projects;
using Azure.AI.Agents.Persistent;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents.AzureAI;
using OpenAI.Responses;

#pragma warning disable OPENAI001
#pragma warning disable SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var azureEndpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.");
Expand Down Expand Up @@ -85,7 +89,7 @@ async Task SKAgent_As_AFAgentAsync()

#pragma warning restore SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var thread = agent.GetNewThread();
var thread = await agent.CreateSessionAsync();
var agentOptions = new ChatClientAgentRunOptions(new() { Tools = [AIFunctionFactory.Create(GetWeather)] });

var result = await agent.RunAsync(userInput, thread, agentOptions);
Expand All @@ -98,9 +102,9 @@ async Task SKAgent_As_AFAgentAsync()
}

// Clean up
if (thread is ChatClientAgentThread chatThread)
if (thread is ChatClientAgentSession chatSession)
{
await azureAgentClient.Threads.DeleteThreadAsync(chatThread.ConversationId);
await azureAgentClient.Threads.DeleteThreadAsync(chatSession.ConversationId);
}
await azureAgentClient.Administration.DeleteAgentAsync(agent.Id);
}
Expand All @@ -109,26 +113,22 @@ async Task AFAgentAsync()
{
Console.WriteLine("\n=== AF Agent ===\n");

var azureAgentClient = new PersistentAgentsClient(azureEndpoint, new AzureCliCredential());
var agent = new AIProjectClient(new Uri(azureEndpoint), new AzureCliCredential())
.AsAIAgent(model: deploymentName,
instructions: "You are a helpful assistant",
tools: [AIFunctionFactory.Create(GetWeather)]);

var agent = await azureAgentClient.CreateAIAgentAsync(deploymentName, instructions: "Answer questions about the menu");
var session = await agent.CreateSessionAsync();
var agentOptions = new ChatClientAgentRunOptions(new() { MaxOutputTokens = 1000 });

var thread = agent.GetNewThread();
var agentOptions = new ChatClientAgentRunOptions(new() { Tools = [AIFunctionFactory.Create(GetWeather)] });

var result = await agent.RunAsync(userInput, thread, agentOptions);
var result = await agent.RunAsync(userInput, session, agentOptions);
Console.WriteLine(result);

Console.WriteLine("---");
await foreach (var update in agent.RunStreamingAsync(userInput, thread, agentOptions))
await foreach (var update in agent.RunStreamingAsync(userInput, session, agentOptions))
{
Console.Write(update);
}

// Clean up
if (thread is ChatClientAgentThread chatThread)
{
await azureAgentClient.Threads.DeleteThreadAsync(chatThread.ConversationId);
}
await azureAgentClient.Administration.DeleteAgentAsync(agent.Id);
// No cleanup needed - non-hosted path doesn't create server-side resources.
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@

<ItemGroup>
<PackageReference Include="Microsoft.Agents.AI.Abstractions" />
<PackageReference Include="Microsoft.Agents.AI.AzureAI" />
<PackageReference Include="Microsoft.Agents.AI.OpenAI" />
Copy link
Copy Markdown
Contributor

@westey-m westey-m Apr 8, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, looks like all foundry
And a few other samples below.

<PackageReference Include="Microsoft.Agents.AI.Foundry" />
<PackageReference Include="Azure.AI.OpenAI" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection" />
</ItemGroup>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
// Copyright (c) Microsoft. All rights reserved.

using Azure.AI.OpenAI;
using Azure.AI.Projects;
using Azure.AI.Agents.Persistent;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Extensions.AI;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.Agents.AzureAI;
using OpenAI.Responses;

#pragma warning disable OPENAI001
#pragma warning disable SKEXP0110 // Type is for evaluation purposes only and is subject to change or removal in future updates. Suppress this diagnostic to proceed.

var azureEndpoint = Environment.GetEnvironmentVariable("AZURE_FOUNDRY_PROJECT_ENDPOINT") ?? throw new InvalidOperationException("AZURE_FOUNDRY_PROJECT_ENDPOINT is not set.");
Expand Down Expand Up @@ -90,7 +94,7 @@ async Task SKAgent_As_AFAgentAsync()

var agent = skAgent.AsAIAgent();

var thread = agent.GetNewThread();
var thread = await agent.CreateSessionAsync();

var result = await agent.RunAsync(userInput, thread);
Console.WriteLine(result);
Expand All @@ -103,9 +107,9 @@ async Task SKAgent_As_AFAgentAsync()

// Clean up
var azureAgentClient = serviceProvider.GetRequiredService<PersistentAgentsClient>();
if (thread is ChatClientAgentThread chatThread)
if (thread is ChatClientAgentSession chatSession)
{
await azureAgentClient.Threads.DeleteThreadAsync(chatThread.ConversationId);
await azureAgentClient.Threads.DeleteThreadAsync(chatSession.ConversationId);
}
await azureAgentClient.Administration.DeleteAgentAsync(agent.Id);
}
Expand All @@ -115,36 +119,29 @@ async Task AFAgentAsync()
Console.WriteLine("\n=== AF Agent ===\n");

var serviceCollection = new ServiceCollection();
serviceCollection.AddSingleton((sp) => new PersistentAgentsClient(azureEndpoint, new AzureCliCredential()));
serviceCollection.AddSingleton((sp) => new AIProjectClient(new Uri(azureEndpoint), new AzureCliCredential()));
serviceCollection.AddTransient<AIAgent>((sp) =>
{
var azureAgentClient = sp.GetRequiredService<PersistentAgentsClient>();

return azureAgentClient.CreateAIAgent(
deploymentName,
name: "GenerateStory",
instructions: "You are good at telling jokes.");
var client = sp.GetRequiredService<AIProjectClient>();
return client.AsAIAgent(
deploymentName,
instructions: "You are good at telling jokes.",
name: "GenerateStory");
});

await using ServiceProvider serviceProvider = serviceCollection.BuildServiceProvider();
var agent = serviceProvider.GetRequiredService<AIAgent>();

var thread = agent.GetNewThread();
var session = await agent.CreateSessionAsync();

var result = await agent.RunAsync(userInput, thread);
var result = await agent.RunAsync(userInput, session);
Console.WriteLine(result);

Console.WriteLine("---");
await foreach (var update in agent.RunStreamingAsync(userInput, thread))
await foreach (var update in agent.RunStreamingAsync(userInput, session))
{
Console.Write(update);
}

// Clean up
var azureAgentClient = serviceProvider.GetRequiredService<PersistentAgentsClient>();
if (thread is ChatClientAgentThread chatThread)
{
await azureAgentClient.Threads.DeleteThreadAsync(chatThread.ConversationId);
}
await azureAgentClient.Administration.DeleteAgentAsync(agent.Id);
// No cleanup needed - non-hosted path doesn't create server-side resources.
}
Loading
Loading