Microsoft AI Agents for Beginners 课程深度研究
Microsoft AI Agents for Beginners Course - Deep Dive
🎯 核心收获
🎯 Key Takeaways
1. AI Agent的本质定义
1. What is an AI Agent?
AI Agent是让大语言模型能够实际执行操作的系统,通过给予工具和知识来作用于世界,而不仅仅是响应提示。
AI Agents are systems that let LLMs actually DO things by giving them tools and knowledge to act on the world, not just respond to prompts.
核心三要素:
Core components:
- Environment:Agent工作的空间
- Sensors:Agent读取环境状态的途径
- Actuators:Agent采取行动的方式
2. Agent的七种类型
2. Seven Types of Agents
| 类型 | Type | 特点 | Characteristics | 示例 | Example |
|---|---|---|---|---|---|
| 简单反射型 | Simple Reflex | 硬编码规则,无记忆 | Hard-coded rules | 邮件转发 | Email forwarding |
| 基于模型的反射型 | Model-Based | 维护世界内部模型 | Internal world model | 价格跟踪 | Price tracking |
| 目标导向型 | Goal-Based | 有目标,逐步规划 | Step-by-step planning | 行程预订 | Trip booking |
| 效用导向型 | Utility-Based | 权衡利弊找最优 | Optimize tradeoffs | 最优决策 | Optimal decisions |
| 学习型 | Learning | 通过反馈持续改进 | Continuous improvement | 自适应推荐 | Adaptive recommendations |
| 分层型 | Hierarchical | 多层Agent分工 | Multi-level delegation | 任务分解 | Task decomposition |
| 多Agent系统 | Multi-Agent | 多Agent协作 | Agent collaboration | 团队协作 | Team collaboration |
3. 三大核心Agent框架对比
3. Three Core Agent Frameworks Comparison
| 框架 | Framework | 特点 | Features | 适用场景 | Use Cases |
|---|---|---|---|---|---|
| AutoGen | AutoGen | 开源、事件驱动、分布式 | Open source, Event-driven | 研究、多Agent | Research, Multi-agent |
| Semantic Kernel | Semantic Kernel | 企业级、轻量级、Azure集成 | Enterprise, Lightweight | 企业应用 | Enterprise apps |
| Azure AI Agent Service | Azure AI Agent | 全托管、自动工具调用 | Fully managed, Auto tool calling | 生产环境 | Production |
4. 六大Agent设计模式
4. Six Core Agent Design Patterns
1. Tool Use
函数调用/工具使用
函数调用/工具使用
2. Planning
任务分解与规划
任务分解与规划
3. Memory
短期/长期记忆
短期/长期记忆
4. Multi-Agent
多Agent协作
多Agent协作
5. Metacognition
元认知/自我反思
元认知/自我反思
6. Trustworthiness
可信Agent构建
可信Agent构建
5. 三大Agent协议
5. Three Agent Protocols
| 协议 | 全称 | 定位 | Positioning | 核心功能 | Core Function |
|---|---|---|---|---|---|
| MCP | Model Context Protocol | LLM ↔ 工具/数据 | LLM ↔ Tools/Data | 标准化工具发现 | Standardized tool discovery |
| A2A | Agent to Agent | Agent ↔ Agent | Agent ↔ Agent | 跨组织协作 | Cross-org collaboration |
| NLWeb | Natural Language Web | 网站 ↔ AI | Website ↔ AI | 自然语言交互 | Natural language interaction |
📖 详细内容
📖 Detailed Content
1. Agentic RAG核心循环
1. Agentic RAG Core Loop
┌─────────────────────────────────────────┐
│ Agentic RAG Core Loop │
├─────────────────────────────────────────┤
│ 1. Initial Call: 用户目标发给LLM │
│ 2. Tool Invocation: 选择检索工具 │
│ 3. Assessment: 评估结果是否足够 │
│ 4. Refinement: 优化查询或尝试其他工具 │
│ 5. Repeat: 循环直到满意 │
│ 6. Final Response: 交付最终答案 │
└─────────────────────────────────────────┘
与传统RAG的区别:
Difference from Traditional RAG:
| 维度 | Dimension | 传统RAG | Agentic RAG |
|---|---|---|---|
| 流程 | Flow | 检索→读取(固定) | LLM调用→工具调用→循环 |
| 规划 | Planning | 预定义路径 | 自主决定 |
| 错误处理 | Error Handling | 返回失败 | 重试、调整策略 |
2. MCP协议工作流程
2. MCP Protocol Workflow
1. AI助手(Client)连接航司MCP Server
2. 询问可用工具 → Server返回"search_flights"、"book_flights"
3. 用户请求:搜索Portland到Honolulu的航班
4. AI识别需调用"search_flights",传参数给Server
5. Server调用航司API,返回航班信息
6. 用户选择航班,AI调用"book_flights"完成预订
3. 多Agent退款流程示例
3. Multi-Agent Refund Process Example
专用Agent:
Specific Agents:
- Customer Agent(客户)
- Seller Agent(卖家)
- Payment Agent(支付)
- Resolution Agent(解决)
- Compliance Agent(合规)
通用Agent:
General Agents:
- Shipping/Feedback/Escalation Agent
- Notification/Analytics/Audit Agent
- Reporting/Knowledge/Security Agent
💭 思考与实践
💭 Reflections and Practice
学习心得
Key Insights
- Agent不是银弹:不是所有问题都需要Agent,简单LLM能解决的不要过度设计
- 工具是Agent的灵魂:Agent的能力边界由其工具体系决定
- 多Agent协作是趋势:复杂任务需要专业化分工
- 协议标准化很重要:MCP、A2A、NLWeb将构建Agent生态基础设施
适用场景
When to Use What
| 场景 | Scenario | 推荐模式 | Recommended Pattern |
|---|---|---|---|
| 简单问答 | Simple Q&A | 基础LLM | Basic LLM |
| 需要调用API | API Integration | Tool Use | Tool Use |
| 跨数据库检索 | Cross-DB Retrieval | Agentic RAG | Agentic RAG |
| 复杂多步任务 | Complex Multi-step | Planning + Multi-Agent | Planning + Multi-Agent |
| 网站智能化 | Website Intelligence | NLWeb | NLWeb |
🔗 相关链接
🔗 Related Links
📝 笔记信息📝 Note Info
学习日期:2026-04-28 | 来源:Microsoft GitHub | 作者:常思杨Date: 2026-04-28 | Source: Microsoft GitHub | Author: 常思杨