Agent Build智能体搭建 Tutor教程
Playbook操作手册

Every step, in an order that works每一步,按可行的顺序排列

This is one valid order for all steps: each comes after everything it uses. Tick steps as you finish them. Your progress is kept in this browser.这是全部步骤的一种可行顺序:每一步都排在它所依赖的步骤之后。完成一步就勾选一步。进度保存在当前浏览器里。

Before step 1第 1 步之前

Clone the repository and run every lab once against the fake model. This takes about 20 seconds and proves your Python works before any model is involved.克隆仓库,用假模型把所有 lab 运行一遍。大约需要 20 秒,可以在涉及任何模型之前先确认 Python 环境正常。

bash
git clone <your repository url> aitutor && cd aitutor
python3 -m labs.run_all --check
0 / 122 done已完成
  1. Write the memory budget before you choose models先写内存预算,再选模型

    The budget decides the lineup. A lineup chosen first often cannot be resident together, and you find out in production as reload delays.预算决定阵容。先选模型的话,常常发现它们无法同时驻留,而且是在生产环境里通过加载延迟才发现。

    python3 -m labs.m01_inference.budget
  2. 0021. Inference engineering推理工程 · 2Not executed in the labslab 中未执行

    Install the engine and put weights on a dedicated volume安装引擎,把权重放到专用卷上

    It follows the budget because you now know which models to pull. Weights are large and reproducible, so they live apart from the boot disk and from backups.它排在预算之后,因为现在才知道该下载哪些模型。权重很大且可以重新下载,所以要和系统盘、备份分开存放。

  3. 0031. Inference engineering推理工程 · 3Not executed in the labslab 中未执行

    Set the serving parameters on purpose有意识地设定服务参数

    Defaults assume one user and one model. An agent makes many calls per question, so defaults cause evictions and queueing that look like a slow model.默认值假设只有一个用户、一个模型。智能体每回答一个问题要调用很多次,默认值会导致模型被换出和排队,看起来像模型慢。

  4. 0041. Inference engineering推理工程 · 4Not executed in the labslab 中未执行

    Call the endpoint the way every later layer will用后续各层都会用的方式调用端点

    The OpenAI-compatible chat endpoint is the contract for the whole stack. Fix it now and you can swap engines, machines, or providers later by changing a URL.OpenAI 兼容的 chat 接口是整个系统的契约。现在把它定下来,以后换引擎、换机器、换供应商都只需要改一个 URL。

  5. Write one client function and use it everywhere写一个客户端函数,全系统共用

    It comes right after the contract because it is the contract in code. One function means one place to change the URL, the timeout, or the provider.它紧跟在契约之后,因为它就是契约的代码形式。只有一个函数,改 URL、超时或供应商时就只需改一处。

  6. Measure time to first token and tokens per second测量首 token 时间和每秒 token 数

    Measure before tuning. These two numbers explain almost every latency complaint, and each has a different fix.先测量再优化。这两个数字能解释几乎所有延迟问题,而且各自的解法不同。

    python3 -m labs.m01_inference.bench
  7. 0071. Inference engineering推理工程 · 7Not executed in the labslab 中未执行

    Add a second runtime only where it earns its place只在值得的地方增加第二个运行时

    A small fast model handles cheap jobs such as triage, question writing, and judging. It must not compete with the workhorse for a resident slot, which is why it comes after the budget and the measurements.小而快的模型处理分流、出题、裁判这类便宜的任务。它不能和主力模型抢驻留名额,所以要在预算和测量之后再加。

  8. Route by task type, and fail safe按任务类型路由,并且失败时不出错

    Routing comes after the endpoints exist and are measured. A router over unmeasured models sends work to the wrong place with confidence.路由要等端点都存在并测量过之后再做。对没测过的模型做路由,只会自信地把任务送错地方。

    python3 -m labs.m01_inference.router
  9. 0091. Inference engineering推理工程 · 9Not executed in the labslab 中未执行

    Cut latency where it is actually spent在真正耗时的地方降低延迟

    This needs logs from real requests, so it comes after measurement. Tuning earlier usually targets model speed, which is rarely the problem.这一步需要真实请求的日志,所以排在测量之后。过早优化往往盯着模型速度,而那很少是问题所在。

  10. 0101. Inference engineering推理工程 · 10Not executed in the labslab 中未执行

    Keep the engine private让引擎保持私有

    The engine has no authentication. Anything outside your machine must go through the gateway, which is the next module.引擎本身没有身份验证。机器外部的任何访问都必须经过网关,也就是下一个模块。

  11. Decide the public surface确定对外接口

    The surface is what callers depend on. Fix it first, because every later change behind it is free and every change to it breaks someone.对外接口是调用方依赖的东西。要先把它定下来,因为之后改它背后的东西没有代价,而改接口本身一定会影响到别人。

  12. Build the key store建立密钥库

    Identity comes before the handler, because the handler's first act is to ask who is calling.身份在处理函数之前,因为处理函数做的第一件事就是问“谁在调用”。

  13. Write the gateway handler编写网关处理函数

    It needs the key store to exist and the engine contract to forward to. It is the first piece that joins two modules.它需要密钥库已经存在,也需要引擎的契约作为转发目标。这是第一个把两个模块连起来的部件。

  14. Prove each rule with a request用请求逐条验证规则

    A gateway is a list of refusals. Each one is tested before anything is built on top.网关本质上是一组拒绝规则。在其上构建任何东西之前,要逐条测试。

    python3 -m labs.m02_gateway.demo
  15. Issue one key per application每个应用签发一个密钥

    Now that the rules hold, give every caller its own identity. Doing this before building callers means none of them ever shares a key.规则都成立之后,给每个调用方一个独立身份。在开发调用方之前就这么做,就不会出现共用密钥的情况。

  16. Apply the model router in the gateway在网关里应用模型路由

    The gateway is the one place every request passes, so model choice belongs here and callers stay unaware of it.网关是所有请求的必经之路,所以选模型的逻辑放在这里,调用方不需要知道。

    python3 -m labs.m02_gateway.route
  17. 0172. API and gatewayAPI 与网关 · 7Not executed in the labslab 中未执行

    Open one public door只开一个对外入口

    Exposure is last. Only a gateway that already refuses correctly should be reachable from outside.对外暴露放在最后。只有已经能正确拒绝请求的网关,才应该从外部可达。

  18. Fix the folder taxonomy and file names确定目录分类和文件命名

    Path is the first signal every later step uses: the tier rules match on it, and search results cite it. It cannot be added afterward without re-filing everything.路径是后续每一步都会用到的第一个信号:等级规则靠它匹配,检索结果引用它。事后再补就得把所有文件重新归档。

  19. Validate files by content按内容校验文件

    It comes before filing because a bad file that reaches the bank will be chunked, embedded, and returned with confidence. On the reference build 15 files named .pdf were HTML error pages that passed a size check.它排在归档之前,因为坏文件一旦进入知识库,就会被切块、向量化,并被自信地返回。参考系统里有 15 个 .pdf 文件其实是 HTML 错误页,它们通过了文件大小检查。

  20. Write the authority rules编写权威等级规则

    Tiers depend on the taxonomy and are needed by the ledger, so they sit between the two. Retrieval later uses the tier as a small ranking bonus and to choose between duplicate passages.等级依赖目录分类,又是台账需要的字段,所以排在两者之间。之后检索会用等级做小幅排序加分,并在重复段落中做选择。

  21. Create the ledger建立台账

    The ledger is the single record of what exists. Indexing, retirement, and audits all read it, so it has to exist before any of them.台账是“有哪些文档”的唯一记录。索引、退役和审计都读它,所以必须先于它们存在。

  22. Run intake: scan the bank and process the inbox执行入库:扫描知识库并处理收件箱

    This is the first step that uses all three earlier pieces together. It is also the routine you will repeat every week.这是第一个同时用到前面三个部件的步骤,也是你以后每周要重复的例行操作。

    python3 -m labs.m03_knowledge.demo
  23. Retire, do not delete退役,而不是删除

    Retirement needs ledger rows to act on. Keeping the row lets the system explain why a passage vanished and recognize the same file if it is downloaded again.退役需要台账里已有记录。保留这一行,系统就能解释某段内容为什么消失,并在同一文件被再次下载时认出它。

  24. 0243. Knowledge management知识管理 · 7Not executed in the labslab 中未执行

    Add collectors with a relevance filter加入带相关性过滤的采集器

    Automation comes after the manual path works, because a collector only feeds the inbox. Without a filter it fills the bank with off-topic documents that then compete in retrieval.自动化要等手工流程跑通之后再做,因为采集器只是往收件箱送文件。没有过滤的话,它会把跑题的文档塞满知识库,然后在检索中抢位置。

  25. 0253. Knowledge management知识管理 · 8Not executed in the labslab 中未执行

    Add a curated tier for judgment为经验判断增加一个人工整理层

    It is last because it is built from the bank. Source documents state rules. They do not contain your judgment about how the rules apply, and that is often what a question needs.它排在最后,因为它是从知识库里提炼出来的。原始文档陈述规则,但不包含你对规则如何适用的判断,而问题往往需要的正是这个。

  26. Name each kind of state and its owner给每种状态命名,并确定归属

    Decide ownership before creating a single table. A table with two owners is where concurrent-write bugs and privacy leaks start.在建任何一张表之前先确定归属。一张表有两个所有者,正是并发写入问题和隐私泄露的起点。

  27. Open the database so concurrent access works以支持并发访问的方式打开数据库

    Connection settings come before schema because they decide whether a second writer waits or fails. Fixing this after jobs exist means finding it as a corrupted file.连接设置排在建表之前,因为它决定第二个写入方是等待还是失败。等任务都跑起来再改,往往是通过文件损坏才发现问题。

  28. Create the schema, grouped by owner按归属分组建表

    Schema follows ownership. Every later module writes into one of these tables, so they are created once here and never altered ad hoc.表结构由归属决定。后面每个模块都会往其中某张表里写数据,所以在这里一次建好,之后不做临时修改。

    python3 -m labs.m04_state.demo
  29. Define merge rules for run state定义运行状态的合并规则

    This must exist before any code runs two nodes at once. Without it, the second tool result silently replaces the first.在任何代码同时运行两个节点之前,这套规则就必须存在。否则第二个工具的结果会悄悄覆盖第一个。

  30. Test concurrent writers before you depend on them在依赖并发写入之前先测试

    It needs the connection and the schema. It is here, and not in operations, because a failure changes the storage choice.它需要连接和表结构都就绪。放在这里而不是运维模块,是因为一旦失败就要改变存储方案。

  31. Give every background job a cursor给每个后台任务一个游标

    Jobs that read logs come later, in evaluation and self-evolution. The cursor is built now because it is storage, and those jobs assume it.读取日志的任务在后面的评估和自进化模块才出现。游标现在就建好,因为它属于存储层,而那些任务默认它已存在。

  32. Check that learned state can be dropped alone确认学到的状态可以单独清除

    Do this before any learning job exists. It is the test of the ownership boundary, and it is your recovery plan when a learner writes something wrong.要在任何学习任务出现之前做这件事。它检验归属边界是否成立,也是学习任务写错内容时的恢复方案。

  33. Move to Postgres when the workload asks for it当负载需要时迁移到 Postgres

    It is last because the lab database is enough to learn every later module. Move when you have several writers under load, need a vector index over many rows, or need point-in-time recovery.它排在最后,因为 lab 用的数据库足够学完后面所有模块。当你有多个高负载写入方、需要对大量数据建向量索引,或需要按时间点恢复时,再迁移。

    PG_RUN_AS=<ordinary user, only when running as root> python3 -m labs.m05_rag.pg
  34. Chunk with a context line切块时带上上下文行

    Chunking decides what a hit can contain, and the embedding is of the chunk text. It is first because changing it later means re-embedding everything.切块决定一次命中能包含什么,而向量是对块文本计算的。它排第一,因为以后再改就得全部重新向量化。

  35. Embed and load, driven by the ledger由台账驱动,向量化并入库

    Loading joins three earlier modules: the ledger says which files, the embedder turns text into vectors, the schema says where rows go.入库把前面三个模块连在一起:台账决定处理哪些文件,embedding 把文本变成向量,表结构决定数据写到哪里。

    python3 -m labs.m05_rag.demo
  36. Dense search向量检索

    Each side of hybrid search is built and inspected alone before fusion, so you can see what each one finds and misses.混合检索的两路要先各自搭好、单独检查,再做融合,这样才能看清每一路能找到什么、会漏掉什么。

  37. Lexical search关键词检索

    Built next to dense search for comparison. It finds exact tokens that vectors blur: policy numbers, section numbers, rare terms.紧挨着向量检索搭建,便于对比。它能找到向量会模糊掉的精确词:规定编号、章节号、罕见术语。

  38. Fuse the two lists by rank按名次融合两个列表

    Fusion needs both lists. It uses positions and never scores, because cosine similarity and BM25 are on unrelated scales.融合需要两个列表都就绪。它只用名次、不用分数,因为余弦相似度和 BM25 的量纲毫不相干。

  39. Add the authority nudge and collapse duplicates加入权威度微调并合并重复

    Both act on the fused list. They fix two failures you only see once search works: a summary outranking the rule, and one paragraph filling the results.两者都作用于融合后的列表。它们解决的是检索跑通之后才会暴露的两个问题:摘要排在规定原文前面,以及同一段话占满结果。

  40. Build graph edges at index time在索引阶段建立图的边

    Edges are built after loading because they are derived from chunk text. They come after baseline search because you need failing questions to know which edges are worth building.边要在入库之后建,因为它们是从块的正文中提取的。又排在基础检索之后,因为你需要先有答不好的问题,才知道哪些边值得建。

  41. Expand results along the edges沿着边扩展检索结果

    Expansion starts from a hit list, so it follows search. It is bounded, because every added passage costs context.扩展从命中列表出发,所以排在检索之后。它必须有上限,因为每多一个段落都要占用上下文。

  42. Explain empty results and write a trace解释空结果,并记录追踪信息

    This finishes the search function. The agent will call it as a tool next, and an empty result with no explanation is where fabrication starts.这一步让检索函数完整。接下来智能体会把它当工具调用,而没有解释的空结果正是编造的起点。

  43. Production form: Postgres with pgvector生产形态:Postgres 加 pgvector

    Same stages, different engine. It is last because the lab version is enough to build and evaluate everything after it.阶段相同,引擎不同。它排在最后,因为 lab 版本足够搭建和评估后面的所有内容。

    PG_RUN_AS=<ordinary user, only when running as root> python3 -m labs.m05_rag.pg
  44. Decide the tool list on paper先在纸上确定工具清单

    Every tool's schema is sent on every turn, and every extra tool is another way to answer with the wrong instrument. Decide the list before writing any of them.每个工具的 schema 每一轮都要发送,每多一个工具就多一种用错工具的可能。动手写之前先把清单定下来。

  45. Build the registry搭建注册表

    The registry comes before the tools so every tool is born with a schema, a log record, and a size cap. Adding those later to tools that already exist is how some get missed.注册表先于工具,这样每个工具从一开始就有 schema、日志记录和大小上限。等工具都写好了再补,总会有漏掉的。

  46. Write the tools, with diagnostics for empty results编写工具,并为空结果提供诊断

    Tools are written against the registry and wrap the modules below: search from retrieval, and a data source. The diagnostic is written now because the harness and the learner both depend on it.工具基于注册表编写,封装的是下层模块:来自检索模块的 search,以及一个数据源。诊断信息现在就要写,因为 Harness 和学习任务都依赖它。

    python3 -m labs.m06_tools.demo
  47. Check errors, caps, and cost检查错误处理、截断和开销

    These are the properties the loop will rely on without checking. Verify them here, where a failure is one line of output and not a broken conversation.这些是循环会直接依赖而不再检查的特性。在这里验证,出问题只是一行输出;到了循环里,就是一次失败的对话。

  48. Serve the same tools over MCP通过 MCP 提供同一批工具

    It follows the local tools because it wraps them. One implementation then serves every harness, which is what makes the rest of this curriculum portable.它排在本地工具之后,因为它是对本地工具的封装。这样一套实现就能服务所有 Harness,这也是整套课程可以移植的基础。

  49. Call the server the way a client does像客户端那样调用服务

    Test the protocol path before handing the server to a client you do not control.在把服务交给你无法控制的客户端之前,先测试协议这条路径。

    python3 -m labs.m06_tools.mcp_check
  50. 0506. Tools and MCP工具与 MCP · 7Not executed in the labslab 中未执行

    Register the server in each client在各个客户端里注册这个服务

    Last, because each client needs only a config entry pointing at a server that is already tested.放在最后,因为每个客户端只需要一条指向已测试服务的配置。

  51. Build the flat loop and bound it搭建扁平循环并设上限

    The flat loop is the smallest thing that is an agent. It joins the model client and the tool registry. Get it correct and bounded before adding concurrency, because every later feature is a refinement of it.扁平循环是能称为智能体的最小形态。它把模型客户端和工具注册表连在一起。先把它做对、设好上限,再加并发,因为后面的每项功能都是在它之上的改进。

    python3 -m labs.m07_harness.demo
  52. Write the wave executor编写波次执行器

    It follows the flat loop because it is the same behavior with two additions: tool calls in one turn run concurrently, and their results merge safely. It needs the merge rules from the state module.它排在扁平循环之后,因为行为相同,只多了两点:同一轮的工具调用并发执行,结果安全合并。它需要状态模块里的合并规则。

  53. Express the loop as planner and tool nodes把循环表达为规划节点和工具节点

    Now the two pieces meet: the flat loop's logic, run by the wave executor.现在两部分汇合:扁平循环的逻辑,交给波次执行器来运行。

  54. Handle a spent budget as a designed outcome把预算耗尽当作设计内的结果来处理

    It depends on the round counter in the planner. Without it, hitting the limit returns nothing after the user has waited the longest.它依赖规划节点里的轮次计数。没有它的话,达到上限时什么都不返回,而此时用户已经等了最久。

  55. Compose the system prompt from parts分部分组装系统提示词

    Composition has to exist before skills and memory can plug in. It is kept short because the prompt is charged on every turn.先要有组装这一步,技能和记忆才有地方接入。它要保持简短,因为提示词每一轮都计费。

  56. Add hooks before tool execution在工具执行前加入钩子

    Hooks sit inside the tool node, so that node must exist. They enforce policy in code, which holds whatever the model was told.钩子位于工具节点内部,所以工具节点必须先存在。它们用代码强制执行策略,不管模型被告知了什么都有效。

  57. Assemble run(): guard, retry, log, record组装 run():护栏、重试、日志、记录

    This is the last piece because it orders everything else: compose, execute, check, respond, record.这是最后一块,因为它给其余部分排好顺序:组装、执行、检查、响应、记录。

  58. Put cheap deterministic gates in front of the planner在规划节点前放置便宜的确定性关卡

    Triage runs before the planner, so add it once the planner path is stable. It removes whole classes of slow requests.分流在规划节点之前运行,所以等规划路径稳定后再加。它能直接消除几类慢请求。

    python3 -m labs.m07_harness.triage
  59. Write one skill from a real failure从一次真实的失败出发写一个技能

    A skill encodes a correction. Start from a request the agent handled badly in the harness logs, so every line has a reason.技能是把一次纠正固化下来。从 Harness 日志里智能体处理得不好的请求入手,这样每一行都有来由。

  60. Load skill files加载技能文件

    Parsing comes before matching. Keep it trivial so a skill stays a file anyone can edit.先解析,再匹配。解析要足够简单,让技能始终只是一个人人都能编辑的文件。

    python3 -m labs.m08_skills.demo
  61. Write routing examples, including a list for no skill编写路由示例,包括“不需要技能”的列表

    Examples are written before the matcher because the matcher is only as good as they are. The `_none` list is what stops small talk from loading the least-bad skill.先写示例再写匹配器,因为匹配器的效果完全取决于示例。`_none` 列表的作用是防止闲聊时加载“最不差”的那个技能。

  62. Match a request to at most one skill把请求匹配到至多一个技能

    Matching needs skills and examples. It returns one skill or nothing, because stacking skills dilutes each and raises prompt cost.匹配需要技能和示例都就绪。它只返回一个技能或空,因为叠加多个技能会相互稀释,还会增加提示词开销。

  63. Plug the router into the harness把路由器接入 Harness

    This is the join. The harness already has the plug point, so this step is one argument.这是两个模块的连接点。Harness 已经留好了接入点,所以这一步只是传一个参数。

  64. 0648. Skills技能(Skills) · 6Not executed in the labslab 中未执行

    Share the same files with a coding agent让编程智能体共用同一批文件

    Once skills are plain files they can serve more than one harness. Do it after the router works so you know the files are sound.技能既然是普通文件,就能服务多个 Harness。等路由器跑通、确认文件没问题之后再做这一步。

  65. Fix the partition rule确定分区规则

    Decide where the partition comes from before writing any memory code. Every function takes it as its first argument, and retrofitting it is how leaks happen.在写任何记忆代码之前,先确定分区从哪里来。每个函数都把它作为第一个参数,事后再补正是泄露的来源。

  66. Store facts and build the briefing保存事实并生成摘要

    Facts are the simplest memory and the only kind that goes into every prompt, so they are built first and kept small.事实是最简单的记忆,也是唯一会进入每次提示词的那种,所以先做它,并保持精简。

  67. Write the record pipeline, after the answer编写记录流程,放在回答之后

    It needs the fact store. It runs after the answer because the user is waiting for the answer and no one is waiting for the notes.它依赖事实存储。它在回答之后运行,因为用户等的是回答,没有人在等笔记。

  68. Add recall over past turns加入对历史对话的回忆

    Recall needs stored turns, so it follows the pipeline. History is searched on demand because putting it all in the prompt costs every turn.回忆需要已保存的对话,所以排在记录流程之后。历史按需检索,因为全放进提示词的话每一轮都要付费。

  69. Plug memory into the harness and test isolation把记忆接入 Harness 并测试隔离性

    This joins memory to the loop. Isolation is tested here, with two users, before any real user exists.这一步把记忆接到循环上。隔离性就在这里用两个用户测试,赶在任何真实用户出现之前。

    python3 -m labs.m09_memory.demo
  70. Test the three boundaries of recall测试回忆的三条边界

    Each boundary is a line of output. Test them now so a later change that breaks one is caught by the same demo.每条边界对应一行输出。现在就测好,以后哪次改动破坏了其中一条,同一个 demo 就能发现。

  71. Prove a memory failure cannot break an answer证明记忆故障不会破坏回答

    The pipeline claims to be fire and forget. Test the claim by making it fail.记录流程声称自己“发出即不管”。通过让它故意失败来验证这个说法。

  72. Offer recall as a tool bound to one user把回忆做成绑定到单个用户的工具

    Last, because it combines recall with the tool registry. The partition is bound when the tool is created, so the model has no argument through which to ask for another user's history.放在最后,因为它把回忆和工具注册表结合起来。分区在创建工具时就绑定了,所以模型没有任何参数可以用来索取别人的历史。

    python3 -m labs.m09_memory.tool_check
  73. Start from logged failures从日志里的失败案例出发

    A guard written from imagination blocks the wrong things. Start with real answers that were wrong, so each rule has a case it must catch and you can find the cases it must allow.凭想象写的护栏会拦错东西。从真实的错误回答入手,这样每条规则都有它必须拦住的案例,你也能找到它必须放行的情况。

  74. Write the grounding check编写依据检查

    The check is the core and has no dependencies, so it is written and tested alone before it touches the loop.这项检查是核心,而且没有任何依赖,所以先单独写好、测好,再接入循环。

    python3 -m labs.m10_guard.demo
  75. Wrap the check in review(), with modes and exemptions用 review() 封装检查,加入模式和豁免

    The loop needs one function that also knows when not to judge. The exemptions come from your must-allow list.循环需要的是一个函数,它还得知道什么时候不该判断。豁免规则来自你的“必须放行”清单。

  76. Run in observe mode first先以观察模式运行

    Before the guard changes any answer, measure how often it would fire on real traffic and what it would wrongly block.在护栏改变任何回答之前,先测量它在真实流量上会触发多少次、会误拦什么。

  77. Enforce: corrective retry, then fallback强制执行:先纠正重试,再兜底

    This joins the guard to the loop. It follows observation because now you know the guard's false positives.这一步把护栏接到循环上。它排在观察之后,因为此时你已经了解了护栏的误报情况。

  78. Add streaming last最后再加流式输出

    Streaming changes how output leaves the loop and interacts with the guard. Add it when the loop and guard are stable.流式输出会改变结果离开循环的方式,并与护栏相互影响。等循环和护栏稳定后再加。

    python3 -m labs.m07_harness.stream
  79. Add a pre-tool hook for writes为写操作加一个工具前置钩子

    Hooks are the other half: they act before a tool runs. This one is independent of the answer guard and can be built at any point after the harness has its hook list.钩子是另一半:它们在工具运行之前起作用。这一个与回答护栏无关,只要 Harness 有了钩子列表,随时可以搭建。

  80. Keep one regression test per rule每条规则保留一个回归测试

    Last, because every rule now exists. A guard grows one rule at a time, and without tests a new rule breaks an old exemption.放在最后,因为此时所有规则都已存在。护栏是一条一条规则加出来的,没有测试的话,新规则会破坏旧的豁免。

    python3 -m labs.m10_guard.run_tests
  81. Write the human baseline questions编写人工基线问题

    These come first because they must predate your own tooling. Questions written before any learning existed are the only true pre-learning baseline you will ever have.它们排第一,因为必须早于你自己的任何工具。在任何学习发生之前写下的问题,是你唯一能拥有的真正“学习前”基线。

  82. Build a retrieval gold set构建检索标准集

    Retrieval is scored before end-to-end quality because it is deterministic, fast, needs no judge, and is the most common root cause.先给检索打分,再看端到端质量,因为它确定、快速、不需要裁判,而且是最常见的根本原因。

    python3 -m labs.m11_eval.demo
  83. Seal the test material before anything learns在任何学习发生之前封存测试材料

    Sealing must precede the learning loop and cannot be done afterward. Once a learner has read a chunk or seen a question, that item no longer measures generalization.封存必须先于学习循环,而且事后无法补做。学习任务一旦读过某个文本块或见过某道题,它就不再能衡量泛化能力。

  84. Score routing with examples the router never saw用路由器没见过的例子给路由打分

    It is last because it needs the router, and it belongs with the evaluation module's sealed sets. Routing is a separate layer, so it gets its own number.它排在最后,因为需要路由器已就绪,而且要和评估模块的封存集放在一起。路由是独立的一层,所以要有自己的指标。

    python3 -m labs.m08_skills.route_eval
  85. Write the rank metrics编写排名指标

    Metric code follows the gold set because the definitions depend on what a gold item identifies: a chunk, its neighbors, its document.指标代码排在标准集之后,因为指标的定义取决于标准条目标识的是什么:一个文本块、它的相邻块、它所在的文档。

  86. Run variants and append history运行变体并追加历史

    This needs the seal, the score function, and the flags built into retrieval. It is the mechanism that turns every later change into an experiment.这一步需要封存、评分函数,以及检索模块里内置的开关。正是这个机制把之后的每次改动变成一次实验。

  87. Read the table and decide what stays读懂表格,决定保留什么

    A table is not a decision. This step is the discipline: keep a feature only if a number moved.有表格不等于有决定。这一步是纪律:只有指标真的变了,才保留一项功能。

  88. Evaluate the whole agent with mechanical checks用代码检查评估整个智能体

    End-to-end evals come after the layer evals, so when the full score drops you already know which layer to check.端到端评估排在分层评估之后,这样总分下降时你已经知道该检查哪一层。

  89. Repeat, and report the spread重复运行,并报告波动范围

    This is what makes the earlier steps worth doing. It needs a working agent eval, and it comes before you trust any single result.正是这一步让前面的工作有价值。它需要智能体评估已经可用,并且要在你相信任何单次结果之前完成。

  90. Write down what the split is for写下拆分的目的

    Decide before building. A second agent is justified by one of two needs, and each has a test.动手之前先决定。增加第二个智能体只有两种正当理由,每种都有对应的检验方法。

  91. Create narrow workers创建专职子智能体

    Workers come before the orchestrator. A worker is defined by what it cannot reach.先有子智能体,再有编排器。子智能体由“它接触不到什么”来定义。

    python3 -m labs.m12_multi.demo
  92. Fan out, fan in, synthesize扇出、扇入、汇总

    Now the wave executor does for agents what it did for tools. This step reuses it unchanged.现在波次执行器对智能体做的事,和它之前对工具做的一样。这一步原样复用它。

  93. Measure what the split cost测量拆分的代价

    Right after it works, measure it. This is the test you wrote down in the first step.一跑通就测量。这正是第一步里写下的检验。

  94. Build two independent judges搭建两个相互独立的裁判

    The second pattern is independence. It is built here because the learning loop and the evaluation module both call it.第二种模式是独立性。它放在这里搭建,因为学习循环和评估模块都会调用它。

  95. Add model judges with two votes and calibration加入模型裁判:双票制加校准

    Judges are needed for free-text fidelity, and they are models with their own errors. They come late because you calibrate them against the deterministic checks you already have.判断自由文本是否忠实需要裁判,但裁判也是会出错的模型。它们放在后面,因为要用你已有的确定性检查来校准。

    python3 -m labs.m12_multi.calibrate
  96. Calibrate the judges before they remove anything在裁判移除任何内容之前先校准

    A judge that acts is a guard on stored knowledge. Like the answer guard, it runs in report mode first.会执行动作的裁判,就是针对已存储知识的护栏。和回答护栏一样,它要先以只报告的模式运行。

    python3 -m labs.m12_multi.calibrate
  97. Check the four preconditions检查四项前提条件

    This module joins more earlier work than any other. Starting without one of these produces a loop that looks like it is learning.这个模块衔接的前序工作比其他任何模块都多。缺了其中任何一项就开始,得到的只是一个“看起来在学习”的循环。

  98. Observe: find failures that prove themselves观察:找出能自我证明的失败

    Observation is first in the loop. It looks only for shapes that code can confirm, because a loop that learns from a model's opinion of its own answers amplifies its own mistakes.观察是循环的第一步。它只找代码能够确认的模式,因为如果循环从模型对自己回答的看法中学习,只会放大它自己的错误。

  99. Record evidence so repetition cannot pose as support记录证据,不让重复冒充支持

    Evidence is stored before any gate reads it. The key design is the reason this step exists: one row per claim, origin, and day.证据要先存好,关卡才有东西可读。主键的设计正是这一步存在的原因:每个论断、来源、日期只有一行。

  100. Assemble the nightly loop with the eval gate组装夜间循环,并加上评估关卡

    This joins observation, evidence, and the sealed eval. The eval sits between the gate and the write, so a change that passes the day count can still be stopped.这一步把观察、证据和封存评估连在一起。评估位于关卡和写入之间,所以即使天数达标,改动仍然可以被拦下。

  101. Run in report mode and read three days以报告模式运行,查看三天的情况

    Report mode first, for the same reason the guard ran in observe mode: see what it would do before it does it.先用报告模式,理由和护栏先用观察模式一样:在它真正动手之前,先看它会做什么。

    python3 -m labs.m13_evolve.demo
  102. Switch to apply and confirm the change切换到应用模式并确认改动

    Only after reading reports. The change is confirmed three ways: the rules file, the sealed eval, and the behavior on the original question.只有在看过报告之后才做。改动通过三种方式确认:规则文件、封存评估,以及原问题上的行为。

  103. 10313. Self-evolving agents自进化智能体 · 7Not executed in the labslab 中未执行

    Know what the lab does not prove明确 lab 没有证明什么

    Read this before running the loop on a real model. The lab proves the plumbing. It cannot prove the learning.在真实模型上运行循环之前先读这一步。lab 证明了管道是通的,但证明不了学习本身。

  104. 10413. Self-evolving agents自进化智能体 · 8Not executed in the labslab 中未执行

    Extend the loop to learn from documents把循环扩展到从文档中学习

    Log-based learning comes first because it is mechanically checkable. Document learning adds a model that reads, so it adds the two-vote check and the held-out exclusion.先做基于日志的学习,因为它可以机械验证。从文档学习多了一个负责阅读的模型,所以要加上双票核查和留出排除。

  105. 10513. Self-evolving agents自进化智能体 · 9Not executed in the labslab 中未执行

    Keep rollback one command away让回滚只需一条命令

    Last, and required before the loop runs unattended. Every applied change must be reversible without touching anything else.这是最后一步,也是让循环无人值守运行之前的必要条件。每个已应用的改动都必须可以撤销,且不影响其他任何东西。

  106. Map SDK features to parts you built把 SDK 的功能对应到你搭建过的部件

    Read before you install. The map tells you which defaults to check and what to keep outside.先读再装。这张对照表告诉你该检查哪些默认值,以及哪些东西要留在框架之外。

  107. Give every SDK the same endpoint给每个 SDK 同一个端点

    Hold the model constant so differences come from the loop. The gateway from module 2 serves that purpose unchanged.让模型保持不变,这样差异就只来自循环。第 2 模块的网关无需改动就能承担这个角色。

  108. Port the agent to LangGraph把智能体移植到 LangGraph

    First port, because a graph framework is closest to the wave executor you wrote.第一个移植对象选它,因为图框架和你写的波次执行器最接近。

  109. Port the agent to the OpenAI Agents SDK把智能体移植到 OpenAI Agents SDK

    Second port, to see the same parts under different names. Two ports show what is common to SDKs and what is one vendor's choice.第二个移植对象,用来看同样的部件换了名字是什么样子。做两次移植,才能看出哪些是各 SDK 的共性,哪些是某家厂商自己的选择。

  110. Run all three and compare三个都跑一遍并比较

    Now there are three loops over the same tools and endpoint. Compare what each did.现在同样的工具和端点上有了三个循环。比较它们各自做了什么。

    python3 -m labs.m14_sdk.demo
  111. 11114. SDKs and frameworksSDK 与框架 · 6Not executed in the labslab 中未执行

    Port to the Claude Agent SDK through MCP通过 MCP 移植到 Claude Agent SDK

    This port reuses the MCP server from module 6 with no wrapper functions, which shows the second way tools travel. It was not executed in the lab run.这个移植直接复用第 6 模块的 MCP 服务,不需要包装函数,展示了工具迁移的第二种方式。它没有在 lab 运行中实际执行。

  112. Decide what stays outside any SDK决定哪些东西留在任何 SDK 之外

    Last, because the ports show it. What you did not have to rewrite is what you own.放在最后,因为移植过程已经说明了答案。那些不需要重写的东西,就是真正属于你的。

  113. List every service, its port, and its interpreter列出每个服务、它的端口和解释器

    You cannot supervise what you have not listed. The list also exposes two services sharing a port or needing different environments.没列出来的东西无法守护。这份清单还能暴露两个服务共用端口或需要不同运行环境的情况。

  114. 11415. Operations and deployment运维与部署 · 2Not executed in the labslab 中未执行

    Put each service under the supervisor把每个服务交给守护进程

    Supervision is the first operational step because everything after it assumes services come back by themselves.守护是运维的第一步,因为之后的一切都默认服务会自己恢复。

  115. Write one status command写一条状态命令

    After supervision, you need to see state in one place. This is also what the watchdog calls.有了守护之后,你需要在一个地方看到全部状态。看门狗调用的也是它。

    python3 -m labs.m15_ops.demo
  116. Add the busy marker to the server给服务加上忙碌标记

    The marker has to exist before any background job, because it is the only way a job learns that a user is waiting.在任何后台任务出现之前,这个标记就得存在,因为它是任务得知“有用户在等”的唯一途径。

  117. Schedule background work with preemption and a duty cycle用抢占和占空比来调度后台任务

    It needs the marker. It is what lets evals and the learning loop share one machine with live users.它依赖忙碌标记。正是它让评估和学习循环能与在线用户共用一台机器。

  118. Schedule the evals and print one line each给评估排上日程,每项输出一行

    Automation comes after the evals are trusted. Scheduling an eval you do not believe produces a dashboard nobody reads.等评估值得信任之后再自动化。把一个你自己都不信的评估排上日程,只会得到一个没人看的仪表盘。

    python3 -m labs.m15_ops.nightly_evals
  119. Back up what cannot be reproduced, and test the restore备份无法重新生成的东西,并测试恢复

    Backups come once there is state worth keeping. The restore test is part of the same step because an untested backup is a hope.有了值得保留的状态,就该做备份。恢复测试属于同一步,因为没有测试过的备份只是一种希望。

  120. Rotate logs and keep signal apart from noise轮转日志,并把信号与噪音分开

    Other jobs read your logs: self-observation reads them every night. Noise in a log that a job reads is how a signal stops being seen.别的任务会读你的日志:自我观察每晚都读。任务要读的日志里混进噪音,信号就会被淹没。

    python3 -m labs.m15_ops.logs
  121. 12115. Operations and deployment运维与部署 · 8Not executed in the labslab 中未执行

    Wire the nightly window把夜间时间窗串起来

    This joins operations to evaluation and self-evolution. It is last among the runtime steps because it schedules everything built before it.这一步把运维与评估、自进化连在一起。它在运行时步骤里排最后,因为它调度的是之前搭建的一切。

  122. 12215. Operations and deployment运维与部署 · 9Not executed in the labslab 中未执行

    Adopt a change discipline建立改动纪律

    Last, because it governs every change you make from now on to all fifteen modules.放在最后,因为从现在起你对全部十五个模块的每次改动都受它约束。