AI Agent 工程师完整学习路线(面向生产级项目与面试)

AI Agent 工程师完整学习路线(面向生产级项目与面试)

目标:从"会调用大模型 / 会搭 Dify 工作流",提升到"能独立设计、开发、调试、评测并上线生产级 AI Agent 系统"。

建议周期:16 周

建议投入:工作日每天 1.5~2 小时 ,周末 3~4 小时

主线技术:Python + Agent Loop + Function Calling + LangChain + LangGraph + RAG + Elasticsearch + Redis + Kafka/RocketMQ + Evaluation + Harness/Coding Agent


1. 最终能力目标

不要只把目标定成:

会 LangChain、会 Dify、会调用模型。

真正应该达到:

具备"后端工程能力 + AI Agent 工程能力",能够独立完成生产级 Agent 系统。

最终需要掌握以下 10 个能力模块:

能力模块 必须掌握
Agent 基础 Agent vs Workflow、Agent Loop、ReAct、Plan-and-Execute
Tool Calling Function Calling、JSON Schema、参数校验、重试、超时
LangGraph State、Node、Edge、Reducer、Conditional Edge、Checkpoint、HITL
RAG Chunk、Embedding、BM25、Vector Search、Hybrid Search、RRF、Rerank
Agentic RAG Query Rewrite、检索失败判断、重新规划、多阶段检索
Context / Memory 多轮指代、短期记忆、长期记忆、上下文压缩
Multi-Agent Supervisor、Orchestrator-Worker、Pipeline、Agent 通信
工程化 Redis、ES、Kafka/RocketMQ、限流、幂等、分布式锁、重试
可观测与评测 Trace、Evaluation、Golden Dataset、回归测试
Harness / Coding Agent Repo Search、上下文裁剪、Sandbox、CI、安全边界

2. 总体学习线路图

#mermaid-svg-RSNoWizfvZrzG66W{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-RSNoWizfvZrzG66W .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-RSNoWizfvZrzG66W .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-RSNoWizfvZrzG66W .error-icon{fill:#552222;}#mermaid-svg-RSNoWizfvZrzG66W .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-RSNoWizfvZrzG66W .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-RSNoWizfvZrzG66W .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-RSNoWizfvZrzG66W .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-RSNoWizfvZrzG66W .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-RSNoWizfvZrzG66W .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-RSNoWizfvZrzG66W .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-RSNoWizfvZrzG66W .marker{fill:#333333;stroke:#333333;}#mermaid-svg-RSNoWizfvZrzG66W .marker.cross{stroke:#333333;}#mermaid-svg-RSNoWizfvZrzG66W svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-RSNoWizfvZrzG66W p{margin:0;}#mermaid-svg-RSNoWizfvZrzG66W .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-RSNoWizfvZrzG66W .cluster-label text{fill:#333;}#mermaid-svg-RSNoWizfvZrzG66W .cluster-label span{color:#333;}#mermaid-svg-RSNoWizfvZrzG66W .cluster-label span p{background-color:transparent;}#mermaid-svg-RSNoWizfvZrzG66W .label text,#mermaid-svg-RSNoWizfvZrzG66W span{fill:#333;color:#333;}#mermaid-svg-RSNoWizfvZrzG66W .node rect,#mermaid-svg-RSNoWizfvZrzG66W .node circle,#mermaid-svg-RSNoWizfvZrzG66W .node ellipse,#mermaid-svg-RSNoWizfvZrzG66W .node polygon,#mermaid-svg-RSNoWizfvZrzG66W .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-RSNoWizfvZrzG66W .rough-node .label text,#mermaid-svg-RSNoWizfvZrzG66W .node .label text,#mermaid-svg-RSNoWizfvZrzG66W .image-shape .label,#mermaid-svg-RSNoWizfvZrzG66W .icon-shape .label{text-anchor:middle;}#mermaid-svg-RSNoWizfvZrzG66W .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-RSNoWizfvZrzG66W .rough-node .label,#mermaid-svg-RSNoWizfvZrzG66W .node .label,#mermaid-svg-RSNoWizfvZrzG66W .image-shape .label,#mermaid-svg-RSNoWizfvZrzG66W .icon-shape .label{text-align:center;}#mermaid-svg-RSNoWizfvZrzG66W .node.clickable{cursor:pointer;}#mermaid-svg-RSNoWizfvZrzG66W .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-RSNoWizfvZrzG66W .arrowheadPath{fill:#333333;}#mermaid-svg-RSNoWizfvZrzG66W .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-RSNoWizfvZrzG66W .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-RSNoWizfvZrzG66W .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-RSNoWizfvZrzG66W .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-RSNoWizfvZrzG66W .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-RSNoWizfvZrzG66W .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-RSNoWizfvZrzG66W .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-RSNoWizfvZrzG66W .cluster text{fill:#333;}#mermaid-svg-RSNoWizfvZrzG66W .cluster span{color:#333;}#mermaid-svg-RSNoWizfvZrzG66W div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-RSNoWizfvZrzG66W .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-RSNoWizfvZrzG66W rect.text{fill:none;stroke-width:0;}#mermaid-svg-RSNoWizfvZrzG66W .icon-shape,#mermaid-svg-RSNoWizfvZrzG66W .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-RSNoWizfvZrzG66W .icon-shape p,#mermaid-svg-RSNoWizfvZrzG66W .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-RSNoWizfvZrzG66W .icon-shape .label rect,#mermaid-svg-RSNoWizfvZrzG66W .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-RSNoWizfvZrzG66W .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-RSNoWizfvZrzG66W .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-RSNoWizfvZrzG66W :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 阶段1:LLM 与 Agent 基础
阶段2:手写 Agent Loop
阶段3:Function Calling / Tools
阶段4:LangChain
阶段5:LangGraph
阶段6:RAG
阶段7:Hybrid Search + Rerank
阶段8:Context / Memory
阶段9:Redis + Elasticsearch
阶段10:Agentic RAG
阶段11:Multi-Agent
阶段12:Kafka / 异步任务
阶段13:Trace / Evaluation
阶段14:Harness / Coding Agent
阶段15:Sandbox / Security
阶段16:综合项目 + 模拟面试

一句话记住:

text 复制代码
LLM
 ↓
Agent Loop
 ↓
Tools
 ↓
LangGraph
 ↓
RAG
 ↓
Memory
 ↓
Multi-Agent
 ↓
工程化
 ↓
Evaluation
 ↓
Harness / Coding Agent
 ↓
生产级 Agent

3. 16 周学习总览

周数 学习主题 必须产出
第 1 周 LLM、Prompt、Token、Message、Structured Output 最小模型调用 Demo
第 2 周 Agent、Workflow、ReAct、Agent Loop 手写最小 Agent Loop
第 3 周 Function Calling、Tool Schema、错误处理 4 个 Tool + 参数校验
第 4 周 LangChain 核心 LangChain Tool Agent
第 5 周 LangChain 工程化 Memory / Middleware / Structured Output
第 6 周 LangGraph 基础 StateGraph Demo
第 7 周 LangGraph 高级 Conditional Edge + Checkpoint + HITL
第 8 周 RAG 基础 文档切片 + Embedding + Vector Search
第 9 周 Hybrid Search BM25 + Vector + RRF
第 10 周 Rerank + ACL TopK Recall + Rerank + 权限过滤
第 11 周 Context / Memory Redis Session + Context Compression
第 12 周 Agent 工程层 ES、Redis、重试、幂等、限流、锁
第 13 周 Agentic RAG + Multi-Agent Supervisor / Orchestrator Worker
第 14 周 Kafka + Trace + Evaluation 异步任务 + Agent Trace + Eval
第 15 周 Harness / Coding Agent Mini Coding Agent
第 16 周 Security + 综合面试 生产架构图 + 项目复盘 + 模拟面试

4. 第 1~2 周:LLM 与 Agent 基础

4.1 第 1 周:LLM 基础

必须理解

text 复制代码
LLM
Prompt
System Message
User Message
Assistant Message
Token
Context Window
Temperature
Structured Output
Embedding
Tool
Function Calling

