Migrating from Semantic Kernel to Microsoft Agent Framework: A C# Developer's Guide
The future of AI agent development in .NET is here — and it unifies everything.
At .NET Conf 2025, Microsoft announced that Microsoft Agent Framework has reached Release Candidate status. This isn't just another SDK update — it's a major consolidation that merges Semantic Kernel and AutoGen into a single, unified framework for building AI agents.
If you've been following my Semantic Kernel series, you might be wondering: What does this mean for my existing code? Should I migrate now? How different is the new API?
Let's break it all down.
What Changed and Why
For the past two years, Microsoft maintained two separate agentic AI frameworks:
- Semantic Kernel — focused on orchestration, plugins, and enterprise integration
- AutoGen — focused on multi-agent conversations and research scenarios
The problem? Developers were confused about which to use. Features overlapped. Codebases diverged. The community was fragmented.
Agent Framework solves this by providing:
| Capability | Agent Framework |
|---|---|
| Simple agent creation | ✅ Few lines of code |
| Function tools | ✅ Type-safe definitions |
| Multi-agent workflows | ✅ Sequential, concurrent, handoff, group chat |
| Streaming | ✅ Built-in |
| Human-in-the-loop | ✅ Native support |
| Multi-provider | ✅ Azure OpenAI, OpenAI, Anthropic, Ollama, etc. |
| Interoperability | ✅ A2A, MCP, AG-UI standards |
The API surface is now stable and feature-complete for v1.0. GA is expected in Q1 2026.
Before and After: Creating an Agent
Let's compare how you'd create a simple agent in both frameworks.
Semantic Kernel (Legacy)
using Microsoft.SemanticKernel;
using Microsoft.SemanticKernel.ChatCompletion;
var builder = Kernel.CreateBuilder();
builder.AddAzureOpenAIChatCompletion(
deploymentName: "gpt-4",
endpoint: "https://your-resource.openai.azure.com/",
apiKey: Environment.GetEnvironmentVariable("AZURE_OPENAI_KEY")!
);
var kernel = builder.Build();
var chat = kernel.GetRequiredService<IChatCompletionService>();
var history = new ChatHistory();
history.AddSystemMessage("You are a helpful assistant.");
history.AddUserMessage("Write a haiku about cloud computing.");
var response = await chat.GetChatMessageContentsAsync(history);
Console.WriteLine(response[0].Content);
Microsoft Agent Framework (New)
using Azure.Identity;
using Microsoft.Agents.AI;
using OpenAI;
var agent = new OpenAIClient(
new BearerTokenPolicy(new AzureCliCredential(), "https://ai.azure.com/.default"),
new OpenAIClientOptions { Endpoint = new Uri("https://your-resource.openai.azure.com/openai/v1") })
.GetResponsesClient("gpt-4.1")
.AsAIAgent(
name: "CloudPoet",
instructions: "You are a helpful assistant."
);
Console.WriteLine(await agent.RunAsync("Write a haiku about cloud computing."));
Notice the difference? Agent Framework treats the agent as a first-class concept. You're not wiring up services and building kernels — you're defining an agent with a name, instructions, and capabilities.
Migrating Function Tools (Plugins)
This is where migrations get interesting. In Semantic Kernel, you defined plugins as classes with kernel functions:
Semantic Kernel Plugin
public class WeatherPlugin
{
[KernelFunction("get_weather")]
[Description("Gets the current weather for a location")]
public string GetWeather(
[Description("The city name")] string city)
{
// Simulated weather lookup
return $"The weather in {city} is sunny, 72°F";
}
}
// Registration
kernel.Plugins.AddFromType<WeatherPlugin>();
Agent Framework Function Tool
using Microsoft.Agents.AI;
using System.ComponentModel;
var weatherTool = AIFunction.Create(
[Description("Gets the current weather for a location")]
(string city) => $"The weather in {city} is sunny, 72°F",
name: "get_weather"
);
var agent = chatClient.AsAIAgent(
name: "WeatherBot",
instructions: "You help users check the weather.",
tools: [weatherTool]
);
The new approach uses AIFunction.Create() with lambda expressions. It's more concise, but you can still use class-based tools when you need dependency injection or complex logic.
Multi-Agent Orchestration
Here's where Agent Framework really shines. Remember building multi-agent systems with AgentGroupChat in Semantic Kernel? It worked, but the API was verbose.
Sequential Workflow Example
Let's build a content pipeline where a writer drafts content and a reviewer provides feedback:
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
// Create specialized agents
ChatClientAgent writer = new(chatClient,
"You are a concise copywriter. Create engaging marketing copy.",
"writer");
ChatClientAgent reviewer = new(chatClient,
"You are a thorough editor. Review the copy and suggest improvements.",
"reviewer");
ChatClientAgent finalizer = new(chatClient,
"You incorporate feedback and produce the final polished copy.",
"finalizer");
// Build sequential workflow: writer -> reviewer -> finalizer
Workflow workflow = AgentWorkflowBuilder.BuildSequential(writer, reviewer, finalizer);
// Execute with streaming
List<ChatMessage> messages = [new(ChatRole.User, "Write a tagline for a cybersecurity startup.")];
await using StreamingRun run = await InProcessExecution.RunStreamingAsync(workflow, messages);
await run.TrySendMessageAsync(new TurnToken(emitEvents: true));
await foreach (WorkflowEvent evt in run.WatchStreamAsync())
{
if (evt is AgentResponseUpdateEvent e)
{
Console.Write(e.Update.Text);
}
}
Concurrent Workflows
Need multiple agents to work in parallel? Agent Framework handles that too:
// Research agents that work simultaneously
ChatClientAgent marketResearcher = new(chatClient,
"Research market trends and competitor analysis.",
"market_researcher");
ChatClientAgent techAnalyst = new(chatClient,
"Analyze technical feasibility and implementation costs.",
"tech_analyst");
ChatClientAgent riskAssessor = new(chatClient,
"Identify potential risks and mitigation strategies.",
"risk_assessor");
// All three run concurrently, results aggregated
Workflow parallelWorkflow = AgentWorkflowBuilder.BuildConcurrent(
marketResearcher,
techAnalyst,
riskAssessor
);
Handoff Patterns
For scenarios where agents need to transfer control:
Workflow handoffWorkflow = AgentWorkflowBuilder.BuildHandoff(
new HandoffConfig
{
Agents = [salesAgent, supportAgent, billingAgent],
Router = routerAgent, // Decides who handles each message
AllowBacktrack = true
}
);
What About My Planners?
If you're using Semantic Kernel's planners (Handlebars, Stepwise), here's the migration path:
| SK Planner | Agent Framework Equivalent |
|---|---|
| FunctionCallingStepwisePlanner | Use agent with tools + reasoning model |
| HandlebarsPlanner | Sequential workflows with templating |
| Custom planners | Graph-based workflow builder |
The good news: modern reasoning models (GPT-4.1, Claude Opus) handle planning natively. You often don't need explicit planners anymore — just give your agent the right tools and instructions.
MCP Integration
One of Agent Framework's biggest additions is native Model Context Protocol (MCP) support. This means your agents can connect to any MCP-compatible tool server:
var agent = chatClient.AsAIAgent(
name: "DevAgent",
instructions: "You help developers with their codebase.",
mcpServers: [
new McpServerConfig("filesystem", "uvx mcp-server-filesystem /workspace"),
new McpServerConfig("github", "uvx mcp-server-github")
]
);
Your agent automatically gets access to all tools exposed by those MCP servers. No plugin code needed.
Migration Checklist
Ready to migrate? Here's your action plan:
1. Update NuGet Packages
# Remove old packages
dotnet remove package Microsoft.SemanticKernel
# Add new packages
dotnet add package Microsoft.Agents.AI.OpenAI --prerelease
dotnet add package Microsoft.Agents.AI.Workflows --prerelease
dotnet add package Azure.Identity
2. Replace Kernel with Agents
-
Kernel→IAIAgentimplementations -
KernelFunction→AIFunction -
IChatCompletionService→ agent'sRunAsync()
3. Convert Plugins to Tools
-
[KernelFunction]methods →AIFunction.Create()lambdas or[AIFunction]attributes - Plugins become tool collections passed to agents
4. Update Orchestration
-
AgentGroupChat→AgentWorkflowBuilderworkflows - Selection strategies →
BuildHandoff()with router - Termination conditions → workflow completion handlers
5. Test Incrementally
The RC is stable, but test each migrated component before moving on. The official migration guide covers edge cases.
Should You Migrate Now?
Yes, if:
- You're starting a new project
- You need multi-agent orchestration
- You want MCP/A2A interoperability
- You're hitting Semantic Kernel's complexity ceiling
Wait if:
- You have stable production code with no new requirements
- You need features not yet in the RC
- Your team needs time to learn the new patterns
The RC is stable enough for development. GA is imminent. Getting familiar now means you're ready when it lands.
What's Next?
This post covers the fundamentals. In the next article, we'll dive deeper into:
- Advanced workflow patterns — conditional branching, loops, and error recovery
- Human-in-the-loop — approval workflows and intervention points
- Distributed agents — running agents across services with A2A protocol
The agent era is here. Time to build.
Have questions about migrating your Semantic Kernel project? Drop a comment below.
Resources:
Top comments (0)