agentframeworkllmmulti-agentmicrosoftenterprisepythondotnet type: concept 创建: 2026-05-15 更新: 2026-05-15

Microsoft Agent Framework

Microsoft Agent Framework(MAF) 是微软推出的企业级多 Agent 开发框架,2026 年 4 月 3 日发布 1.0 GA。它是 ai-game-devtools/autogen(微软研究院)和 Semantic Kernel 的统一后继者,由同一团队打造,同时支持 .NET 和 Python 作为一等公民。

定位:AutoGen + Semantic Kernel 的融合

MAF 合并了两条产品线的核心能力:

来源继承的能力
AutoGen多 Agent 对话模式(GroupChat/Handoff/Magentic)、Agent 抽象、MCP/A2A 协议支持
Semantic Kernel企业级特性(Session 状态管理、Middleware 管道、Telemetry)、插件模型

“Agent Framework is the direct successor, created by the same teams. In short, Agent Framework is the next generation of both Semantic Kernel and AutoGen.”

核心架构

MAF 提供两大核心能力:AgentWorkflow

Agents

LLM 驱动的智能体,支持:

  • 6+ LLM Provider:Azure OpenAI/OpenAI/Anthropic/Ollama/Gemini/Bedrock
  • 工具调用:FunctionTool、MCP Server、Code Interpreter
  • 中间件系统:拦截 Agent run()、Chat get_response()、Function 调用
  • Session 管理:状态持久化(内存/文件/Azure Cosmos/Redis)
  • Context Provider:RAG、记忆系统、Compaction
from agent_framework import Agent
from agent_framework.openai import OpenAIChatClient

agent = Agent(
    client=OpenAIChatClient(),
    instructions="You are helpful.",
    tools=[my_function],
)
response = await agent.run("Hello")

Workflows

基于有向图(DAG) 的显式编排,两种 API:

API控制流适合场景
Functional (@workflow)原生 Python(if/for/asyncio.gather)顺序管道、自定义循环
Graph (WorkflowBuilder)边和条件路由固定拓扑、Fan-out/Fan-in

核心概念:

  • Executor — 基本工作单元(Executor<TInput, TOutput>),强类型输入输出
  • Edge — 连接 Executor 的边,可带条件路由
  • Orchestrator — 编排模式:Sequential / Concurrent / Handoff / GroupChat / Magentic
# Functional API
from agent_framework import workflow

@workflow
async def my_workflow(ctx):
    step1 = await ctx.call(executor1, input_data)
    step2 = await ctx.call(executor2, step1)
    return step2

Durable Workflows(持久化工作流)

通过 Microsoft.Agents.AI.DurableTask 包实现,不改 workflow 定义即可获得:

  • Checkpointing:保存每步状态,崩溃后恢复
  • 分布式执行:跨机器编排
  • 已完成 Agent 不重复执行
  • Azure Functions 托管

生态体系

Python 包结构

agent-framework/python/packages/
├── core/             # 核心抽象(Agent/ChatClient/Session/Middleware/Workflow)
├── openai/           # OpenAI Responses API + Chat Completions
├── anthropic/        # Anthropic Claude
├── ollama/           # 本地 Ollama
├── gemini/           # Google Gemini
├── foundry/          # Azure AI Foundry
├── a2a/              # Agent-to-Agent 协议
├── ag-ui/            # AG-UI 协议
├── devui/            # 开发者 UI
├── declarative/      # YAML/JSON Agent 定义
├── durabletask/      # 持久化执行引擎
├── mem0/             # Mem0 记忆集成
├── redis/            # Redis 存储
├── azure-cosmos/     # CosmosDB
└── ...

Provider 矩阵(6+ 模型供应商)

OpenAI / Azure OpenAI / Anthropic Claude / Ollama / Gemini / AWS Bedrock / Azure AI Foundry

协议支持

  • MCP — 原生 McpClientuse_mcp_tools() 支持
  • A2A — Agent-to-Agent 协议(独立包)
  • AG-UI — Agent 用户界面协议

与 AutoGen 的迁移关系

概念AutoGen v0.4MAF
AgentRoutedAgentAgent / BaseAgent
Chat ClientModelClientBaseChatClient
工具ToolFunctionTool / @tool
会话AgentSession
中间件AgentMiddleware / ChatMiddleware
工作流GroupChat / HandoffWorkflow + Orchestrator
CheckpointDurableTask

官方迁移指南:https://learn.microsoft.com/en-us/agent-framework/migration-guide/from-autogen/

仓库概况

指标数值
GitHub Stars~10K+(快速增长的官方仓库)
LicenseMIT
语言Python + C# (.NET)
1.0 GA2026-04-03
组织microsoft
开发者预览2025 年底开始

相关页面