LLM 可以先简单理解成:

text 复制代码
输入 Prompt
    ↓
模型推理
    ↓
输出文本 / JSON / Tool Call

LLM 本身并不天然拥有:

  • 数据库能力
  • 文件操作能力
  • 浏览器能力
  • Shell 能力
  • 长期记忆
  • 自动循环执行能力

这些能力通常由 Agent Runtime 提供。

第 1 周必须完成

写一个 Python Demo:

text 复制代码
用户输入
   ↓
调用 LLM
   ↓
要求 Structured Output
   ↓
返回 JSON

例如:

json 复制代码
{
  "intent": "query_weather",
  "confidence": 0.96
}

面试必须会

  1. LLM 是什么?
  2. Token 是什么?
  3. Context Window 是什么?
  4. Temperature 有什么作用?
  5. Structured Output 为什么比纯文本稳定?
  6. Embedding 和生成式 LLM 有什么区别?
  7. 为什么 LLM 本身不等于 Agent?

4.2 第 2 周:Agent / Workflow / ReAct

Agent 与 Workflow

传统 Workflow:

text 复制代码
A
↓
B
↓
C
↓
D

流程主要由程序员提前规定。

Agent:

text 复制代码
Goal
 ↓
LLM 判断
 ↓
Action
 ↓
Tool
 ↓
Observation
 ↓
重新判断
 ↓
...
 ↓
Final Answer

最重要的公式:

text 复制代码
Agent ≈ LLM + Tools + Context + State + Control Loop

ReAct

核心:

text 复制代码
Reason
  ↓
Act
  ↓
Observe
  ↓
Reason
  ↓
Act

工程实现时,更应该关注:

text 复制代码
当前状态
↓
下一步动作
↓
工具调用
↓
工具结果
↓
下一步状态

Plan-and-Execute

text 复制代码
用户任务
   ↓
Planner
   ↓
生成任务计划
   ↓
Executor
   ↓
执行步骤1
   ↓
执行步骤2
   ↓
...
   ↓
必要时 Replan

ReAct vs Plan-and-Execute

场景 更适合
短任务、探索式任务 ReAct
长任务、多步骤任务 Plan-and-Execute
代码修改、研究任务 Plan + Execute + Replan
简单工具问答 ReAct

必做:手写最小 Agent Loop

不要一开始使用 LangChain。

python 复制代码
messages = [user_message]

for step in range(MAX_STEPS):
    response = call_llm(messages, tools)

    if response.final_answer:
        return response.final_answer

    if response.tool_call:
        result = execute_tool(response.tool_call)
        messages.append(tool_result_to_message(result))

raise RuntimeError("Agent exceeded max steps")

必须增加:

text 复制代码
MAX_STEPS
TIMEOUT
异常退出
Tool Error
Final Answer

面试必须会

  • Agent 和 Workflow 本质区别?
  • 什么场景不应该用 Agent?
  • ReAct 是什么?
  • Plan-and-Execute 是什么?
  • 长任务为什么更适合 Plan-and-Execute?
  • Agent 如何避免无限循环?

5. 第 3 周:Function Calling / Tools

这是 Agent 工程最重要的基础之一。

5.1 Tool Schema

例如:

json 复制代码
{
  "name": "query_customer",
  "description": "根据客户编号查询客户信息",
  "parameters": {
    "type": "object",
    "properties": {
      "customer_id": {
        "type": "string"
      }
    },
    "required": ["customer_id"]
  }
}

必须理解:

text 复制代码
type
required
enum
description
default
nullable
array
object

5.2 Tool 标准链路

#mermaid-svg-Y1Qq4PpN3512yVyu{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-Y1Qq4PpN3512yVyu .error-icon{fill:#552222;}#mermaid-svg-Y1Qq4PpN3512yVyu .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-Y1Qq4PpN3512yVyu .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-Y1Qq4PpN3512yVyu .marker{fill:#333333;stroke:#333333;}#mermaid-svg-Y1Qq4PpN3512yVyu .marker.cross{stroke:#333333;}#mermaid-svg-Y1Qq4PpN3512yVyu svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-Y1Qq4PpN3512yVyu p{margin:0;}#mermaid-svg-Y1Qq4PpN3512yVyu .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu .cluster-label text{fill:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu .cluster-label span{color:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu .cluster-label span p{background-color:transparent;}#mermaid-svg-Y1Qq4PpN3512yVyu .label text,#mermaid-svg-Y1Qq4PpN3512yVyu span{fill:#333;color:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu .node rect,#mermaid-svg-Y1Qq4PpN3512yVyu .node circle,#mermaid-svg-Y1Qq4PpN3512yVyu .node ellipse,#mermaid-svg-Y1Qq4PpN3512yVyu .node polygon,#mermaid-svg-Y1Qq4PpN3512yVyu .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-Y1Qq4PpN3512yVyu .rough-node .label text,#mermaid-svg-Y1Qq4PpN3512yVyu .node .label text,#mermaid-svg-Y1Qq4PpN3512yVyu .image-shape .label,#mermaid-svg-Y1Qq4PpN3512yVyu .icon-shape .label{text-anchor:middle;}#mermaid-svg-Y1Qq4PpN3512yVyu .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-Y1Qq4PpN3512yVyu .rough-node .label,#mermaid-svg-Y1Qq4PpN3512yVyu .node .label,#mermaid-svg-Y1Qq4PpN3512yVyu .image-shape .label,#mermaid-svg-Y1Qq4PpN3512yVyu .icon-shape .label{text-align:center;}#mermaid-svg-Y1Qq4PpN3512yVyu .node.clickable{cursor:pointer;}#mermaid-svg-Y1Qq4PpN3512yVyu .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-Y1Qq4PpN3512yVyu .arrowheadPath{fill:#333333;}#mermaid-svg-Y1Qq4PpN3512yVyu .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-Y1Qq4PpN3512yVyu .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-Y1Qq4PpN3512yVyu .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Y1Qq4PpN3512yVyu .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-Y1Qq4PpN3512yVyu .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Y1Qq4PpN3512yVyu .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-Y1Qq4PpN3512yVyu .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-Y1Qq4PpN3512yVyu .cluster text{fill:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu .cluster span{color:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-Y1Qq4PpN3512yVyu .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-Y1Qq4PpN3512yVyu rect.text{fill:none;stroke-width:0;}#mermaid-svg-Y1Qq4PpN3512yVyu .icon-shape,#mermaid-svg-Y1Qq4PpN3512yVyu .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Y1Qq4PpN3512yVyu .icon-shape p,#mermaid-svg-Y1Qq4PpN3512yVyu .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-Y1Qq4PpN3512yVyu .icon-shape .label rect,#mermaid-svg-Y1Qq4PpN3512yVyu .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Y1Qq4PpN3512yVyu .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-Y1Qq4PpN3512yVyu .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-Y1Qq4PpN3512yVyu :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 是



LLM Tool Call
Schema 校验
权限校验
业务参数校验
执行 Tool
成功?
ToolResult
错误分类
可重试?
Retry
Sanitized Error
回流给 Agent

5.3 必须主动测试的异常

text 复制代码
1. 缺少必填参数
2. 参数类型错误
3. enum 越界
4. 参数格式错误
5. Tool 404
6. Tool 500
7. Tool 502
8. Tool timeout
9. Tool 返回空数据
10. Tool 返回超大结果
11. 重复调用同一个 Tool
12. Agent 无限 Tool Call

错误回流示例

不要直接把完整 StackTrace 喂给模型。

json 复制代码
{
  "error_code": "INVALID_ARGUMENT",
  "field": "database_type",
  "reason": "unsupported value",
  "allowed_values": ["MYSQL", "ORACLE"],
  "retryable": true
}

面试题标准思路

text 复制代码
LLM Tool Call
↓
服务端 Schema Validation
↓
失败
↓
转换为结构化错误
↓
允许 Agent 修正参数后重试
↓
超过次数终止

6. 第 4~5 周:LangChain

LangChain 不需要学几个月。

重点:

