微软AI智能体框架:企业级AI应用开发新范式
Microsoft Agent Framework (MAF) is a production-ready AI agent framework that combines Semantic Kernel and AutoGen strengths with enterprise features for observability, security, and durability, supporting multiple orchestration patterns and cloud-agnostic deployment. (微软AI智能体框架是一个生产就绪的AI智能体框架,结合了Semantic Kernel和AutoGen的优势以及企业级的可观测性、安全性和持久性功能,支持多种编排模式和云无关部署。)
Introduction to AI Agent Frameworks (AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架介绍)
AI agent frameworks represent a paradigm shift in how we build intelligent systems. According to industry reports from Gartner and Forrester, the adoption of AI agent frameworks is expected to grow by 300% over the next three years as organizations seek to operationalize their AI investments.
AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架代表了构建智能系统方式的范式转变。根据Gartner和Forrester的行业报告,随着各组织寻求将其AI投资投入运营,AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架的采用预计在未来三年内增长300%。
BLUF: Bottom Line Up Front (核心要点先行)
Microsoft Agent Framework (MAF) is a comprehensive, production-ready framework for building AI agents that combines the best features of Semantic Kernel and AutoGen while adding enterprise-grade capabilities for observability, security, and durability. (微软AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架是一个全面的、可用于生产的框架,用于构建AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.,它结合了Semantic Kernel和AutoGen的最佳特性,同时增加了企业级的可观测性、安全性和持久性能力。)
Understanding Microsoft Agent Framework (理解微软AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架)
Microsoft Agent Framework (MAF) builds on top of the experience and learnings from Semantic Kernel and AutoGen. It offers the flexibility to address the wide variety of agentic use cases seen in both production and research environments.
微软AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架建立在Semantic Kernel和AutoGen的经验和学习基础上。它提供了灵活性,以解决生产和研究环境中看到的各种智能体用例。
Key Orchestration Patterns (关键编排模式智能体之间协调和协作的结构化方式,包括顺序编排、并发编排、群聊编排、交接编排和磁力编排等多种模式。)
MAF supports multiple orchestration patterns:
- Sequential Agent orchestration in scenarios where step-by-step workflows are needed. (在需要逐步工作流的场景中进行顺序智能体编排)
- Concurrent orchestration in scenarios where agents need to complete tasks at the same time. (在智能体需要同时完成任务的情况下进行并发编排)
- Group chat orchestration in scenarios where agents can collaborate together on one task. (在智能体可以协作完成一个任务的情况下进行群聊编排)
- Handoff Orchestration in scenarios where agents hand off the task to one another as the subtasks are completed. (在智能体随着子任务完成而将任务交接给彼此的情况下进行交接编排)
- Magnetic Orchestration in scenarios where a manager agent creates and modifies a task list and handles the coordination of subagents to complete the task. (在管理器智能体创建和修改任务列表并处理子智能体协调以完成任务的情况下进行磁力编排)
Production-Ready Features (生产就绪特性)
To deliver AI Agents in Production, MAF includes essential features:
- Observability through OpenTelemetry integration (通过OpenTelemetry集成实现可观测性)
- Security via Azure AI Foundry with role-based access controls (通过Azure AI Foundry实现基于角色的访问控制安全)
- Durability with pause/resume capabilities for long-running processes (具有暂停/恢复能力以实现长时间运行流程的持久性)
- Control through human-in-the-loop workflows requiring approval (通过需要批准的人工介入工作流实现控制)
Key Concepts of Microsoft Agent Framework (微软AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架核心概念)
Agents (智能体)
An AI Agent is an autonomous software entity that perceives its environment and takes actions to achieve specific goals using artificial intelligence capabilities.
AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.是一个自主的软件实体,它感知环境并使用人工智能能力采取行动以实现特定目标。
Creating Agents (创建智能体)
Agent creation involves defining the inference service (LLM Provider), instructions, and name:
agent = AzureOpenAIChatClient(credential=AzureCliCredential()).create_agent(
instructions="You are good at recommending trips to customers based on their preferences.",
name="TripRecommender"
)
Running Agents (运行智能体)
Agents can be executed with streaming or non-streaming responses:
result = await agent.run("What are good places to visit in Amsterdam?")
print(result.text)
Tools (工具智能体可以调用的函数或服务,用于与外部系统交互或执行特定操作,扩展智能体的能力范围。)
Tools in MAF are functions that agents can invoke to interact with external systems or perform specific operations.
MAF中的工具智能体可以调用的函数或服务,用于与外部系统交互或执行特定操作,扩展智能体的能力范围。是智能体可以调用的函数,用于与外部系统交互或执行特定操作。
Tools can be defined during agent creation or at runtime:
def get_attractions(
location: Annotated[str, Field(description="The location to get the top tourist attractions for")],
) -> str:
"""Get the top tourist attractions for a given location."""
return f"The top attractions for {location} are."
Agent Threads (智能体线程管理多轮对话并维护对话状态的机制,支持序列化和反序列化以实现持久化存储和恢复。)
Agent Threads manage multi-turn conversations and maintain conversation state across sessions.
智能体线程管理多轮对话并维护对话状态的机制,支持序列化和反序列化以实现持久化存储和恢复。管理多轮对话并跨会话维护对话状态。
Threads support serialization for persistence:
thread = agent.get_new_thread()
serialized_thread = await thread.serialize()
resumed_thread = await agent.deserialize_thread(serialized_thread)
Agent Middleware (智能体中间件在智能体操作和外部交互之间提供拦截点的软件组件,用于实现日志记录、监控、转换或安全控制等功能。)
Middleware in MAF provides interception points between agent actions and external interactions.
MAF中的中间件在智能体操作和外部交互之间提供拦截点。
Function Middleware (函数中间件)
Intercepts tool/function calls for logging or modification:
async def logging_function_middleware(
context: FunctionInvocationContext,
next: Callable[[FunctionInvocationContext], Awaitable[None]],
) -> None:
"""Function middleware that logs function execution."""
print(f"[Function] Calling {context.function.name}")
await next(context)
print(f"[Function] {context.function.name} completed")
Chat Middleware (聊天中间件)
Intercepts LLM interactions for monitoring or transformation:
async def logging_chat_middleware(
context: ChatContext,
next: Callable[[ChatContext], Awaitable[None]],
) -> None:
"""Chat middleware that logs AI interactions."""
print(f"[Chat] Sending {len(context.messages)} messages to AI")
await next(context)
Migration and Integration Guide (迁移与集成指南)
Comparing MAF to Semantic Kernel and AutoGen (MAF与Semantic Kernel和AutoGen对比)
According to Microsoft's technical documentation, MAF represents an evolution that addresses limitations found in earlier frameworks:
- Enhanced Production Capabilities: MAF adds enterprise features missing in research-focused frameworks (增强的生产能力:MAF增加了以研究为重点的框架中缺少的企业功能)
- Unified API: Consistent interface across different orchestration patterns (统一API:跨不同编排模式智能体之间协调和协作的结构化方式,包括顺序编排、并发编排、群聊编排、交接编排和磁力编排等多种模式。的一致接口)
- Cloud Agnosticism: Unlike some proprietary solutions, MAF supports multi-cloud deployment (云无关性:与某些专有解决方案不同,MAF支持多云部署)
Integration Strategies (集成策略)
MAF's interoperability features include:
- Cloud-agnostic deployment - Agents can run in containers, on-prem and across multiple clouds (云无关部署 - 智能体可以在容器、本地和多个云中运行)
- Provider-agnostic design - Support for Azure OpenAI, OpenAI, and other LLM providers (提供商无关设计 - 支持Azure OpenAI、OpenAI和其他LLM提供商)
- Open Standards integration - A2A and Model Context Protocol (MCP) support (开放标准集成 - 支持A2A和模型上下文协议)
- Plugin ecosystem - Connections to Microsoft Fabric, SharePoint, Pinecone, Qdrant (插件生态系统 - 连接到Microsoft Fabric、SharePoint、Pinecone、Qdrant)
Production Deployment Considerations (生产部署考虑因素)
Observability and Monitoring (可观测性与监控)
MAF integrates with Azure AI Foundry dashboards for comprehensive monitoring of:
- Tool invocation patterns and performance (工具智能体可以调用的函数或服务,用于与外部系统交互或执行特定操作,扩展智能体的能力范围。调用模式和性能)
- Orchestration step execution times (编排步骤执行时间)
- Reasoning flow analysis and optimization (推理流程分析和优化)
- Error rates and recovery mechanisms (错误率和恢复机制)
Security Best Practices (安全最佳实践)
When deploying MAF in production environments:
- Implement role-based access control for agent management (为智能体管理实施基于角色的访问控制)
- Utilize Azure AI Foundry's built-in content safety features (利用Azure AI Foundry的内置内容安全功能)
- Establish private data handling protocols for sensitive information (为敏感信息建立私有数据处理协议)
- Regular security audits of agent behaviors and tool permissions (定期审计智能体行为和工具智能体可以调用的函数或服务,用于与外部系统交互或执行特定操作,扩展智能体的能力范围。权限)
Frequently Asked Questions (常见问题)
微软AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.框架与Semantic Kernel的主要区别是什么?
MAF在Semantic Kernel的基础上增加了企业级的生产功能,包括可观测性、安全控制、持久性和人类介入工作流,使其更适合生产环境部署。
MAF支持哪些AI模型提供商?
MAF支持Azure OpenAI、OpenAI以及通过标准接口集成的其他LLM提供商,具有提供商无关的设计架构。
如何实现智能体的持久化存储和恢复?
通过Agent Threads的序列化功能,可以将对话状态保存到数据库或文件系统,并在需要时反序列化恢复智能体状态。
MAF在安全方面有哪些特性?
MAF通过Azure AI Foundry提供基于角色的访问控制、私有数据处理、内置内容安全以及安全审计功能。
如何监控生产环境中的AI智能体An autonomous intelligent system that perceives its environment, makes decisions, and executes tasks, characterized by autonomy and adaptability.性能?
MAF集成了OpenTelemetry和Azure AI Foundry仪表板,可以监控工具智能体可以调用的函数或服务,用于与外部系统交互或执行特定操作,扩展智能体的能力范围。调用、编排步骤、推理流程和错误恢复等关键指标。
版权与免责声明:本文仅用于信息分享与交流,不构成任何形式的法律、投资、医疗或其他专业建议,也不构成对任何结果的承诺或保证。
文中提及的商标、品牌、Logo、产品名称及相关图片/素材,其权利归各自合法权利人所有。本站内容可能基于公开资料整理,亦可能使用 AI 辅助生成或润色;我们尽力确保准确与合规,但不保证完整性、时效性与适用性,请读者自行甄别并以官方信息为准。
若本文内容或素材涉嫌侵权、隐私不当或存在错误,请相关权利人/当事人联系本站,我们将及时核实并采取删除、修正或下架等处理措施。 也请勿在评论或联系信息中提交身份证号、手机号、住址等个人敏感信息。