Chapter 13–16 · Project Integration

最后四章的意义,不是再学四个 Demo,而是看前面所有能力怎样组合成一个真实 Agent 产品

Travel Agent 教你分层架构,Deep Research 教你长任务与信息合成,Cyber Town 教你独立 Agent 的状态与记忆边界,毕业设计则要求你把这些能力变成一个真正可运行、可评测、可迭代的项目。

Travel产品分层
Agent 只是系统的一层
Deep Research长任务编排
Plan / Search / Notes / Report
Cyber Town多 Agent 状态
Memory / Role / Context
Final Project可运行、可评测
Build → Eval → Iterate

1. 第 13 章:Travel Agent —— 学“产品分层”

真正要拿走的不是旅游业务,而是:Agent 只是一个产品架构层,不应该承担所有逻辑。

Frontend FastAPI Backend Agent Layer Map API Weather API Hotel API LLM / Image

业务逻辑

确定性操作、数据格式、参数校验尽量由普通代码完成。

Agent

负责需要判断、规划、信息综合的部分。

外部服务

地图、天气、搜索等独立封装,不直接散落在 Agent Prompt 里。

Agent 是产品的一层,不是整个产品

2. 第 14 章:Deep Research —— 学“长任务 Agent”

这是综合项目里最值得重点理解的一章,因为它把 Planning、Search、Notes、Context Engineering 和最终综合全部串起来。

Research Goal Planner 拆成结构化 TODO Search 1 Search 2 Search 3 Summary + Note Summary + Note Summary + Note
Plan → Retrieve → Process → Persist → Synthesize

Deep Research 的三个关键角色

🧭

Planner

把开放问题拆成结构化子任务。

🔎

Executor / Search

逐个搜索、过滤、总结,并记录来源。

📝

Report Writer

基于中间 Notes 分层综合,而不是直接吞全部原始网页。

最重要:长任务 Agent 必须“写下来”。Notes、状态文件、结构化摘要可以让 Agent 在多个步骤之间稳定继续,而不是完全依赖聊天历史。

3. 第 15 章:Cyber Town —— 学“多 Agent 的边界”

Cyber Town 的价值不在游戏本身,而在于理解不同 Agent 为什么应该有独立 Role、State、Memory 和 Context。

Research Agent 论文 / 来源 / 结论 Code Agent 代码 / 环境 / 测试 Evaluation Agent 指标 / 对比 / 结果 独立 Memory / State 独立 Memory / State 独立 Memory / State
Agent Boundary ≈ Responsibility + State + Context + Memory Boundary
不要为了高级而过早 Multi-Agent。如果单 Agent + Tools 已经足够,拆成多个 Agent 只会增加协调复杂度。职责确实独立时再拆。

4. 三类项目真正共同的规律

分层

UI、API、Agent、Service、Tool 各司其职。

结构化

状态、任务、结果尽量结构化,不靠自由文本硬撑。

持久化

长任务要有 Notes、State、Checkpoint。

评测

项目不是“能跑 Demo”,而是要有 Eval Dataset 和指标。

LLM 负责判断;Code 负责确定性操作;Runtime 负责执行;Eval 负责证明效果

5. 最终项目:科研论文代码复现 Agent

这个项目最适合把整套 Hello-Agents 的知识真正串起来。

User Goal 复现这篇论文的 baseline Reproduction Agent Plan / Decide / Replan Paper Service PDF / 实验设置 Repo Service GitHub / README Runtime Shell / Python / Tests Evaluator Metrics / Gap / Success Notes / Memory 环境 / 错误 / 经验 Structured State 当前步骤 / blocker Eval Dataset 真实 repo / benchmark
Agent = Planner + Tool Use + State + Notes + Evaluator + Replan

6. MVP:第一版只做一个非常具体的任务

不要第一版就做自动找论文、自动找 repo、Multi-Agent、MCP、RL、复杂 UI。先把最小闭环跑通。

输入

paper.pdf + github_repository_url

输出

environment.md experiment_plan.md failures.md results.md reproduction_report.md

MVP 必须完成的 6 件事

从论文中提取实验环境、数据集、模型、关键指标。
读取 repo README / requirements / scripts。
创建或检查运行环境。
运行 baseline,并捕获错误。
根据错误进行有限次修复与重试。
得到指标后与论文结果对比并生成报告。
不要把 MVP 做成“万能科研 Agent”。范围越窄,越容易真正评测,也越容易做出第一个稳定版本。

7. 项目的核心控制循环

while not finished: action = agent.decide( goal=goal, state=state, context=context_builder.build(state) ) result = runtime.execute(action) state.update(result) evaluator_result = evaluator.check(state) if evaluator_result.need_replan: state.plan = planner.replan(state) if evaluator_result.success: finished = True
Plan → Act → Observe → Update State → Evaluate → Replan / Finish

Planner

把长任务拆成当前可执行步骤。

Runtime

真正读文件、执行命令、运行测试。

Evaluator

判断是否成功、是否需要重试或重规划。

8. 推荐目录结构

research-reproduction-agent/ ├── README.md ├── pyproject.toml ├── .env.example │ ├── src/ │ ├── agent.py │ ├── state.py │ ├── planner.py │ ├── context.py │ ├── prompts.py │ │ │ ├── tools/ │ │ ├── paper.py │ │ ├── repository.py │ │ ├── shell.py │ │ ├── files.py │ │ └── notes.py │ │ │ ├── services/ │ │ ├── environment.py │ │ ├── executor.py │ │ └── evaluator.py │ │ │ └── memory/ │ └── store.py │ ├── workspace/ │ ├── paper_notes.md │ ├── environment.md │ ├── failures.md │ └── results.md │ ├── eval/ │ ├── tasks.json │ └── fixtures/ │ └── tests/
结构原则:Agent 决策、工具执行、业务服务、状态、记忆、评测分开。不要把所有逻辑写进一个 agent.py

9. 升级路线:一步一步加,不要一次全上

V1 Single Agent Tools + Eval V2 RAG + Notes Checkpoint V3 Multi-Agent 职责拆分 V4 MCP 标准化工具接入 V5 SFT / RL 有数据再训练
版本目标先不要做什么
V1单 Agent 跑通闭环Multi-Agent / RL
V2增强上下文与持久化复杂协议层
V3按职责拆 Agent无意义的角色扮演
V4工具标准化、可复用为了 MCP 而 MCP
V5基于失败数据训练在没有 Eval / Reward 时硬上 RL

10. Hello-Agents 全书统一总图

User Goal Context Builder State + Memory + RAG + Tools Agent / LLM Plan / ReAct / Reflection Runtime Execute / Retry / Limit Tools / MCP Files / Web / DB / Shell A2A / Agents Specialized Agents Environment Real World State / Memory Evaluator Eval Dataset
Agent System = Model + Tools + Runtime + State + Context + Evaluation

你已经学会的“控制层”

ReAct、Planning、Reflection、Agent Loop。

你已经学会的“系统层”

State、Memory、RAG、MCP、Runtime、Framework。

你已经学会的“工程层”

Eval、Cost、Robustness、项目分层、迭代路线。

真正的“学完”标准:不是把 16 章看完,而是你能自己画出系统、写出最小 Agent Loop、解释每个模块为什么存在,并在真实项目里逐步加能力。