text 复制代码
Model
Messages
Prompt
Tools
Structured Output
Agent
Runnable
Middleware
Memory
Streaming

第 4 周产出

至少实现:

text 复制代码
Weather Tool
Calculator Tool
Database Tool
Knowledge Tool

让模型自主选择工具:

text 复制代码
用户
 ↓
LangChain Agent
 ↓
判断 Tool
 ├─ Weather
 ├─ Calculator
 ├─ Database
 └─ Knowledge
 ↓
Tool Result
 ↓
Agent
 ↓
Final

第 5 周重点

理解:

  • Prompt 动态构建
  • Tool 动态注册
  • Structured Output
  • Memory
  • Middleware
  • Streaming
  • Error Handling

核心目标:

理解 LangChain 替你封装了哪些原本需要手写的 Agent Runtime 能力。


7. 第 6~7 周:LangGraph

这是中高级 Agent 面试重点。

7.1 StateGraph 三件套

State

python 复制代码
class AgentState(TypedDict):
    messages: list
    intent: str
    plan: list
    current_step: int
    retry_count: int
    tool_result: dict | None

Node

text 复制代码
intent_node
planner_node
agent_node
tool_node
review_node
final_node

Edge

text 复制代码
A → B
B → C

Conditional Edge

text 复制代码
agent
 ↓
need_tool?
 ├─ yes → tool
 └─ no  → final

7.2 Reducer

多个节点修改同一个 State 字段时,需要定义新旧值如何合并。

例如:

text 复制代码
旧 messages
+
新 messages
=
最终 messages

7.3 防死循环

至少四层:

text 复制代码
1. max_steps
2. retry_count
3. per-node timeout
4. global timeout

高级保护:

text 复制代码
相同 Tool + 相同参数连续调用检测
重复 State Hash 检测
失败原因分类
Fallback

7.4 Checkpoint

保存:

text 复制代码
thread_id
run_id
current_node
state
messages
tool_results
timestamp

用于:

  • 故障恢复
  • HITL
  • 暂停继续
  • Debug
  • Time Travel

7.5 HITL

text 复制代码
Agent
 ↓
准备执行高风险动作
 ↓
Interrupt
 ↓
Checkpoint
 ↓
等待人工
 ↓
Approve / Edit / Reject
 ↓
恢复执行

适合:

text 复制代码
发送邮件
删除数据
提交代码
生产发布
转账
修改权限

7.6 第 7 周必须完成

#mermaid-svg-w5peiyD6II2rrorf{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-w5peiyD6II2rrorf .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-w5peiyD6II2rrorf .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-w5peiyD6II2rrorf .error-icon{fill:#552222;}#mermaid-svg-w5peiyD6II2rrorf .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-w5peiyD6II2rrorf .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-w5peiyD6II2rrorf .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-w5peiyD6II2rrorf .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-w5peiyD6II2rrorf .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-w5peiyD6II2rrorf .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-w5peiyD6II2rrorf .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-w5peiyD6II2rrorf .marker{fill:#333333;stroke:#333333;}#mermaid-svg-w5peiyD6II2rrorf .marker.cross{stroke:#333333;}#mermaid-svg-w5peiyD6II2rrorf svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-w5peiyD6II2rrorf p{margin:0;}#mermaid-svg-w5peiyD6II2rrorf .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-w5peiyD6II2rrorf .cluster-label text{fill:#333;}#mermaid-svg-w5peiyD6II2rrorf .cluster-label span{color:#333;}#mermaid-svg-w5peiyD6II2rrorf .cluster-label span p{background-color:transparent;}#mermaid-svg-w5peiyD6II2rrorf .label text,#mermaid-svg-w5peiyD6II2rrorf span{fill:#333;color:#333;}#mermaid-svg-w5peiyD6II2rrorf .node rect,#mermaid-svg-w5peiyD6II2rrorf .node circle,#mermaid-svg-w5peiyD6II2rrorf .node ellipse,#mermaid-svg-w5peiyD6II2rrorf .node polygon,#mermaid-svg-w5peiyD6II2rrorf .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-w5peiyD6II2rrorf .rough-node .label text,#mermaid-svg-w5peiyD6II2rrorf .node .label text,#mermaid-svg-w5peiyD6II2rrorf .image-shape .label,#mermaid-svg-w5peiyD6II2rrorf .icon-shape .label{text-anchor:middle;}#mermaid-svg-w5peiyD6II2rrorf .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-w5peiyD6II2rrorf .rough-node .label,#mermaid-svg-w5peiyD6II2rrorf .node .label,#mermaid-svg-w5peiyD6II2rrorf .image-shape .label,#mermaid-svg-w5peiyD6II2rrorf .icon-shape .label{text-align:center;}#mermaid-svg-w5peiyD6II2rrorf .node.clickable{cursor:pointer;}#mermaid-svg-w5peiyD6II2rrorf .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-w5peiyD6II2rrorf .arrowheadPath{fill:#333333;}#mermaid-svg-w5peiyD6II2rrorf .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-w5peiyD6II2rrorf .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-w5peiyD6II2rrorf .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-w5peiyD6II2rrorf .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-w5peiyD6II2rrorf .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-w5peiyD6II2rrorf .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-w5peiyD6II2rrorf .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-w5peiyD6II2rrorf .cluster text{fill:#333;}#mermaid-svg-w5peiyD6II2rrorf .cluster span{color:#333;}#mermaid-svg-w5peiyD6II2rrorf div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-w5peiyD6II2rrorf .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-w5peiyD6II2rrorf rect.text{fill:none;stroke-width:0;}#mermaid-svg-w5peiyD6II2rrorf .icon-shape,#mermaid-svg-w5peiyD6II2rrorf .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-w5peiyD6II2rrorf .icon-shape p,#mermaid-svg-w5peiyD6II2rrorf .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-w5peiyD6II2rrorf .icon-shape .label rect,#mermaid-svg-w5peiyD6II2rrorf .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-w5peiyD6II2rrorf .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-w5peiyD6II2rrorf .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-w5peiyD6II2rrorf :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 是
需要人工审批
完成
START
Intent Router
Planner
Agent
需要工具?
Tools
HITL
Final
END

State 至少:

text 复制代码
messages
intent
plan
tool_result
retry_count
step_count
error

8. 第 8~10 周:RAG

8.1 基本 RAG

text 复制代码
Document
 ↓
Parser
 ↓
Chunk
 ↓
Embedding
 ↓
Vector Store

查询:

text 复制代码
Query
 ↓
Embedding
 ↓
Vector Search
 ↓
TopK
 ↓
LLM

8.2 Chunk 怎么设计

不能只背固定大小。

考虑:

text 复制代码
文档类型
模型 Context
语义完整性
段落结构
标题层级
召回粒度
Reranker 成本

Chunk 太小

优点:

  • 召回更精准

缺点:

  • 上下文断裂
  • 语义不完整

Chunk 太大

优点:

  • 上下文完整

缺点:

  • 噪声多
  • Embedding 表达被稀释
  • Token 成本高

Overlap

作用:

防止重要信息刚好被切在 Chunk 边界。

过大则:

  • 存储增大
  • 重复召回
  • Rerank 成本增加

9. Hybrid Search:BM25 + Vector + RRF

9.1 为什么不能只用 Embedding

Vector Search 擅长:

text 复制代码
语义相似
同义表达
自然语言问题

BM25 在以下场景常常更稳:

text 复制代码
产品代码
合同编号
错误码
人名
缩写
特殊术语
精确字符串

因此:

text 复制代码
BM25
+
Vector
=
Hybrid Search

9.2 推荐流程

