S
SkillNav

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

资讯2026-02-20T05:52:57+00:007 分钟阅读
微软 Agent Framework 发布 RC:Semantic Kernel 与 AutoGen 项目迎来迁移窗口

我们非常高兴地宣布,Microsoft Agent Framework 已在 .NETPython 上达到 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

code
pip install agent-framework --pre
code
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

code
dotnet add package Microsoft.Agents.AI.OpenAI --prerelease
dotnet add package Azure.Identity
code
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

code
pip install agent-framework-orchestrations --pre
code
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

code
dotnet add package Microsoft.Agents.AI.Workflows --prerelease
code
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

Dmytro Struk

高级软件工程师

Shawn Henry

首席组产品经理

首席组产品经理

原文链接:https://devblogs.microsoft.com/semantic-kernel/migrate-your-semantic-kernel-and-autogen-projects-to-microsoft-agent-framework-release-candidate/

相关文章

AINews:Harness Engineering 到底是不是一门真学问?
深度·3月5日
AINews:Harness Engineering 到底是不是一门真学问?

这篇文章围绕 AI 工程中的核心争议展开:系统能力究竟主要来自更强的模型(Big Model),还是来自更强的编排层(Big Harness)。文中汇总了 OpenAI、Anthropic、Scale AI、METR 等多方观点与数据,显示两派在“模型进步会不会吞噬 Harness 价值”上分歧明显。作者最终认为,随着 Agent 产品落地加速,Harness Engineering 的独立价值正在被市场和社区进一步确认。

10 分钟
每个 Agent 都需要一个 Box:Aaron Levie 谈 AI 时代的新基础设施
深度·3月5日
每个 Agent 都需要一个 Box:Aaron Levie 谈 AI 时代的新基础设施

在围绕“AI 是否正在杀死 SaaS”的争论中,Box CEO Aaron Levie 提出相反观点:企业内容与文件系统在 Agent 时代反而更关键。随着 Filesystem、Sandbox 和 Agent 工作流快速普及,核心问题从“让 Agent 能做事”转向“如何治理 Agent 的身份、权限与安全边界”。他认为,未来企业将拥有远多于人的 Agent 数量,而真正的竞争力在于率先完成面向 Agent 的组织与基础设施改造。

8 分钟