微软 Agent Framework 发布 RC:Semantic Kernel 与 AutoGen 项目迎来迁移窗口

我们非常高兴地宣布,Microsoft Agent Framework 已在 .NET 和 Python 上达到 Release Candidate 阶段。Release Candidate 是迈向 General Availability 的关键里程碑——这意味着 API surface 已经稳定,并且我们计划随 1.0 版本发布的全部功能都已完成。现在正是将你的 Semantic Kernel 项目迁移到 Microsoft Agent Framework,并在最终发布前向我们提供反馈的最佳时机。无论你是在构建一个实用的单体助手,还是在编排一组专业化 Agent 协同工作,Agent Framework 都能提供一致的多语言基础能力。
什么是 Microsoft Agent Framework?
Microsoft Agent Framework 是一个全面的开源框架,用于构建、编排和部署 AI Agent。它是 Semantic Kernel 与 AutoGen 的后继方案,并在 .NET 与 Python 上提供统一的编程模型,具备以下能力:
- 简单创建 Agent —— 只需几行代码即可从零构建可运行 Agent
- Function tools —— 通过类型安全(type-safe)的工具定义,让 Agent 能调用你的代码
- 基于图的工作流 —— 将 Agent 与函数组合为串行、并行、handoff、群聊等模式,并支持流式输出、checkpointing 与 human-in-the-loop
- 多 Provider 支持 —— 可对接 Microsoft Foundry、Azure OpenAI、OpenAI、GitHub Copilot、Anthropic Claude、AWS Bedrock、Ollama 等
- 互操作性 —— 支持 A2A(Agent-to-Agent)、AG-UI 与 MCP(Model Context Protocol)标准
从 Semantic Kernel 与 AutoGen 迁移
如果你一直使用 Semantic Kernel 或 AutoGen 构建 Agent,那么 Agent Framework 是顺理成章的下一步。我们已经发布了详细迁移指南,帮助你平滑过渡:
创建你的第一个 Agent
上手只需要几行代码。下面演示如何在两种语言中创建一个简单 Agent。
Python
pip install agent-framework --pre
import asyncio
from agent_framework.azure import AzureOpenAIResponsesClient
from azure.identity import AzureCliCredential
async def main():
agent = AzureOpenAIResponsesClient(
credential=AzureCliCredential(),
).as_agent(
name="HaikuBot",
instructions="You are an upbeat assistant that writes beautifully.",
)
print(await agent.run("Write a haiku about Microsoft Agent Framework."))
if __name__ == "__main__":
asyncio.run(main())
.NET
dotnet add package Microsoft.Agents.AI.OpenAI --prerelease
dotnet add package Azure.Identity
using System.ClientModel.Primitives;
using Azure.Identity;
using Microsoft.Agents.AI;
using OpenAI;
using OpenAI.Responses;
// Replace <resource> and gpt-4.1 with your Azure OpenAI resource name and deployment name.
var agent = new OpenAIClient(
new BearerTokenPolicy(new AzureCliCredential(), "https://ai.azure.com/.default"),
new OpenAIClientOptions() { Endpoint = new Uri("https://<resource>.openai.azure.com/openai/v1") })
.GetResponsesClient("gpt-4.1")
.AsAIAgent(name: "HaikuBot", instructions: "You are an upbeat assistant that writes beautifully.");
Console.WriteLine(await agent.RunAsync("Write a haiku about Microsoft Agent Framework."));
就是这么简单——几行代码就能得到一个可运行的 AI Agent。接下来你可以继续添加 Function tools、多轮对话会话(session)、流式响应等能力。
多 Agent 工作流
单 Agent 已经很强大,但真实业务通常需要多个 Agent 协同。Agent Framework 内置工作流引擎,可将 Agent 组合成串行、并行、handoff、群聊等编排模式,并且全部内建流式支持。
下面是一个串行工作流示例:先由文案 Agent 产出标语,再由评审 Agent 给出反馈。
Python
pip install agent-framework-orchestrations --pre
import asyncio
from typing import cast
from agent_framework import Message
from agent_framework.azure import AzureOpenAIChatClient
from agent_framework.orchestrations import SequentialBuilder
from azure.identity import AzureCliCredential
async def main() -> None:
client = AzureOpenAIChatClient(credential=AzureCliCredential())
writer = client.as_agent(
instructions="You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt.",
name="writer",
)
reviewer = client.as_agent(
instructions="You are a thoughtful reviewer. Give brief feedback on the previous assistant message.",
name="reviewer",
)
# Build sequential workflow: writer -> reviewer
workflow = SequentialBuilder(participants=[writer, reviewer]).build()
# Run and collect outputs
outputs: list[list[Message]] = []
async for event in workflow.run("Write a tagline for a budget-friendly eBike.", stream=True):
if event.type == "output":
outputs.append(cast(list[Message], event.data))
if outputs:
for msg in outputs[-1]:
name = msg.author_name or "user"
print(f"[{name}]: {msg.text}")
if __name__ == "__main__":
asyncio.run(main())
.NET
dotnet add package Microsoft.Agents.AI.Workflows --prerelease
using System.ClientModel.Primitives;
using Azure.Identity;
using Microsoft.Agents.AI;
using Microsoft.Agents.AI.Workflows;
using Microsoft.Extensions.AI;
using OpenAI;
// Replace <resource> and gpt-4.1 with your Azure OpenAI resource name and deployment name.
var chatClient = new OpenAIClient(
new BearerTokenPolicy(new AzureCliCredential(), "https://ai.azure.com/.default"),
new OpenAIClientOptions() { Endpoint = new Uri("https://<resource>.openai.azure.com/openai/v1") })
.GetChatClient("gpt-4.1")
.AsIChatClient();
ChatClientAgent writer = new(chatClient,
"You are a concise copywriter. Provide a single, punchy marketing sentence based on the prompt.",
"writer");
ChatClientAgent reviewer = new(chatClient,
"You are a thoughtful reviewer. Give brief feedback on the previous assistant message.",
"reviewer");
// Build sequential workflow: writer -> reviewer
Workflow workflow = AgentWorkflowBuilder.BuildSequential(writer, reviewer);
List<ChatMessage> messages = [new(ChatRole.User, "Write a tagline for a budget-friendly eBike.")];
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);
}
}
接下来是什么?
这次 Release Candidate 是迈向 GA 的关键一步。我们鼓励你尽快试用该框架并分享反馈——在未来几周我们敲定最终发布版本时,你的意见将非常重要。
更多信息可查看我们的文档与 GitHub 示例,并从 NuGet (.NET) 或 PyPI (Python) 安装最新包。
Category
Author

高级软件工程师

首席组产品经理
首席组产品经理