#mermaid-svg-fHS1Q7dTxSgo7LLA{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-fHS1Q7dTxSgo7LLA .error-icon{fill:#552222;}#mermaid-svg-fHS1Q7dTxSgo7LLA .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-fHS1Q7dTxSgo7LLA .marker{fill:#333333;stroke:#333333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .marker.cross{stroke:#333333;}#mermaid-svg-fHS1Q7dTxSgo7LLA svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-fHS1Q7dTxSgo7LLA p{margin:0;}#mermaid-svg-fHS1Q7dTxSgo7LLA .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .cluster-label text{fill:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .cluster-label span{color:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .cluster-label span p{background-color:transparent;}#mermaid-svg-fHS1Q7dTxSgo7LLA .label text,#mermaid-svg-fHS1Q7dTxSgo7LLA span{fill:#333;color:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .node rect,#mermaid-svg-fHS1Q7dTxSgo7LLA .node circle,#mermaid-svg-fHS1Q7dTxSgo7LLA .node ellipse,#mermaid-svg-fHS1Q7dTxSgo7LLA .node polygon,#mermaid-svg-fHS1Q7dTxSgo7LLA .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .rough-node .label text,#mermaid-svg-fHS1Q7dTxSgo7LLA .node .label text,#mermaid-svg-fHS1Q7dTxSgo7LLA .image-shape .label,#mermaid-svg-fHS1Q7dTxSgo7LLA .icon-shape .label{text-anchor:middle;}#mermaid-svg-fHS1Q7dTxSgo7LLA .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .rough-node .label,#mermaid-svg-fHS1Q7dTxSgo7LLA .node .label,#mermaid-svg-fHS1Q7dTxSgo7LLA .image-shape .label,#mermaid-svg-fHS1Q7dTxSgo7LLA .icon-shape .label{text-align:center;}#mermaid-svg-fHS1Q7dTxSgo7LLA .node.clickable{cursor:pointer;}#mermaid-svg-fHS1Q7dTxSgo7LLA .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .arrowheadPath{fill:#333333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-fHS1Q7dTxSgo7LLA .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-fHS1Q7dTxSgo7LLA .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-fHS1Q7dTxSgo7LLA .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-fHS1Q7dTxSgo7LLA .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .cluster text{fill:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA .cluster span{color:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-fHS1Q7dTxSgo7LLA .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-fHS1Q7dTxSgo7LLA rect.text{fill:none;stroke-width:0;}#mermaid-svg-fHS1Q7dTxSgo7LLA .icon-shape,#mermaid-svg-fHS1Q7dTxSgo7LLA .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-fHS1Q7dTxSgo7LLA .icon-shape p,#mermaid-svg-fHS1Q7dTxSgo7LLA .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-fHS1Q7dTxSgo7LLA .icon-shape .label rect,#mermaid-svg-fHS1Q7dTxSgo7LLA .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-fHS1Q7dTxSgo7LLA .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-fHS1Q7dTxSgo7LLA .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-fHS1Q7dTxSgo7LLA :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} Query
BM25 Top20
Vector Top20
RRF
Top20
Reranker
Top5
LLM

9.3 RRF

RRF 不要求直接比较 BM25 Score 与 Cosine Score。

核心:

根据不同检索器中的排名做融合。


10. Rerank

10.1 Embedding vs Reranker

text 复制代码
Embedding
=
快速粗召回

Reranker
=
精排

Embedding:

text 复制代码
Query → Vector
Document → Vector

然后:

text 复制代码
Cosine Similarity

Reranker:

text 复制代码
(Query, Document)

直接评估相关性,通常更精确但更贵。

典型架构:

text 复制代码
100000 Documents
       ↓
Vector / BM25
       ↓
Top 20~100
       ↓
Reranker
       ↓
Top 3~10
       ↓
LLM

11. RAG 权限:ACL

面试:

普通员工不能查询高管薪酬,ACL 怎么进入检索?

不推荐:

text 复制代码
先召回未授权内容
↓
交给 LLM
↓
最后再过滤

推荐:

text 复制代码
Query
+
user_id
+
department
+
role
+
ACL
        ↓
Retrieval Filter
        ↓
只从有权限文档中召回

文档 Metadata:

json 复制代码
{
  "document_id": "D001",
  "department": "HR",
  "allowed_roles": ["HR_ADMIN"],
  "security_level": 3
}

原则:

权限越靠近数据源越安全。


12. 第 11 周:Context Engineering / Memory

面试题:

用户说"刚才那个改成 MySQL",怎么知道"刚才那个"?

Turn 1:

text 复制代码
创建数据库连接:
host=10.0.0.1
databaseType=ORACLE

Turn 2:

text 复制代码
刚才那个改成 MySQL

Agent 应形成:

text 复制代码
目标实体:
上一轮创建的 database_connection

修改:
databaseType:
ORACLE → MYSQL

必须区分

text 复制代码
Message History
Short-term Memory
Long-term Memory
Agent State
Business State

Message History

原始对话。

Short-term Memory

当前 Session 的短期信息。

Long-term Memory

跨 Session 可复用的重要信息。

Agent State

本次 Run 的运行状态。

Business State

业务系统真实状态,例如:

text 复制代码
订单状态
审批状态
数据库记录

不能只存在模型上下文里。


13. Context Compression

不要:

text 复制代码
300 轮聊天
↓
全部塞给模型

推荐:

text 复制代码
当前用户问题
+
最近 N 轮
+
历史摘要
+
关键事实
+
当前任务状态
+
相关 Tool Result

四层压缩:

text 复制代码
第一层:Sliding Window
第二层:历史 Summary
第三层:关键事实保留
第四层:Tool Result 裁剪

Tool 返回 5000 行数据时:

text 复制代码
Tool
 ↓
结构化过滤
 ↓
只保留必要字段
 ↓
分页 / TopK
 ↓
摘要
 ↓
LLM

14. Redis 在 Agent 中怎么用

Redis 不只是缓存。

text 复制代码
Redis
├── Session State
├── Short-term Memory
├── Tool Result Cache
├── Rate Limit
├── Idempotency
├── Distributed Lock
└── Agent Execution State

示例 Key:

text 复制代码
agent:session:{sessionId}
agent:run:{runId}
agent:tool-cache:{tool}:{hash}
agent:lock:{resource}
agent:rate:{userId}

分布式锁

面试:

多个 Agent 同时抢一个浏览器实例怎么办?

text 复制代码
Agent A
Agent B
Agent C
   ↓
Redis Lock
   ↓
browser-instance-01

需要考虑:

text 复制代码
锁超时
租约
续期
异常释放
唯一 owner token
防误删其他线程锁

不要只回答:

用 Redlock。

要先讨论业务是否必须分布式锁,能否通过资源池、队列、租约服务解决。


15. Elasticsearch 在 Agent 里的作用

除了 BM25:

text 复制代码
全文检索
Metadata Filter
ACL Filter
Vector Search
KNN
Hybrid Search
RRF
日志检索
Trace Search

示例索引:

json 复制代码
{
  "content": "...",
  "content_vector": [0.1, 0.2, 0.3],
  "document_id": "D001",
  "department": "IT",
  "role": "developer"
}

16. Agentic RAG

普通 RAG:

text 复制代码
Query
 ↓
Retrieve
 ↓
LLM

Agentic RAG:

text 复制代码
Query
 ↓
Agent
 ↓
要不要检索?
 ↓
选择数据源
 ↓
Query Rewrite
 ↓
Retrieve
 ↓
判断结果是否足够
 ├─足够 → Answer
 └─不足
      ↓
  Rewrite / Replan
      ↓
  再次 Retrieve

检索失败判断可以综合:

text 复制代码
TopK Score
Reranker Score
文档覆盖度
关键实体覆盖
LLM Judge
规则

必须设置:

text 复制代码
max_retrieval_rounds
max_query_rewrite
global_timeout

17. Multi-Agent

先掌握三种。

Pipeline

text 复制代码
Agent A
 ↓
Agent B
 ↓
Agent C

适合稳定流程。

Supervisor

text 复制代码
          Supervisor
        /     |      \
   Search   Data    Report
   Agent    Agent    Agent

Supervisor 负责:

  • 判断任务
  • 分派 Agent
  • 汇总结果
  • 控制结束

Orchestrator-Worker

text 复制代码
             Planner
                ↓
          Orchestrator
        /      |       \
   Worker1  Worker2  Worker3
        \      |       /
            Aggregate

适合:

text 复制代码
代码仓库并行分析
大量文档解析
多数据源调研
复杂报告生成

18. Agent 通信:State / Redis / Kafka

记住:

text 复制代码
单次 Agent Run 内
→ State

同系统跨实例共享状态
→ Redis / DB

长耗时异步任务
→ MQ

大规模事件流
→ Kafka / RocketMQ

19. Kafka / RocketMQ 在 Agent 中的场景

例如 1000 个 PDF:
#mermaid-svg-Han6cJzzXDRyfw8w{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-Han6cJzzXDRyfw8w .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-Han6cJzzXDRyfw8w .error-icon{fill:#552222;}#mermaid-svg-Han6cJzzXDRyfw8w .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-Han6cJzzXDRyfw8w .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-Han6cJzzXDRyfw8w .marker{fill:#333333;stroke:#333333;}#mermaid-svg-Han6cJzzXDRyfw8w .marker.cross{stroke:#333333;}#mermaid-svg-Han6cJzzXDRyfw8w svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-Han6cJzzXDRyfw8w p{margin:0;}#mermaid-svg-Han6cJzzXDRyfw8w .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-Han6cJzzXDRyfw8w .cluster-label text{fill:#333;}#mermaid-svg-Han6cJzzXDRyfw8w .cluster-label span{color:#333;}#mermaid-svg-Han6cJzzXDRyfw8w .cluster-label span p{background-color:transparent;}#mermaid-svg-Han6cJzzXDRyfw8w .label text,#mermaid-svg-Han6cJzzXDRyfw8w span{fill:#333;color:#333;}#mermaid-svg-Han6cJzzXDRyfw8w .node rect,#mermaid-svg-Han6cJzzXDRyfw8w .node circle,#mermaid-svg-Han6cJzzXDRyfw8w .node ellipse,#mermaid-svg-Han6cJzzXDRyfw8w .node polygon,#mermaid-svg-Han6cJzzXDRyfw8w .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-Han6cJzzXDRyfw8w .rough-node .label text,#mermaid-svg-Han6cJzzXDRyfw8w .node .label text,#mermaid-svg-Han6cJzzXDRyfw8w .image-shape .label,#mermaid-svg-Han6cJzzXDRyfw8w .icon-shape .label{text-anchor:middle;}#mermaid-svg-Han6cJzzXDRyfw8w .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-Han6cJzzXDRyfw8w .rough-node .label,#mermaid-svg-Han6cJzzXDRyfw8w .node .label,#mermaid-svg-Han6cJzzXDRyfw8w .image-shape .label,#mermaid-svg-Han6cJzzXDRyfw8w .icon-shape .label{text-align:center;}#mermaid-svg-Han6cJzzXDRyfw8w .node.clickable{cursor:pointer;}#mermaid-svg-Han6cJzzXDRyfw8w .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-Han6cJzzXDRyfw8w .arrowheadPath{fill:#333333;}#mermaid-svg-Han6cJzzXDRyfw8w .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-Han6cJzzXDRyfw8w .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-Han6cJzzXDRyfw8w .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Han6cJzzXDRyfw8w .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-Han6cJzzXDRyfw8w .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Han6cJzzXDRyfw8w .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-Han6cJzzXDRyfw8w .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-Han6cJzzXDRyfw8w .cluster text{fill:#333;}#mermaid-svg-Han6cJzzXDRyfw8w .cluster span{color:#333;}#mermaid-svg-Han6cJzzXDRyfw8w div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-Han6cJzzXDRyfw8w .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-Han6cJzzXDRyfw8w rect.text{fill:none;stroke-width:0;}#mermaid-svg-Han6cJzzXDRyfw8w .icon-shape,#mermaid-svg-Han6cJzzXDRyfw8w .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-Han6cJzzXDRyfw8w .icon-shape p,#mermaid-svg-Han6cJzzXDRyfw8w .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-Han6cJzzXDRyfw8w .icon-shape .label rect,#mermaid-svg-Han6cJzzXDRyfw8w .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-Han6cJzzXDRyfw8w .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-Han6cJzzXDRyfw8w .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-Han6cJzzXDRyfw8w :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 用户上传1000个PDF
Agent 创建任务
Kafka / RocketMQ
Worker 1
Worker 2
Worker 3
Embedding
Vector DB

需要考虑:

text 复制代码
consumer group
ack
retry
dead-letter queue
幂等
任务状态
重复消费
失败恢复

20. Trace / Evaluation

生产 Agent 必须可观测。

Trace 至少记录

text 复制代码
Trace
├── User Input
├── Prompt / Context
├── Model Call
├── Tool Call
├── Tool Argument
├── Tool Result
├── Retrieval
├── Rerank
├── Agent Decision
├── Error / Retry
├── Token
├── Latency
└── Final Answer

常用指标

text 复制代码
Task Success Rate
Tool Selection Accuracy
Tool Argument Accuracy
Retrieval Recall
Rerank Accuracy
Groundedness
Hallucination Rate
Latency
Token Cost
Loop Steps
Failure Rate

模型升级回归

错误:

text 复制代码
Qwen → GLM
启动成功
= 上线

正确:

text 复制代码
Golden Dataset
     ↓
Qwen
     ↓
记录指标

Golden Dataset
     ↓
GLM
     ↓
记录指标

Compare

比较:

text 复制代码
任务成功率
工具选择准确率
工具参数准确率
RAG Recall
最终答案准确率
P95 latency
Token
Cost
异常率

21. Harness 是什么

可以理解成:

Agent 与真实运行环境之间的一整套控制层。

text 复制代码
                LLM
                 ↓
              Harness
       ┌─────────┼─────────┐
       ↓         ↓         ↓
    Context     Tools      Loop
       ↓         ↓         ↓
  Repo Search  Shell      Retry
  File Select  Git        Timeout
  Compression  Test       Stop

Harness 包括:

text 复制代码
上下文获取
上下文裁剪
工具注册
工具权限
Agent Loop
错误恢复
Token Budget
超时
Sandbox
Trace
审批

22. Coding Agent 上下文怎么裁剪

用户:

text 复制代码
修复 OrderService 的空指针 Bug

推荐:

text 复制代码
Query
 ↓
Repo Search
 ↓
OrderService.java
 ↓
Symbol / Reference Search
 ↓
OrderMapper.java
OrderController.java
相关测试
 ↓
选择相关 Context
 ↓
修改
 ↓
Test
 ↓
失败?
 ↓
按错误补充新的 Context

核心:

Context 是动态检索出来的,不是一次把整个 Repo 全塞进去。


23. Coding Agent 的 Context Compression

可以使用:

text 复制代码
1. 最近操作 Sliding Window
2. 已读文件摘要
3. 关键代码片段保留
4. Tool Result 截断
5. Diff 优先保留
6. 测试错误保留
7. 无关日志丢弃

一个示意性的 Token Budget:

text 复制代码
System Rules        10%
Current Task        10%
Relevant Code       45%
Recent Tool Result  20%
History Summary     10%
Buffer               5%

真实比例需要通过评测调整。


24. Coding Agent Sandbox / Security

AI Coding Agent 可以执行:

text 复制代码
Shell
Git
File
Browser
Database
CI

必须设计:

text 复制代码
Sandbox
Allow List
Deny List
Read Scope
Write Scope
Network Policy
Secret Masking
Least Privilege
Human Approval
Audit

示例:

text 复制代码
git status          ✅
git diff            ✅
mvn test            ✅
pytest              ✅
读取当前项目         ✅

rm -rf /            ❌
cat ~/.ssh/*        ❌
读取生产密钥         ❌
git push main       ❌
DROP DATABASE       ❌
生产发布             需要人工审批

25. CI 中 Agent 权限

不要给:

text 复制代码
全局云账号
长期 Token
生产 DB 密码
SSH 私钥
主分支直接 Push 权限

推荐:

text 复制代码
临时 Credential
最小权限 Token
短 TTL
Sandbox Runner
Secret Mask
Network Restriction
Branch Protection
Human Approval

26. 必做项目一:企业知识库 Agent

最终架构

#mermaid-svg-x5Y1lF1ECZhOva2b{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-x5Y1lF1ECZhOva2b .error-icon{fill:#552222;}#mermaid-svg-x5Y1lF1ECZhOva2b .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-x5Y1lF1ECZhOva2b .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-x5Y1lF1ECZhOva2b .marker{fill:#333333;stroke:#333333;}#mermaid-svg-x5Y1lF1ECZhOva2b .marker.cross{stroke:#333333;}#mermaid-svg-x5Y1lF1ECZhOva2b svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-x5Y1lF1ECZhOva2b p{margin:0;}#mermaid-svg-x5Y1lF1ECZhOva2b .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b .cluster-label text{fill:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b .cluster-label span{color:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b .cluster-label span p{background-color:transparent;}#mermaid-svg-x5Y1lF1ECZhOva2b .label text,#mermaid-svg-x5Y1lF1ECZhOva2b span{fill:#333;color:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b .node rect,#mermaid-svg-x5Y1lF1ECZhOva2b .node circle,#mermaid-svg-x5Y1lF1ECZhOva2b .node ellipse,#mermaid-svg-x5Y1lF1ECZhOva2b .node polygon,#mermaid-svg-x5Y1lF1ECZhOva2b .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-x5Y1lF1ECZhOva2b .rough-node .label text,#mermaid-svg-x5Y1lF1ECZhOva2b .node .label text,#mermaid-svg-x5Y1lF1ECZhOva2b .image-shape .label,#mermaid-svg-x5Y1lF1ECZhOva2b .icon-shape .label{text-anchor:middle;}#mermaid-svg-x5Y1lF1ECZhOva2b .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-x5Y1lF1ECZhOva2b .rough-node .label,#mermaid-svg-x5Y1lF1ECZhOva2b .node .label,#mermaid-svg-x5Y1lF1ECZhOva2b .image-shape .label,#mermaid-svg-x5Y1lF1ECZhOva2b .icon-shape .label{text-align:center;}#mermaid-svg-x5Y1lF1ECZhOva2b .node.clickable{cursor:pointer;}#mermaid-svg-x5Y1lF1ECZhOva2b .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-x5Y1lF1ECZhOva2b .arrowheadPath{fill:#333333;}#mermaid-svg-x5Y1lF1ECZhOva2b .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-x5Y1lF1ECZhOva2b .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-x5Y1lF1ECZhOva2b .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-x5Y1lF1ECZhOva2b .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-x5Y1lF1ECZhOva2b .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-x5Y1lF1ECZhOva2b .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-x5Y1lF1ECZhOva2b .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-x5Y1lF1ECZhOva2b .cluster text{fill:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b .cluster span{color:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-x5Y1lF1ECZhOva2b .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-x5Y1lF1ECZhOva2b rect.text{fill:none;stroke-width:0;}#mermaid-svg-x5Y1lF1ECZhOva2b .icon-shape,#mermaid-svg-x5Y1lF1ECZhOva2b .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-x5Y1lF1ECZhOva2b .icon-shape p,#mermaid-svg-x5Y1lF1ECZhOva2b .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-x5Y1lF1ECZhOva2b .icon-shape .label rect,#mermaid-svg-x5Y1lF1ECZhOva2b .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-x5Y1lF1ECZhOva2b .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-x5Y1lF1ECZhOva2b .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-x5Y1lF1ECZhOva2b :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} User
Intent Router
LangGraph
Knowledge Tool
Database Tool
Business API Tool
RAG Retrieval
BM25
Vector Search
RRF
Reranker
ACL Filter
LLM
Redis Memory
Trace / Evaluation
HITL

第一版

text 复制代码
文档上传
Chunk
Embedding
Vector Search
LLM Answer

第二版

增加:

text 复制代码
BM25
RRF
Reranker
Metadata

第三版

增加:

text 复制代码
LangGraph
Tools
Agentic RAG
Query Rewrite

第四版

增加:

text 复制代码
Redis Memory
ACL
HITL
Trace
Evaluation

第五版

增加:

text 复制代码
Rate Limit
Retry
Timeout
Fallback
Audit Log

做完后可以覆盖大部分面试题:

text 复制代码
Agent vs Workflow
Function Calling
LangGraph
State / Node / Edge
Conditional Edge
RAG
Chunk
BM25
Vector
RRF
Rerank
ACL
Redis
Trace
Eval
HITL
Agentic RAG

27. 必做项目二:Mini Coding Agent

最终目标:

text 复制代码
用户:
"修复这个 Spring Boot Bug"

Agent 自动:
#mermaid-svg-lQQDZi7u7nvOgkap{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;fill:#333;}@keyframes edge-animation-frame{from{stroke-dashoffset:0;}}@keyframes dash{to{stroke-dashoffset:0;}}#mermaid-svg-lQQDZi7u7nvOgkap .edge-animation-slow{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 50s linear infinite;stroke-linecap:round;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-animation-fast{stroke-dasharray:9,5!important;stroke-dashoffset:900;animation:dash 20s linear infinite;stroke-linecap:round;}#mermaid-svg-lQQDZi7u7nvOgkap .error-icon{fill:#552222;}#mermaid-svg-lQQDZi7u7nvOgkap .error-text{fill:#552222;stroke:#552222;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-thickness-normal{stroke-width:1px;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-thickness-thick{stroke-width:3.5px;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-pattern-solid{stroke-dasharray:0;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-thickness-invisible{stroke-width:0;fill:none;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-pattern-dashed{stroke-dasharray:3;}#mermaid-svg-lQQDZi7u7nvOgkap .edge-pattern-dotted{stroke-dasharray:2;}#mermaid-svg-lQQDZi7u7nvOgkap .marker{fill:#333333;stroke:#333333;}#mermaid-svg-lQQDZi7u7nvOgkap .marker.cross{stroke:#333333;}#mermaid-svg-lQQDZi7u7nvOgkap svg{font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:16px;}#mermaid-svg-lQQDZi7u7nvOgkap p{margin:0;}#mermaid-svg-lQQDZi7u7nvOgkap .label{font-family:"trebuchet ms",verdana,arial,sans-serif;color:#333;}#mermaid-svg-lQQDZi7u7nvOgkap .cluster-label text{fill:#333;}#mermaid-svg-lQQDZi7u7nvOgkap .cluster-label span{color:#333;}#mermaid-svg-lQQDZi7u7nvOgkap .cluster-label span p{background-color:transparent;}#mermaid-svg-lQQDZi7u7nvOgkap .label text,#mermaid-svg-lQQDZi7u7nvOgkap span{fill:#333;color:#333;}#mermaid-svg-lQQDZi7u7nvOgkap .node rect,#mermaid-svg-lQQDZi7u7nvOgkap .node circle,#mermaid-svg-lQQDZi7u7nvOgkap .node ellipse,#mermaid-svg-lQQDZi7u7nvOgkap .node polygon,#mermaid-svg-lQQDZi7u7nvOgkap .node path{fill:#ECECFF;stroke:#9370DB;stroke-width:1px;}#mermaid-svg-lQQDZi7u7nvOgkap .rough-node .label text,#mermaid-svg-lQQDZi7u7nvOgkap .node .label text,#mermaid-svg-lQQDZi7u7nvOgkap .image-shape .label,#mermaid-svg-lQQDZi7u7nvOgkap .icon-shape .label{text-anchor:middle;}#mermaid-svg-lQQDZi7u7nvOgkap .node .katex path{fill:#000;stroke:#000;stroke-width:1px;}#mermaid-svg-lQQDZi7u7nvOgkap .rough-node .label,#mermaid-svg-lQQDZi7u7nvOgkap .node .label,#mermaid-svg-lQQDZi7u7nvOgkap .image-shape .label,#mermaid-svg-lQQDZi7u7nvOgkap .icon-shape .label{text-align:center;}#mermaid-svg-lQQDZi7u7nvOgkap .node.clickable{cursor:pointer;}#mermaid-svg-lQQDZi7u7nvOgkap .root .anchor path{fill:#333333!important;stroke-width:0;stroke:#333333;}#mermaid-svg-lQQDZi7u7nvOgkap .arrowheadPath{fill:#333333;}#mermaid-svg-lQQDZi7u7nvOgkap .edgePath .path{stroke:#333333;stroke-width:2.0px;}#mermaid-svg-lQQDZi7u7nvOgkap .flowchart-link{stroke:#333333;fill:none;}#mermaid-svg-lQQDZi7u7nvOgkap .edgeLabel{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-lQQDZi7u7nvOgkap .edgeLabel p{background-color:rgba(232,232,232, 0.8);}#mermaid-svg-lQQDZi7u7nvOgkap .edgeLabel rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-lQQDZi7u7nvOgkap .labelBkg{background-color:rgba(232, 232, 232, 0.5);}#mermaid-svg-lQQDZi7u7nvOgkap .cluster rect{fill:#ffffde;stroke:#aaaa33;stroke-width:1px;}#mermaid-svg-lQQDZi7u7nvOgkap .cluster text{fill:#333;}#mermaid-svg-lQQDZi7u7nvOgkap .cluster span{color:#333;}#mermaid-svg-lQQDZi7u7nvOgkap div.mermaidTooltip{position:absolute;text-align:center;max-width:200px;padding:2px;font-family:"trebuchet ms",verdana,arial,sans-serif;font-size:12px;background:hsl(80, 100%, 96.2745098039%);border:1px solid #aaaa33;border-radius:2px;pointer-events:none;z-index:100;}#mermaid-svg-lQQDZi7u7nvOgkap .flowchartTitleText{text-anchor:middle;font-size:18px;fill:#333;}#mermaid-svg-lQQDZi7u7nvOgkap rect.text{fill:none;stroke-width:0;}#mermaid-svg-lQQDZi7u7nvOgkap .icon-shape,#mermaid-svg-lQQDZi7u7nvOgkap .image-shape{background-color:rgba(232,232,232, 0.8);text-align:center;}#mermaid-svg-lQQDZi7u7nvOgkap .icon-shape p,#mermaid-svg-lQQDZi7u7nvOgkap .image-shape p{background-color:rgba(232,232,232, 0.8);padding:2px;}#mermaid-svg-lQQDZi7u7nvOgkap .icon-shape .label rect,#mermaid-svg-lQQDZi7u7nvOgkap .image-shape .label rect{opacity:0.5;background-color:rgba(232,232,232, 0.8);fill:rgba(232,232,232, 0.8);}#mermaid-svg-lQQDZi7u7nvOgkap .label-icon{display:inline-block;height:1em;overflow:visible;vertical-align:-0.125em;}#mermaid-svg-lQQDZi7u7nvOgkap .node .label-icon path{fill:currentColor;stroke:revert;stroke-width:revert;}#mermaid-svg-lQQDZi7u7nvOgkap :root{--mermaid-font-family:"trebuchet ms",verdana,arial,sans-serif;} 否

Bug 描述
Repo Search
Read Relevant Files
Planner
Edit
Run Tests
通过?
Analyze Error
git diff
Final Report

Tool

text 复制代码
list_files
search_code
read_file
write_patch
run_command
run_test
git_diff

必须增加:

text 复制代码
max_steps
timeout
retry
sandbox
command whitelist
context compression
trace
human approval

高级版本再增加:

text 复制代码
Planner Agent
Coder Agent
Reviewer Agent
Test Agent

原则:

先完成 Single Agent,再做 Multi-Agent。


28. 推荐学习资源

优先官方资料。

S 级:必须学

Hugging Face AI Agents Course

https://huggingface.co/learn/agents-course/en/unit0/introduction

重点:

text 复制代码
Agent 基础
Tools
Thought / Action / Observation
Framework
LangGraph
Agentic RAG
Evaluation

建议:

第 1~3 周。

LangChain Academy

LangGraph Essentials:

https://academy.langchain.com/courses/langgraph-essentials-python

重点:

text 复制代码
Nodes
Edges
Conditional Edges
Memory
Interrupt
Human In The Loop

建议:

第 6~7 周。

LangGraph 官方文档

https://docs.langchain.com/oss/python/langgraph/overview

重点:

text 复制代码
StateGraph
Persistence
Checkpoint
Memory
Interrupt
HITL

DeepLearning.AI:AI Agents in LangGraph

https://www.deeplearning.ai/courses/ai-agents-in-langgraph

重点:

text 复制代码
手写 Agent
LangGraph 重构
Agentic Search
Persistence

OpenAI Agents SDK

https://openai.github.io/openai-agents-python/

重点:

text 复制代码
Agents
Tools
Handoffs
Guardrails
Sessions
Tracing

学习目的:

观察现代 Agent Runtime 是如何设计的。


A 级:RAG

https://www.elastic.co/docs/solutions/search/hybrid-search

重点:

text 复制代码
BM25
Vector
Hybrid Search
RRF

Redis Agent Memory

https://redis.io/docs/latest/develop/use-cases/agent-memory/

重点:

text 复制代码
Working Memory
Long-term Memory
Event Log
Session

LangSmith Evaluation

https://docs.langchain.com/langsmith/evaluation

重点:

text 复制代码
Offline Evaluation
Online Evaluation
Dataset
Evaluator
LLM-as-Judge
Regression

Anthropic:Building Effective AI Agents

https://resources.anthropic.com/building-effective-ai-agents

重点:

text 复制代码
Workflow vs Agent
Single Agent
Multi-Agent
Sequential
Parallel
Evaluator-Optimizer
Context

B 级:辅助学习

可以使用:

text 复制代码
Bilibili
CSDN
掘金
GitHub
YouTube

正确方法:

text 复制代码
遇到概念
↓
短视频辅助理解
↓
回官方文档确认
↓
自己写代码验证

不要:

text 复制代码
只收藏教程
不写代码

29. 推荐学习顺序

严格按照:

text 复制代码
Hugging Face Agent Course
        ↓
手写 Agent Loop
        ↓
Function Calling
        ↓
LangChain
        ↓
LangGraph
        ↓
RAG
        ↓
Elasticsearch Hybrid Search
        ↓
Rerank
        ↓
Redis Memory
        ↓
Agentic RAG
        ↓
Multi-Agent
        ↓
Kafka / MQ
        ↓
LangSmith Evaluation
        ↓
Harness
        ↓
Coding Agent

不要基础没打稳就先学:

text 复制代码
Multi-Agent
复杂 Harness
各种"Agent OS"

30. 每天怎么学

工作日推荐:

text 复制代码
20 分钟:理论
40 分钟:官方 Demo
40 分钟:自己写代码
20 分钟:面试题复盘

总计约 2 小时。

只有 1 小时:

text 复制代码
15 分钟理论
35 分钟 Coding
10 分钟总结

31. 每周固定产出

每周必须有:

text 复制代码
01_notes.md
02_demo/
03_interview_questions.md
04_weekly_review.md

例如:

text 复制代码
week07-langgraph/
├── notes.md
├── stategraph-demo/
├── checkpoint-demo/
├── hitl-demo/
├── interview_questions.md
└── weekly_review.md

32. 每个技术点的 10 步学习法

text 复制代码
1. 它是什么?
2. 为什么需要?
3. 不用会发生什么?
4. 自己写 Demo。
5. 放入综合项目。
6. 故意制造异常。
7. 加监控。
8. 加评测。
9. 总结替代方案。
10. 整理成面试回答。

33. 面试回答模板

不要只回答定义。

推荐结构:

text 复制代码
1. 先说结论
2. 解释原理
3. 说项目怎么做
4. 说为什么这样选
5. 说异常怎么处理
6. 说生产环境怎么保障

例如:

为什么不用纯 Vector Search?

回答:

text 复制代码
结论:
我们采用 Hybrid Search。

原因:
Vector 擅长语义检索,
BM25 对产品代码、错误码、精确关键词更稳定。

实现:
BM25 Top20 + Vector Top20
↓
RRF
↓
Top20
↓
Reranker
↓
Top5

生产保障:
ACL 在检索阶段过滤,
并记录 retrieval trace。

评估:
用 Golden Dataset 对 Recall@K、MRR、
最终回答正确率做回归。

34. 截图面试题知识点对照

Agent / Workflow

text 复制代码
Agent vs Workflow
什么时候不用 Agent
ReAct
Plan-and-Execute
Agent Loop
max_steps
timeout

意图识别

text 复制代码
规则路由
轻量分类模型
LLM Routing
Confidence
Threshold
Fallback

边界:

text 复制代码
高确定性 + 高频
→ 规则 / 小模型

复杂语义
→ LLM

低置信度
→ 反问 / fallback

多轮指代

text 复制代码
Conversation State
Entity State
Reference Resolution
Session Memory
Context Compression

RAG

text 复制代码
Chunk
Overlap
Embedding
BM25
Vector
Hybrid
RRF
Reranker
ACL

LangGraph

text 复制代码
StateGraph
Node
Edge
State
Reducer
Conditional Edge
Checkpoint
Interrupt
HITL

Multi-Agent

text 复制代码
Supervisor
Orchestrator-Worker
Pipeline
Shared State
Message Bus

工程化

text 复制代码
Redis
Kafka
RocketMQ
Elasticsearch
Retry
Timeout
Rate Limit
Idempotency
Distributed Lock
Circuit Breaker

Trace / Eval

text 复制代码
Run
Trace
Span
Tool Accuracy
Task Success
Retrieval Recall
Groundedness
Latency
Token
Cost
Regression

Harness / Coding Agent

text 复制代码
Repo Search
Context Selection
Context Compression
Tool Runtime
Sandbox
Permission
CI
Secret
Human Approval

35. 算法准备

重点:

text 复制代码
HashMap
Stack
Queue
LinkedList
Binary Search
Two Pointers
Sliding Window
DFS
BFS
Heap
TopK
LRU
字符串

优先题型:

text 复制代码
括号匹配
最长合法括号
LRU
TopK
滑动窗口
二叉树 BFS
二叉树 DFS
字符串处理

建议:

每天 1 道,持续 3~4 个月。


36. 第 16 周最终验收标准

Agent

  • Agent 与 Workflow 区别?
  • 什么情况不应该用 Agent?
  • ReAct 和 Plan-and-Execute 怎么选?
  • 怎么防 Agent 死循环?
  • Agent Loop 怎么手写?

Tool

  • Function Calling Schema 怎么设计?
  • 参数错如何重试?
  • Tool Timeout 怎么处理?
  • Tool 502 怎么处理?
  • 为什么不能把 StackTrace 全喂给 LLM?

LangGraph

  • State / Node / Edge 分别是什么?
  • Reducer 是什么?
  • Conditional Edge 怎么写?
  • Checkpoint 有什么作用?
  • HITL 怎么暂停和恢复?

RAG

  • Chunk Size 怎么选?
  • Overlap 为什么存在?
  • BM25 和 Vector 各自优势?
  • RRF 为什么适合融合?
  • Reranker 放在哪?
  • 为什么不能只用 Embedding?
  • ACL 在哪里过滤?

Memory

  • Short-term 和 Long-term Memory 区别?
  • Redis 在 Agent 中存什么?
  • 多轮"刚才那个"怎么处理?
  • Context 太长怎么压缩?

Multi-Agent

  • Supervisor 和 Orchestrator-Worker 区别?
  • 什么场景不需要 Multi-Agent?
  • State、Redis、Kafka 怎么选?

Evaluation

  • Tool Accuracy 怎么计算?
  • Task Success Rate 怎么评估?
  • 模型升级为什么必须跑 Regression?
  • Golden Dataset 怎么做?

Coding Agent

  • 为什么不能整个 Repo 塞进 Prompt?
  • Repo Context 怎么动态选择?
  • Sandbox 怎么做?
  • CI 密钥怎么保护?
  • Agent 写代码后怎么验证?

37. 简历表达模板

做完"企业知识库 Agent"以后,可以整理成:

text 复制代码
负责企业知识库 AI Agent 设计与落地,
基于 LangGraph 构建状态驱动 Agent Runtime,
实现 Tool Calling、Checkpoint、HITL 和异常恢复。

RAG 检索采用 BM25 + Vector Hybrid Retrieval,
通过 RRF 融合后使用 Cross-Encoder Reranker 精排,
并在 Retrieval 阶段结合 ACL Metadata Filter 实现权限隔离。

使用 Redis 管理 Session / Agent State / Tool Cache,
建立 Trace 和 Golden Dataset 评估体系,
对 Tool Selection、Tool Argument、Retrieval Recall、
Task Success Rate 和 P95 Latency 进行持续回归。

注意:

简历只写真正做过、能展开回答的内容。


38. 推荐项目目录

text 复制代码
ai-agent-learning/
│
├── 01-llm-basics/
├── 02-agent-loop/
├── 03-function-calling/
├── 04-langchain/
├── 05-langgraph/
├── 06-rag/
├── 07-hybrid-search/
├── 08-reranker/
├── 09-memory/
├── 10-agentic-rag/
├── 11-multi-agent/
├── 12-engineering/
├── 13-evaluation/
├── 14-coding-agent/
│
├── projects/
│   ├── enterprise-knowledge-agent/
│   └── mini-coding-agent/
│
├── interview/
│   ├── agent.md
│   ├── rag.md
│   ├── langgraph.md
│   ├── engineering.md
│   └── coding-agent.md
│
└── README.md

39. 现在应该从哪里开始

不要同时开:

text 复制代码
LangGraph
RAG
Multi-Agent
Kafka
MCP
Harness

先按关卡推进:

text 复制代码
第 1 关:
LLM / Message / Structured Output

        ↓

第 2 关:
手写 Agent Loop

        ↓

第 3 关:
Function Calling

        ↓

第 4 关:
Tool Error Handling

        ↓

第 5 关:
LangChain

        ↓

第 6 关:
LangGraph

        ↓

第 7 关:
RAG

        ↓

第 8 关:
Hybrid Search + Rerank

        ↓

第 9 关:
Memory / Context

        ↓

第 10 关:
Agentic RAG / Multi-Agent

        ↓

第 11 关:
Trace / Evaluation

        ↓

第 12 关:
Harness / Coding Agent

40. 学习完成后的真正标准

不是"知道名词"。

而是能够像下面这样回答:

为什么不能只用 Embedding?

text 复制代码
我们第一阶段召回采用 BM25 + Vector Search。

BM25 对产品代码、专有名词、错误码和精确关键词更稳定,
Embedding 对自然语言语义表达更有优势。

由于两种检索器的分数空间不同,
没有直接把 BM25 score 与 cosine score 相加,
而是使用 RRF 按排名融合。

融合后先取 Top20,
再使用 Cross-Encoder Reranker 对 Query-Document 做精排,
最终取 Top5 给 LLM。

ACL 同时在 Retrieval 阶段加入过滤,
避免未授权内容进入候选集合。

最后通过 Golden Dataset 对 Recall@K、
Rerank、最终任务成功率做持续回归。

当你能把大部分问题回答到这个程度,并能对应自己项目里的真实实现时,就真正具备了中高级 AI Agent 工程面试所要求的能力。

相关推荐
小毛驴8501 小时前
前端开发学习路线可以分为几个层次
学习
大模型真好玩1 小时前
DeepSeek Harness 入门很简单(二)——DeepSeek Harness通用设置及Agent预设详解
人工智能·agent·deepseek
江湖十年1 小时前
在 Go 中使用 dyno 包处理动态对象
后端·面试·go
前端世界1 小时前
基于 Linux 的本地 AI 智能问答平台搭建实践 —— Ollama + FastAPI + Nginx 实现本地大模型 Web 服务
linux·运维·人工智能
小小小小钰儿1 小时前
1.2-AI核心理论与术语
人工智能·计算机·网络安全·信息安全·程序员·编程
star learning white1 小时前
STM32入门学习3
stm32·单片机·学习
浔溺1 小时前
al+大数据每日学习笔记31
大数据·笔记·学习
桃西西呀1 小时前
"循环深度"让小模型免费变大?GPT-6 Astra 背后的潜空间推理原理,8 个误读我替你拆了
人工智能·gpt·llm
!!!!8131 小时前
AI Coding学习
学习