Abysstree渊林
Back to notes返回笔记

Report专题报告 / 2026-08-28

AI Agents:
A Comprehensive Report
智能体(Agent)专题报告

A comprehensive report on what AI agents are, what they can do, and how to use, evaluate, and govern them as verifiable task systems.一份围绕智能体是什么、能做什么以及如何使用、评测与治理智能体的中文专题报告,重点讨论从模型能力走向可委托、可验证、可治理的任务系统。

什么是智能体 · 智能体能做什么 · 如何使用智能体

重点案例:OpenClaw(龙虾) · Hermes · Claude Code · Codex

核心主线:从“模型能力”走向“可委托、可验证、可治理的任务系统”

内容摘要

本报告围绕三个问题展开:什么是智能体(Agent)、智能体能做什么、如何使用智能体。报告提出,智能体不是单独的模型或聊天界面,而是由模型与 Harness(模型运行和交互层)共同构成、通过观察与动作接口连接环境的任务系统;目标、上下文、工具、记忆、运行时和治理决定这套系统能否把一次回答推进为可验证任务。

能力分析表明,智能体在研究综合、文档与数据处理、软件工程、数字化操作、持续自动化和多智能体协作方面已出现稳定价值,但是否适用取决于结果能否验证、动作能否撤销、权限是否有限以及责任是否清楚。报告给出任务说明书、权限分级、验证设计、记忆分层、技能化和评测方法,强调“先定义完成,再授权执行”。

产品部分以 OpenClaw(龙虾)、Hermes、Claude Code和 Codex为四个观察样本。其中 Claude Code与 Codex作为重点,分别从入口、配置、上下文、扩展、多智能体、长任务、安全、典型工作流和团队落地展开,并吸收用户提供的两份中文教程重点。最后给出选型坐标、组织就绪度、90天路线图和配套模板。

管理摘要:十个关键结论

  1. Agent(智能体)不是模型的同义词,而是把目标、模型、工具、记忆、运行时和治理组合起来的任务系统。

  2. 智能体的关键变化是交互单位从“生成一个答案”转为“在边界内交付一个可验证任务”。

  3. 能力价值取决于反馈质量。代码测试、文件渲染、结构化回读等强反馈,使工程和知识工作更早成熟。

  4. 适用性应由四个条件共同判断:结果可验证、动作可撤销、权限可限制、责任可明确。

  5. 有效使用始于任务工程:先写清交付物、范围、约束、验证、权限和失败处理,再讨论自主程度。

  6. 长期可用性依赖上下文、记忆、技能、工具和多智能体编排,但每增加一层能力也会增加新的治理对象。

  7. 安全不是末端审核,而是从不可信输入、最小权限、沙箱、审批、秘密保护到审计和回滚的完整链条。

  8. OpenClaw与 Hermes体现常驻个人智能体路线;Claude Code与 Codex体现以代码库和可验证变更为核心的工程路线。

  9. Claude Code与 Codex的选型不应停留在功能表,应以真实任务、统一环境、明确预算和失败分类开展对照评测。

  10. 组织落地的顺序应是任务盘点—受控试点—能力固化—规模运营;自主权只能随证据逐步放大。

一句话结论|Agent 的竞争力最终不是“能否行动”,而是能否在可控成本和风险下持续交付可验证结果。

研究问题与报告结构

本材料不把智能体等同于某个模型或某款产品,而是把它视为一种新的任务执行系统:模型负责理解与决策,工具连接真实环境,记忆维持状态,运行时承载持续执行,治理约束权限和责任。

本文围绕三个核心问题展开:什么是智能体(Agent)?智能体能做什么?如何安全、有效地使用智能体?

全文依次讨论范式变化与系统定义、能力地图与适用边界、任务工程与治理、四个产品案例,以及选型、组织落地和趋势判断。

报告的核心判断是:智能体的价值不是“替人聊天”,而是把任务变成可委托、可观察、可验证、可复用和可治理的运行单元。

目录

1. 引论:从对话范式到任务委托

智能体的兴起并非源于单一模型能力的突变,而是模型、工具、运行环境和组织授权共同成熟的结果。人与 AI 的协作单位正在由一次回答逐步转向有边界、有证据的任务交付。

理解这一范式变化,有助于避免把智能体简化为聊天机器人或营销标签,并为后续的系统定义、能力边界与治理讨论建立共同起点。

1.1 为什么是现在:从回答问题到委托任务

聊天机器人通常围绕对话轮次工作:用户提出问题,系统返回答案。无论答案多长,主要产物仍是文本。智能体则围绕目标和状态工作:用户给出想要达到的结果、允许范围与验收条件,系统在运行过程中自行决定下一步,使用工具获取事实或改变环境,并持续判断是否接近完成。

这个区别可以用三种交互范式理解。搜索是“我找信息”,对话是“我问你答”,智能体是“我把任务交给系统,但保留关键控制点”。智能体并不要求完全自治;很多可靠系统恰恰通过人工批准、可撤销操作和阶段性验收把人嵌入执行闭环。

判断标准|如果系统只能生成建议而不能根据真实环境反馈继续行动,它更接近助手;如果系统能在约束范围内连续选择步骤、调用工具并验证结果,它才具备智能体特征。

智能体兴起并非只由模型参数增长推动。真正改变产品形态的是模型开始稳定地调用搜索、代码执行、浏览器、文件系统和企业接口,并能在一次任务中保留状态、读取反馈和继续修正。当推理能力与可操作环境结合,人工智能才从内容生成器变为流程参与者。

这种变化可用三种交互范式概括:搜索把信息交给人筛选,对话把解释与生成交给模型,智能体则把一段受约束的工作委托给系统。委托并不意味着放弃控制,而是把人的注意力从每个操作步骤转移到目标设定、关键决策、权限批准和最终验收。

对组织而言,最重要的信号不是某个演示能否连续运行几十步,而是交付单元是否发生变化:过去采购的是模型调用或聊天席位,现在开始建设任务模板、工具接口、验证脚本、权限策略和运行记录。这些资产共同决定智能体能否进入真实工作。

Agent 的产业意义,在于把人与 AI 的协作单位从“答案”改造成“有边界、有证据的任务”。

资料依据:OpenAI《A practical guide to building agents》;Anthropic《Trustworthy agents in practice》

1.2 技术与组织条件为何同时成熟

模型能力解决的是“能否理解和决策”,工具协议解决的是“能否触及真实系统”,运行时解决的是“能否持续工作”,验证基础解决的是“能否知道做对了没有”,组织准备则决定“能否被授权”。五者缺一,智能体都容易停留在演示阶段。

软件工程率先成熟,是因为代码库、编译器、测试、静态检查和版本控制天然提供反馈。研究与知识工作随后扩展,是因为网页、文档、表格和演示逐渐成为可操作对象。业务流程的推进更慢,原因不是模型不会写文本,而是身份、数据、审批、审计和异常处理更加复杂。

因此,采用智能体不是购买一个更强模型后自动完成的升级。组织需要同步梳理流程、数据接口、验收标准和责任链,把模糊的岗位活动转写为可委托、可观察、可回滚的任务。

智能体落地是模型能力与组织工程共同成熟的结果。

1.3 三个核心问题与四个观察样本

本报告首先回答三个基础问题。第一,什么是智能体,如何与聊天机器人、固定工作流和普通模型区分;第二,智能体能承担哪些任务,哪些能力已经相对成熟,哪些仍受环境和验证限制;第三,如何使用智能体,怎样把任务说明、权限、验证和人工监督组织成可运行方法。

OpenClaw与 Hermes代表常驻个人智能体运行时路线,重视消息渠道、长期记忆、技能和持续运行;Claude Code与 Codex代表工程智能体路线,围绕代码库、终端、IDE、桌面和云环境形成可验证变更。四个样本不是完整市场排名,而是用于观察不同产品如何组合模型、工具、状态和治理。

报告在产品分析后回到共同问题:记忆如何分层,重复流程如何技能化,外部系统如何连接,多智能体如何协作,后台任务如何审计,权限如何逐级放大。这样可以把产品功能表还原为可迁移的方法论。

产品是观察样本,真正要提炼的是可跨产品复用的系统方法。

1.4 证据方法、版本边界与阅读路径

产品能力以官方文档、产品页和更新日志为主要依据;用户提供的《Claude Code完全教程》和《Codex全解》用于补充中文操作路径、界面理解和实践经验;厂商研究和独立论文用于讨论效果、安全和趋势。不同证据回答的问题不同,不能用操作教程证明性能最优,也不能用营销案例替代统一条件下的评测。

智能体产品变化很快。报告将资料检索日期明确为 2026 年 8 月 10 日,对预览、实验性、默认关闭或平台限定的功能进行标注。版本号、定价、平台支持、限额和安全策略在实际部署前仍应重新核验。

管理者可重点阅读第 1—4、7、11—13 章;希望建立使用方法的读者可重点阅读第 5—7 章;关注个人智能体可阅读第 8 章;工程团队应重点阅读第 9 章 Claude Code和第 10 章 Codex,并直接使用附录模板开展试点。

把“产品事实、实践经验、效果证据”分层,是保持报告可靠性的前提。

2. 什么是智能体:系统结构、运行闭环与自主边界

智能体不是单独的模型,而是由目标、模型、工具、记忆、运行时与治理共同构成的任务系统。它围绕目标持续行动,并根据环境反馈调整后续步骤。

系统定义既要解释智能体如何选择和执行动作,也必须同时说明自主程度、人工控制点与责任边界。

2.1 一个可贯穿全文的定义

本报告将智能体定义为:在约束和权限边界内,能够代表用户围绕目标独立选择步骤、使用工具、维护任务状态,并根据环境反馈修正行动的系统。这个定义故意把“模型”放在系统之中,而不是把模型本身等同于智能体。

智能体的工程质量取决于这些组件如何组合。更强的模型可能减少误判,但不能替代正确的工具接口、测试环境、权限策略和审计记录。反过来,一个模型能力适中但运行环境清楚、工具稳定、验收严格的系统,往往比“模型更强但边界模糊”的系统更可靠。

定义中的“代表用户”强调授权关系,“围绕目标”强调任务导向,“独立选择步骤”强调路径并非完全写死,“使用工具和维护状态”强调系统能够接触真实环境,“根据反馈修正”强调闭环,“在权限边界内”则把安全与治理纳入定义本身。

这个定义允许存在不同自主程度。一个只能读取仓库、提出修改计划的系统可以是低自主智能体;一个能够在隔离工作区修改、测试并提交审查的系统自主程度更高;一个长期在线并可跨应用执行的系统需要更严格的身份、权限和审计。

智能体是围绕目标持续行动并根据环境反馈修正的受约束系统。

资料依据:OpenAI《A practical guide to building agents》;Anthropic《Trustworthy agents in practice》

2.2 六个基本组件:目标、模型、工具、记忆、运行时与治理

目标层把用户意图转写为交付物、范围和停止条件;模型层负责理解、推理和下一步选择;工具层提供读取和行动接口;记忆层保存当前状态、项目事实和可复用经验;运行时负责执行、调度、隔离和恢复;治理层定义权限、审批、审计和责任。

六个组件存在短板效应。模型再强,如果工具接口没有清晰参数和错误返回,系统仍会误用;工具再多,如果没有验收标准,系统可能把失败包装成完成;记忆再长,如果内容过时或被污染,反而会放大错误;运行时间再久,如果没有停止条件,只会累积成本和风险。

评估产品时应沿六个组件逐项提问,而不是只比较模型名称。需要了解模型能否切换、工具是否可控、记忆能否查看和纠正、运行环境是否可复现、关键动作是否审批、全过程是否留下证据。

组件 回答的问题 常见失效
目标 要交付什么,何时停止? 任务范围漂移
模型 如何理解并选择下一步? 推理或事实错误
工具 能读什么、做什么? 误调用、接口失败
记忆 当前状态与长期事实如何保存? 过时、污染、泄露
运行时 在哪里执行、如何恢复? 环境不一致、任务失联
治理 谁授权、谁审批、谁负责? 越权、不可追溯

Agent 质量由最弱的系统环节决定,不由模型排行榜单独决定。

2.2.1 Model—Harness—Environment:智能体的三层边界

六个基本组件适合做建设清单;从运行机理看,还可以把智能体压缩为三层关系:Model负责理解、推理与选择下一步,Harness负责构造上下文、暴露工具、维护循环与状态、实施权限和验证,Environment保存真实状态并执行转移。模型与 Harness共同组成智能体,环境位于智能体之外。

这种边界澄清了三个经常混淆的问题。第一,模型并不直接“看见世界”,它只能处理 Harness写入上下文的观察;第二,模型并不直接改变世界,它只能提出工具调用,再由动作接口执行;第三,环境反馈才是事实源,不能用模型的自述代替文件差异、数据库状态、网页回执或测试结果。

因此可以用三条问题检查任何 Agent:它能看见什么,它被允许做什么,它怎样证明做对了。观察范围决定认知边界,动作范围决定能力与风险边界,验证机制决定系统能否从演示走向可靠运行。

层次 核心职责 主要工程对象 典型失效
Model 理解目标、推理、选择下一步 模型、推理预算、输出协议 误解、幻觉、错误策略
Harness 组织上下文、工具、循环、状态、权限和验证 Prompt、Skills、MCP、Hooks、沙箱、评测 上下文污染、工具误用、状态丢失
Environment 保存真实状态并响应动作 文件、数据库、网页、API、应用与用户 并发变化、不可逆副作用、回执不完整

表 2-1 Model—Harness—Environment 的职责与失效边界

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》第2章。

2.2.2 从 Prompt Engineering 到 Harness Engineering

Prompt仍然重要,但生产级 Agent的可靠性不可能只靠一段更长的系统提示。Harness Engineering关注完整控制循环:如何选择和裁剪观察,怎样给模型提供稳定工具契约,如何保存任务状态,何时压缩上下文,哪些动作必须审批,失败后怎样纠正或回滚,以及用什么证据决定停止。

这一转变也解释了为何同一模型在不同产品中表现差异明显:产品把模型包裹在不同的上下文结构、工具集合、权限机制、执行环境和评估闭环中。模型决定潜在策略空间,Harness把潜力转化为可重复交付。

更强模型会吸收一部分原先写在 Harness中的策略,但 Harness不会因此消失。随着能力扩大,新的观察接口、动作接口、业务约束和验证责任会继续外移到系统层。工程重点会从“教模型完成一步”不断迁移到“组织模型安全完成更长任务”。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

2.3 运行闭环:计划、行动、观察、修正与移交

智能体的基本闭环可以写成“理解目标—制定计划—执行动作—观察结果—修正计划—完成或移交”。每一次工具调用都会把新的事实带回系统:命令是否成功、文件是否改变、测试是否通过、接口是否返回预期数据。模型根据这些观察继续推进,而不是假定前一步已经成功。

可靠性来自反馈与验证,而不是一次推理。对于软件任务,观察可能是编译输出、测试日志、静态检查结果和 diff;对于研究任务,观察可能是来源内容、时间戳、数据一致性和引用检查;对于业务流程,观察则可能是系统回执、状态字段和审批结果。

报告插图 1

图 2-1 编码智能体在“人—界面—模型—环境”之间形成可验证反馈闭环

来源:Anthropic, Building effective agents(检索日期:2026-08-10)

  1. 理解任务:识别最终交付物、受众、限制和不可逆风险。

  2. 形成计划:把目标拆成可执行、可检查的中间节点。

  3. 调用工具:在授权范围内读取、计算、编辑或调用外部服务。

  4. 观察结果:把命令输出、文件差异、接口响应等真实证据返回系统。

  5. 修正与重试:根据失败原因调整路径,不把失败包装成成功。

  6. 验收与移交:对照完成标准,汇总结果、风险和下一步。

闭环的每一步都应产生状态变化或新证据。计划不是静态清单,而是当前假设;行动必须通过工具落到环境;观察要读取命令、文件、接口或页面的真实结果;修正要根据失败原因改变路径;移交则对照验收标准说明完成、未完成和风险。

可靠智能体会显式处理失败。命令超时、测试失败、网页结构变化、权限拒绝和来源冲突都不应被压缩成一句“已完成”。系统需要保留失败上下文,判断是重试、换工具、缩小范围还是请求人工输入。

运行闭环也解释了为什么工程智能体发展迅速:编译器、测试、diff和版本控制构成强反馈;而价值判断、战略选择和现实世界高风险操作缺少廉价、客观的反馈,所以更需要人工参与。

可靠性来自观察—修正—验证,而不是一次生成看起来合理。

2.4 聊天机器人、固定工作流与智能体

三者不是互相排斥的产品类别,而是不同控制方式。聊天机器人适合解释、建议和轻量生成;固定工作流适合规则稳定、路径明确且需要高度可预测的任务;智能体适合路径不能完全预设、需要在中间依据新信息做判断的任务。

实际产品通常采用混合架构。智能体负责理解模糊目标、查找信息和提出方案;固定工作流负责付款、生产发布、对外发送、数据删除等高风险环节;聊天界面负责解释过程和接受人工决策。把所有步骤都交给智能体或都写成固定流程,通常都不是最优解。

聊天界面并不自动意味着智能体,非聊天界面也不意味着没有智能体。关键是由谁控制步骤:聊天机器人通常生成回答;固定工作流按预设路径运行;智能体根据当前状态选择下一步。实际系统可以在同一产品中同时使用三种控制方式。

高影响动作适合保留确定性工作流。例如智能体可以收集退款材料、判断是否符合政策并起草意见,但真实付款通过规则引擎和人工审批;智能体可以准备生产发布变更,但部署系统执行固定检查和权限控制。

类型 步骤控制 适合任务 主要风险
聊天机器人 用户逐轮推动 解释、生成、单轮问答 答案貌似正确
固定工作流 开发者预设路径 稳定、重复、规则明确 异常覆盖不足
智能体 系统按状态选择下一步 开放路径、多步骤任务 目标漂移与权限风险
混合系统 智能判断+确定执行 高价值真实流程 边界设计复杂

最可靠的架构通常是“智能判断 + 确定执行 + 人工控制点”的组合。

2.5 自主程度与人类控制点

“是否是智能体”并不等于“是否完全自治”。更有用的方式是把自主程度拆成五级:只读分析、受控写入、工具执行、后台任务和多智能体协作。每一级都应设置独立的验收门,而不是因为上一阶段表现良好就自动获得更高权限。

责任仍然属于组织和用户。智能体可以提出判断、执行步骤和提供证据,但谁授权访问数据、谁批准高影响操作、谁对外发布、谁承担合规责任,必须在流程中明确。人类监督的价值不只是“最后看一眼”,而是决定哪些节点必须由人确认。

自主程度至少包含五个维度:可读取的数据范围、可执行工具、可写入系统、可持续时间和可自行委派的子任务。不同维度可以独立配置,不应把智能体简单分成“自动”与“不自动”。

人类控制点应放在高杠杆节点:目标和成功标准需要人确认;多个方案涉及业务取舍时需要人选择;权限升级、不可逆动作和外部发布需要人批准;结果影响重大时需要独立复核。低风险、可撤销、验证明确的步骤则可以自动执行。

随着系统成熟,控制方式可以从逐步批准转向例外管理,但前提是已有稳定成功率、失败可见性和审计记录。取消人工确认不应先于建立技术边界和评测证据。

自主不是单一开关,而是一组与风险相匹配的授权维度。

2.6 单智能体、多智能体与组织协作

单智能体最容易维护一致目标、上下文和责任,应该成为默认起点。只有当提示逻辑过于复杂、工具高度相似导致选择困难、某些侧任务会产生大量上下文,或任务可清楚并行时,拆分多个智能体才有意义。

常见结构包括管理者模式和对等模式。管理者模式由主智能体持有用户目标,把研究、测试、安全审查等任务作为工具委派;对等模式由多个会话共享任务和相互通信,更适合需要讨论和协商的复杂工作。

多智能体带来的代价包括重复读取、成本上升、版本冲突、结论不一致和合并责任模糊。拆分时要为每个角色定义输入、输出、工具、可编辑范围和验收标准,最终仍需一个明确的合并者。

多智能体是复杂度工具,不是能力展示;能用一个智能体解决时先用一个。

3. 智能体能做什么:能力地图与场景成熟度

智能体已经能够参与研究综合、文档与数据处理、软件工程、数字化操作、持续自动化和多智能体协作,但不同场景的成熟度差异显著。

判断价值不能只看演示中的连续步骤,而应同时考察交付物、反馈强度、验证成本和错误影响。

3.1 六类相对成熟的能力

目前较成熟的智能体能力可以归纳为六类。它们的共同点不是“能生成内容”,而是能把多来源输入、多个中间步骤和验证动作组织成完整任务。

成熟能力的共同特征是输入可以获得、步骤能够执行、结果能够验证。一个系统是否“会总结”并不重要,重要的是它能否找到材料、区分来源、生成交付物、检查格式和证据,并在缺失信息时说明限制。

能力域 典型交付物 验证方式 成熟度
研究综合 带来源的简报/报告 来源覆盖、引用核验 较高
文档与数据 Word/PPT/表格 渲染、公式、抽样核对 较高
软件工程 代码变更与测试 diff、测试、静态检查 较高
数字化操作 跨系统记录或配置 回读、截图、日志 中等
持续自动化 定时监控与通知 运行历史、异常告警 中等
开放现实行动 外部不可逆结果 往往需人工确认 谨慎

用完整任务链描述能力,比用“搜索、总结、写代码”等动词更接近真实价值。

3.2 研究、报告与知识工作

研究型智能体可以围绕问题生成检索策略,浏览网站、文献、更新日志和商业公司页面,提取关键事实,标注来源和时间,再把证据组织为报告、表格或演示。这类任务的价值在于减少资料搬运和格式转换,让人把注意力放在问题设定、证据权重和结论判断上。

但研究智能体最容易出现“引用存在、内容却不支持结论”的问题。因此,验收不能只看是否有链接,而要检查来源是否直接支持相关句子、信息是否过时、不同来源是否互相矛盾,以及商业宣传和独立证据是否被混淆。

高质量研究智能体需要把检索范围、来源优先级、发布日期、相互印证和引用位置写进任务。对于商业产品,官方网站、文档和更新日志往往比论文更及时;对于效果和风险,独立研究、标准和实测更重要。

人类应把精力放在研究问题、证据权重和结论边界。智能体可以覆盖更多来源并统一格式,但不能替代对利益冲突、样本代表性和因果关系的判断。

研究智能体的核心不是抓取更多信息,而是建立可追溯的证据链。

3.3 数字化操作与业务协同

当智能体连接浏览器、邮件、日历、数据库和业务 API 后,它可以读取工单与客户记录,判断问题类型,生成处理建议,更新系统字段并安排跟进。它也能把会议纪要转成任务,把多个渠道的反馈整理成优先级列表,或将表格数据清洗为可用的分析结果。

价值往往来自跨系统衔接。例如客户投诉处理不是写一封回复,而是读取历史工单、识别问题、查找政策、拟定方案、更新 CRM、创建日程并保留审计。越接近真实业务,越要区分“生成草稿”和“正式发送”,“建议更新”和“实际写入”。

跨系统任务通常包括读取状态、解释非结构化内容、选择处理路径、更新记录和安排后续。智能体擅长处理规则之外的异常分支,但写入和外发动作应根据影响等级设置草稿、建议、审批或自动执行。

业务采用的难点在身份和状态一致性。系统必须知道当前代表谁、读取的是哪一版本数据、动作是否真实成功、重复执行是否幂等,以及失败后如何补偿。

业务智能体的价值在跨系统闭环,风险也集中在身份、写入与外发。

3.4 软件工程与可验证变更

软件工程是智能体能力相对成熟的领域,因为代码库提供了结构化上下文,编译器、测试、静态检查和 Git 又提供了强反馈。工程智能体可以从 Issue、错误日志或需求描述出发,定位相关代码,跨文件修改,运行测试,检查 diff,并形成提交或 PR。

真正的价值不在“生成一段代码”,而在于完成一个可复核的工程闭环:它能够解释改了什么、为什么这样改、验证了什么、还有哪些风险。Claude Code 和 Codex都在强化这种从探索到验证的完整工作方式。

代码库提供结构化上下文,工具链提供高密度反馈,版本控制提供审查和回滚。智能体可以完成代码定位、跨文件修改、测试、静态检查、diff审查和 PR准备,结果能被较客观地验收。

工程智能体仍需要领域知识。需求含义、兼容策略、架构取舍和生产风险往往超出测试覆盖。熟悉系统的人能给出更好的边界、证据和反馈,因而产生更高质量结果。

工程智能体最强的不是生成代码,而是把代码变更纳入可验证的工程流程。

3.5 数据分析、表格与多模态交付

数据任务可以从原始表格或导出文件开始,完成字段识别、异常检查、计算、可视化和报告交付。多模态能力使系统能够读取截图、设计稿和扫描文档,并将分析结果写入电子表格、Word或演示文稿。

这类任务的关键是保持数据谱系:原始数据不被覆盖,清洗规则可记录,公式与结果可复算,图表与文字结论一致。视觉交付还需要渲染检查,避免文件结构正确但页面出现遮挡、截断或字体替换。

对于统计结论,智能体应报告样本、口径、缺失值和不确定性,不能只输出一个看似精确的数字。对需要专业模型的分析,应让智能体调用经过验证的代码或工具,而不是依赖语言模型心算。

多模态智能体把分析延伸到最终交付,但必须保留数据谱系和视觉验收。

3.6 持续自动化与后台工作

当任务说明、工具权限和验收标准已经稳定后,智能体可以进入后台或定时运行:检查每日错误日志、汇总每周代码变化、追踪 PR 状态、扫描依赖更新、生成运营报告或监控特定指标。与传统定时脚本相比,智能体能够处理格式变化和异常分支;与即时对话相比,它能够在无人值守时持续推进。

持续自动化的门槛更高,因为错误会重复发生。正式调度前必须先手动运行数轮,确认输入是否稳定、失败是否可见、结果是否可审查、停止条件是否明确。未经观察就把高权限工作交给定时智能体,是最常见的采用错误之一。

后台智能体能够处理输入格式变化和异常分支,但错误也会随频率放大。正式调度前应先手动运行多轮,记录正常、无变化、部分失败和权限不足时的行为,再逐步降低人工观察频率。

每个后台任务要定义报告策略:什么变化值得通知,没有变化时是否静默,连续失败几次停止,结果写到哪里,谁负责恢复。单纯设置一个定时提示而没有运行责任,是把一次性风险变成持续风险。

持续自动化的前提是稳定任务说明、窄权限、可观测失败和明确责任人。

3.7 多智能体协作

多智能体适合能够并行且可独立验收的任务。例如一个智能体研究市场,另一个分析技术方案,第三个做安全审查,主智能体最后汇总。工程场景中,可以让不同子智能体分别探索代码、补测试和审查风险。

并行不是越多越好。子智能体会增加成本、上下文同步和合并难度。只有当任务之间依赖较少、交付边界清楚、失败不会彼此污染时,并行才会真正缩短时间。对高度耦合的代码修改,先由一个主智能体完成整体设计,再分派独立子任务更稳妥。

并行最适合信息源独立、文件范围独立或评价维度独立的工作。研究可按来源或假设分工,开发可按模块分工,审查可按安全、性能、测试和可维护性分工。主智能体负责统一问题、消除冲突和形成最终结论。

若多个智能体都需要不断读取彼此的中间结果,或者同时修改同一核心文件,并行通常不会更快。此时应先由一个角色完成架构和接口设计,再拆分稳定边界。

任务可独立验收,是多智能体产生净收益的基本条件。

3.8 场景成熟度矩阵:价值、可验证性与影响

场景成熟度应由任务条件而不是产品宣传决定。输入是否稳定、环境反馈是否及时、交付物能否独立验证、动作是否可撤销、权限是否可以限制,是判断能否提高自主程度的关键变量。

研究综合和软件工程通常具备较强反馈,因而更容易建立端到端流程;跨系统业务操作的价值可能更高,但身份、审批和异常处理更复杂;开放现实行动一旦不可逆,就应保留更强的人类控制。

成熟度并非固定属性。通过补充结构化输入、回读接口、测试脚本、模拟环境和回滚机制,同一任务可以从“仅供辅助”逐步升级为“受控执行”。反之,环境变化或验证失效也会使成熟度下降。

试点记录应同时保存成功条件与失败条件,避免把单次顺利运行当成普遍能力。只有在不同输入、异常和权限边界下仍能稳定交付,场景成熟度才具有组织意义。

把成熟度判断转化为试点方案时,应先选择范围窄、反馈快且已有人工基线的任务。试点不宜同时更换数据源、业务规则和执行工具,否则成功或失败都难以归因。

试点至少要记录四组指标:完成质量、耗时与成本、人工介入位置、风险与异常。完成率必须与结果正确性分开统计;一次任务看似结束,并不意味着交付物已经满足业务标准。

随后可按风险分层提高自主度。低风险步骤允许自动执行,中等风险步骤设置抽样复核,高风险和不可逆动作保留逐次审批。每提高一级自主度,都要有新的验证证据支撑。

因此,真正可复制的场景不是一段漂亮演示,而是一套包含输入契约、执行边界、验收标准、异常处理和责任人的任务产品。组织应先把任务工程化,再讨论是否扩大智能体权限。

高价值、易验证、低影响的任务最适合先试点,例如公开资料研究、小范围测试补全、内部报告和只读诊断。高价值、易验证但影响较高的任务适合智能体执行、人工批准,例如生产发布准备和客户退款建议。

难验证、影响高的任务不应追求自动完成,智能体更适合作为分析助手或方案生成器。低价值且规则稳定的任务应优先使用脚本和传统工作流,避免为“智能化”引入额外成本。

成熟度不是固定属性。通过补充测试、结构化数据、沙箱、审批和回滚,可以把原本风险较高的场景逐步改造成可委托任务。

任务特征 适用判断 建议方式
结果可验证、动作可撤销、权限有限 优先试点 允许端到端执行
结果可验证但影响较大 有条件适用 关键节点审批
判断主观、证据不完整 辅助使用 生成选项与证据,不代替决策
高风险、不可逆、责任不清 暂不委托 保留人工主导

先改造验证和边界,再提高自主程度,通常比直接追求更强模型有效。

4. 能力边界、失败模式与评价方法

智能体能够扩大可自动化任务的范围,也会引入目标漂移、事实错误、工具误用、环境不一致和越权等新的失败模式。

只有把失败机制、接管条件和评价指标纳入系统设计,能力边界才会从抽象提醒变为可执行的管理规则。

4.1 何时不该使用智能体

规则固定、路径稳定且可以低成本编程的任务,应优先使用脚本或工作流;无法验证结果的任务,应先建立检查机制;付款、生产变更、外部发送和数据删除等高影响任务,在缺乏审批时不应完全自治;大量凭据或敏感数据暴露的任务,应先缩小权限和隔离环境。

场景选择|不要只写“总结、分类、写代码”等孤立动作;把输入、多个中间步骤、最终产物和验证方法写成完整任务,才能发挥智能体优势。

如果任务路径可以低成本写成确定脚本,传统自动化通常更便宜、更稳定;如果没有任何办法判断结果对错,智能体也无法通过闭环改善;如果动作高影响且不可撤销,缺乏审批时不应授权自动执行。

不使用并不等于完全排除智能体。它可以承担前期材料整理、方案比较、风险提示和草稿生成,把最终动作留给固定系统或人。关键是让能力进入合适环节,而不是为了自动化完整流程而自动化。

场景边界比模型能力更能决定项目是否成功。

4.2 认知失败:幻觉、误解目标与过度自信

智能体可能引用不存在的来源、误读用户意图、把局部成功当成整体完成,或在证据不足时给出确定结论。由于它会执行多步动作,早期误解可能在后续不断放大。

降低认知失败需要把目标、禁止事项和验收写清,要求先探索再行动,使用外部证据和结构化输出,并让系统在关键信息缺失、来源冲突或置信不足时请求输入。对高风险判断,应安排独立复核而非让同一智能体自我确认。

智能体的长链条会放大早期误解,因此必须在前段设置澄清与计划门。

4.3 执行失败:工具错误、状态漂移与部分完成

工具可能超时、返回截断结果、修改错误文件、重复提交或只完成一部分。网页界面会变化,API状态会并发更新,长任务还可能在会话压缩后遗失关键上下文。执行系统必须把返回码、文件差异和外部回执视为事实源。

对写入动作应考虑幂等、事务和补偿:重复执行是否安全,部分成功如何识别,失败后如何回滚。任务状态应显式记录,而不是只存在于对话中。阶段性验收能阻止错误在长链路中继续传播。

真正危险的不是工具报错,而是工具失败后系统仍报告成功。

4.4 安全失败:提示注入、越权与供应链

网页、邮件、Issue、代码注释、文档和 MCP返回都可能包含恶意或误导指令。智能体若把这些内容与用户授权混为一谈,可能泄露信息、调用高权限工具或改变长期记忆。

第三方 Skills、Plugins、Hooks和 MCP服务器既是能力来源,也是软件供应链。风险控制需要内容隔离、工具最小权限、秘密保护、来源审查、版本固定、网络限制和高影响动作审批,而不能只提醒模型“忽略恶意指令”。

提示注入是权限问题和数据流问题,不只是提示词问题。

4.5 评价框架:任务成功、证据、可控性与成本

任务成功率应按完整验收计算,而不是按模型自报;证据质量检查测试、引用、回执和 diff是否直接支持结论;可控性关注失败是否可见、人工干预点是否合理、误操作是否可恢复;成本同时计算模型调用、人工审查、基础设施和返工。

评测集应来自真实任务,覆盖正常样本、边界样本、缺失输入、权限不足和恶意输入。单次演示只能说明可能性,连续多轮、不同操作者和不同时间的稳定结果才支持推广。

维度 核心指标 证据
任务成功 端到端成功率、一次通过率 交付物与验收记录
正确性 事实/测试/计算错误率 引用、测试、抽检
效率 人工时间、总时延、成本 对照组与日志
鲁棒性 异常恢复、重试次数 失败分类
安全 越权、敏感数据、审批命中 审计记录
可用性 接管负担、说明清晰度 用户反馈

评价 Agent 要看完整任务和运行证据,而不是只看最终文本。

4.5.1 能力上限与业务可靠性要分开测量

Pass@k回答“独立尝试k次,至少成功一次”的能力上限问题,适合探索模型是否有可能完成任务;Best@k关注从多个候选中能否选出最好结果。真实业务更关心连续可靠性:同一流程连续运行k次是否都成功,可用 Pass consecutive@k 或近似的成功概率连乘来观察。

两种指标的含义不能互换。单次成功率为90%的系统,看起来已经很高;但若一个业务链路包含多个独立关键步骤,或要求连续十次都正确,整体可靠性会明显下降。试点报告应同时给出单次任务成功、连续运行成功、人工接管率和失败后恢复成本。

评估视角 回答的问题 适用阶段 需要防止的误读
Pass@k 多次尝试中能否至少成功一次 能力探索、模型比较 不能代表稳定生产表现
连续成功 连续多次运行是否始终达标 业务上线、SLA评估 样本过少会高估可靠性
人工接管率 多少任务需要人补充或纠错 试点与运营 低接管可能来自遗漏风险
恢复成本 失败后多久能定位、回滚和重跑 高影响流程 不能只统计模型费用

表 4-1 能力上限与业务可靠性的互补指标

4.5.2 从最终结果深入到轨迹、边界与首错归因

端到端结果评估判断任务最终是否完成;轨迹评估进一步检查模型看到了哪些信息、为何选用某个工具、权限是否合规、是否读取真实回执、失败后是否正确修正。只看最终答案会遗漏“偶然做对”,只看推理过程又可能脱离真实结果,因此两者必须结合。

轨迹前缀评估适合测试边界判断:把运行截断在一个关键节点,让系统基于当时已有信息决定下一步。例如,当前指令是否覆盖历史规则、危险动作前是否应再次确认、低置信检索是否应拒答。它能把偶发事故转化为稳定的回归用例。

首错归因要求标出轨迹中第一个足以导致失败的节点,并区分任务说明、上下文、模型、工具、环境、权限或验证问题。根因不清时,团队容易用更长 Prompt掩盖工具缺陷,或用更强模型掩盖不可复现的环境。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

4.5.3 建立可持续的 Agent 评估闭环

完整评估基础设施由可复现环境、任务数据集、自动验证器、LLM-as-a-Judge、Rubric、轨迹记录和问题分析组成。能执行的事实优先用代码、测试、金额、状态字段等确定性验证器;风格、完整性与政策解释可由带评分标准的模型评审,但必须保留证据位置并允许“证据不足,拒绝评分”。

真实失败应进入评测集:保留输入、环境版本、工具输出、首错节点、最终影响和修复方式。系统修改后先跑目标用例,再跑通用回归与安全边界集;通过后才灰度扩大。评估不是项目末尾的验收活动,而是观察—假设—实验—验证—新假设的持续工程循环。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

4.6 ROI 与总拥有成本

智能体的收益可能来自缩短周期、提高覆盖、减少等待、标准化交付和释放专家注意力。成本不仅是模型费用,还包括工具建设、环境维护、权限审查、评测、人工复核、失败恢复和扩展供应链管理。

最容易被忽略的是返工和监督成本。若用户必须逐行检查所有输出,名义上的自动化会转化为新的审查负担。好的流程会把验证自动化、把差异聚焦、把高风险部分显式标记,使人只审查真正需要判断的部分。

ROI 的核心不是少花多少模型费,而是每个可靠交付需要多少总成本。

4.7 人工介入、停止条件与责任回退

人工介入至少应在三类情形触发:连续失败超过阈值,动作影响高且不可逆,关键事实或授权不明确。系统应把当前目标、已完成步骤、证据、错误和建议选项一并移交,避免人重新从零理解。

停止条件既防风险也控成本。可以按最大步骤、最长时间、费用上限、失败次数、权限拒绝或证据冲突停止。停止不是失败的掩饰,而是智能体系统可靠性的组成部分。

会在正确时机停下并清楚移交,是成熟智能体的重要能力。

5. 如何使用智能体:任务工程与人机协作

有效使用智能体始于任务工程,而不是始于一句更长的提示词。交付物、范围、约束、权限、验证和失败处理共同决定任务能否被可靠委托。

人类的角色也由逐步操作转向目标设定、关键决策、权限批准和最终验收,低风险且可验证的步骤则交由系统持续执行。

5.1 从合适的任务开始

最好的试点不是最宏大、最重要的任务,而是“有真实价值、步骤较多、风险可控、结果可验证”的任务。例如:根据公开资料生成带引用的研究报告;根据测试失败修复一个小范围 Bug;读取工单并生成待人工确认的处理建议;每周汇总代码库变更但不自动发布。

选择任务时可以问四个问题:最终交付物是否明确?是否有真实工具和数据可用?是否有客观验收方法?如果智能体犯错,是否可以撤销或由人及时发现?四个问题中若有两个以上回答为否,应先缩小范围。

理想试点具有真实价值、步骤较多、风险可控和结果可验证四个条件。任务应小到失败可恢复,又大到能够展示跨步骤价值。公开资料研究、小范围 Bug修复、测试补全和内部报告通常优于直接自动发邮件或操作生产系统。

先选择可验证的小闭环,再逐步扩大任务和权限。

5.2 把提示词升级为任务说明书

一句提示词通常不足以支撑复杂任务。可靠的任务说明书至少包含六类信息:目标、上下文、允许范围、禁止事项、证据与验收、停止条件。它相当于给执行者一份简短的项目章程。

任务说明书并不要求把每一步都写死。它的作用是明确“结果与边界”,让智能体在边界内自主选择路径。对于探索性任务,可以允许计划动态变化,但必须保持阶段性总结和验收节点。

任务说明书描述的是结果与边界,不必把所有步骤写死。对探索性任务,可以允许计划变化,但必须要求阶段性总结;对工程任务,要列出验证命令和不可修改项;对业务任务,要区分草稿、建议、写入和对外发送。

字段 应写内容 示例
目标 要解决的问题 完成专题报告
交付物 文件、格式、受众 80页以上Word报告
范围 包含与排除 四个产品,重点CC/Codex
约束 时间、工具、来源、风格 官方资料优先
验证 如何判断完成 页数、目录、渲染检查
权限 允许/需确认/禁止 只读检索;写本地文件
失败处理 何时重试或升级 来源冲突时标注

复杂任务需要一份微型项目章程,而不是一句愿望。

5.3 从只读试点到持续自动化的五步法

  1. 只读试点:先让智能体阅读、分析、整理和提出方案,不写入关键系统。

  2. 受控写入:只开放任务必需的目录和文件,所有变更通过 diff 或版本控制审查。

  3. 工具执行:允许运行测试、格式化、查询等低风险工具,高影响动作保持人工审批。

  4. 技能化:把经过多次验证的流程封装为 Skill、规则或项目指令,减少每次重新解释。

  5. 后台与并行:在流程稳定后再启用定时任务、云端长任务或多智能体,并加强审计。

每一级都要单独定义“通过”的证据。例如从只读分析升级到受控写入,至少应确认智能体能正确识别文件范围、不会误改无关内容、能运行基础验证并清楚报告失败。升级是风险决策,而不是产品功能开关。

每一级都要重新定义成功证据。只读阶段看事实和范围识别,写入阶段看 diff与回滚,工具阶段看命令和回执,技能化阶段看跨样本稳定性,后台阶段看无人值守失败与审计。只有上一层稳定,才进入下一层。

权限升级应由运行证据驱动,不应由产品功能可用性驱动。

5.4 计划、里程碑与任务状态

计划应列出任务分解、依赖、风险、验证和停止点。它不是为了展示智能体“会规划”,而是让人能够在投入大量执行成本前判断方向。高不确定任务应先安排探索里程碑,高风险任务应先安排环境和回滚验证。

每个里程碑都要更新状态:完成了什么、证据是什么、计划为何调整、下一步是什么。状态应写入可恢复的摘要或项目文件,不能只依赖长对话。

计划的价值在于提前暴露方向错误,并为长任务提供恢复点。

5.5 把验证写进“定义完成”

智能体任务的完成标准不能只是“生成内容”或“修改代码”。研究报告应检查引用是否直接支持结论、来源日期是否有效、数字是否一致;工程任务应运行测试、静态检查、格式化并审查 diff;业务任务应检查系统回执、字段状态和审批记录。

最好要求智能体在交付时回答四个问题:做了什么?依据是什么?如何验证?还有什么未完成或风险?这四个问题能显著减少“表面完成、实际未验证”的情况。

研究报告检查引用与时间,工程任务运行测试与审查 diff,数据分析复算公式与口径,业务操作确认系统回执和审批。验证必须是任务的一部分,而不是完成后可选的附加步骤。

如果任务说明中没有“怎样知道做对了”,智能体就很容易只优化表面完成。

5.6 人机交互:反馈应指向规则、证据和取舍

有效反馈应指出哪项事实不对、违反了什么约束、缺少何种证据或需要怎样取舍。对重复错误,应更新项目指令或 Skill;对机械强制,应改为 Hook或规则;对一次性偏好,保留在当前任务即可。

用户还应要求智能体显式呈现不确定性和被否决方案。这样后续人员能够理解决策过程,也能判断失败来自输入、工具、模型还是环境。

高质量协作不是多聊几轮,而是把纠正沉淀到合适的系统层。

5.7 上下文与长期任务管理

上下文不是越多越好。大量日志、搜索结果和重复文件会挤占模型的注意力。长任务应在每个里程碑形成短摘要,记录当前目标、已完成、关键决策、未完成事项、验证状态和下一步。需要深入某一侧任务时,可用子智能体隔离高容量探索。

稳定事实与临时过程应分开保存。项目构建命令、架构约束和审查规则适合写进 CLAUDE.md 或 AGENTS.md;可复用的多步骤流程适合做成 Skill;会话过程和日志只在当前任务中保留;自动记忆更适合记录经验和偏好,而不应承担必须执行的硬规则。

长任务要周期性压缩日志和中间探索,只保留目标、关键事实、决策、已完成、验证和下一步。稳定项目规则写入 CLAUDE.md或 AGENTS.md,重复流程写入 Skill,当前会话日志则不应永久占用上下文。

上下文管理的目标是保持相关性,不是把所有信息永远塞进模型。

5.8 失败恢复、复盘与流程升级

失败后先区分目标误解、信息缺失、工具错误、环境差异、权限不足和验证缺口。不同原因对应不同改进:澄清任务、补数据、修工具、固定环境、调整权限或增加验收。仅重新运行同一提示通常会重复相同问题。

复盘要决定改进放在哪里:项目规则、Skill、Hook、测试、沙箱配置或组织流程。只有错误被转化为可复用改进,智能体系统才真正具有学习效应。

把失败沉淀成规则、测试和技能,比让模型“下次注意”更可靠。

6. 关键基础设施:上下文、记忆、工具与多智能体

智能体要承担长期、重复和并行任务,必须依赖上下文管理、分层记忆、工具接口、技能资产和多智能体编排等基础设施。

这些机制分别解决信息供给、状态延续、真实行动、方法复用和任务分工问题,同时也带来新的版本、权限与协调成本。

6.1 上下文工程:决定当前任务看见什么

上下文是智能体当前能够直接使用的工作材料,包括用户目标、系统指令、项目规则、读取的文件、工具结果和阶段摘要。上下文质量取决于相关性与结构,而不是单纯长度。大量重复日志、无关文档和宽泛工具描述会稀释真正重要的信息。

上下文工程要回答四个问题:哪些内容必须始终加载,哪些按文件路径加载,哪些只在任务触发时加载,哪些应由子智能体读取后返回摘要。稳定而短的规则放在常驻层,领域材料和长流程按需加载,侧任务使用隔离上下文。

压缩和总结应发生在自然里程碑。摘要至少保留目标、已完成、关键事实、决策、验证、未完成和下一步;如果只保留“做了很多工作”,后续智能体无法可靠恢复。

上下文工程追求的是高信噪比和可恢复状态,而不是最大输入量。

6.1.1 稳定前缀、动态轨迹与任务状态栏

上下文可以分成稳定前缀和动态轨迹。稳定前缀包括系统规则、核心工具定义和项目级约束,应尽量保持字节级稳定,以便复用 KV Cache或服务端 Prompt Cache;动态轨迹则按时间追加用户消息、工具调用、结果和阶段总结。频繁改写前缀或把全部工具一次性塞入上下文,会同时增加成本和选择噪声。

长任务还需要一块简短、结构化的任务状态栏,持续记录目标、当前阶段、已验证事实、未决问题、风险、预算和下一步。它不是替代完整轨迹,而是让模型在每一轮都能快速恢复“现在在哪里”。状态栏应由 Harness根据真实运行更新,避免只依赖模型自由总结。

6.1.2 压缩、隔离与渐进披露是三种不同手段

压缩适合已经完成的历史,把大量过程折叠为目标、决策、证据和剩余工作;上下文隔离适合搜索、长日志分析或专项审查,让子智能体只返回结论和证据;渐进披露适合工具与 Skills,先加载元数据目录,命中任务后再读取详细说明或脚本。三者分别处理时间、任务和能力目录的上下文增长。

压缩前必须保留可信根:当前用户指令、权限边界、未完成承诺、关键来源和验证状态。若摘要只保留结论、不保留证据位置,后续轮次会把未经验证的中间判断误当成事实。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

6.2 持久指令:把稳定规则写给每次任务

持久指令适合保存每次工作都必须知道的仓库结构、构建命令、代码风格、禁止事项和交付格式。它们应简短、可执行、可版本化,并能由团队审查。模糊表述如“注意质量”应改写为具体动作与验证命令。

不同层级文件应保持一致。全局规则定义个人或组织通用底线,项目规则定义仓库约定,子目录规则处理特定语言或组件。发生冲突时要依赖明确优先级和更具体范围,而不是把同一句话复制到多个位置。

持久指令不是强制执行器。若规则必须无条件成立,应配合权限、命令规则、Hook或 CI检查。否则它仍属于模型需要解释和遵循的上下文。

持久指令保存“每次都要知道”,强制机制保证“每次都必须做到”。

6.3 记忆分层:工作记忆、项目事实与长期经验

工作记忆服务于当前任务,项目事实由人维护并进入版本控制,自动记忆从历史中提炼偏好和经验,会话检索则在需要时查找过去过程。四者的写入者、生命周期和可信度不同,不能互相替代。

记忆需要治理。用户应能查看、纠正、删除和导出;秘密不应进入长期记忆;自动生成的经验要有来源和更新时间;硬规则不能只存在于模型记忆。过期记忆会造成隐蔽错误,记忆越长越需要清理和冲突处理。

理想的记忆写入具有明确触发:反复出现的项目事实进入规则文件,经过验证的多步骤方法进入 Skill,个人偏好进入用户记忆,当前任务的中间过程则在任务完成后归档或压缩。

层级 内容 生命周期 治理要点
会话状态 当前计划、工具结果 单任务 防止上下文溢出
项目记忆 仓库/流程约定 项目期 可编辑、可追溯
用户偏好 稳定表达与协作偏好 跨任务 需确认与纠错
组织知识 政策、标准、案例 长期 版本和权限
技能记忆 可复用步骤与脚本 长期 测试、发布、回滚

记忆的价值不在“永不遗忘”,而在可追溯、可纠正和按需使用。

6.3.1 区分用户记忆与组织知识库

用户记忆服务于个体尺度,保存偏好、关系、历史决策和经过验证的习惯;知识库服务于团队或组织尺度,保存政策、产品、项目和专业资料。前者强调个体控制、隐私和纠正权,后者强调来源、权限、版本、覆盖范围与一致性。两者都可被检索,但写入策略和治理责任不同。

可靠记忆生命周期包括:在任务开始时按相关性读取;运行中记录候选事实而非立即永久写入;后台根据来源、时间、冲突和隐私判断新增、更新、删除或保持不变;写入后保留出处与验证时间。简单便签适合原子事实,结构化卡片适合可更新属性,叙事记录适合事件背景,程序性经验更适合 Skill或可执行脚本。

6.3.2 RAG 是检索系统,也是知识组织系统

基础 RAG链路包括采集与清洗、语义分块、索引、检索、重排、生成与引用。稠密检索擅长语义近似,BM25等稀疏检索擅长专有名词和精确词形,生产系统常采用混合检索后再重排。分块不应只按固定字数切割,还要保留标题、路径、时间、文档版本和访问控制等元数据。

当资料规模和问题复杂度上升,平面向量索引并不总够用。层次摘要可支持从全局主题下钻到原文,知识图谱适合实体关系和多跳问题,文件系统目录可作为天然的可解释层次。一个实用原则是把短而稳定的结构概览放在上下文中,把长而细的证据通过检索按需加载。

Agentic RAG把检索作为工具交给 Agent:系统先分析问题、改写查询、选择知识源,再根据结果判断是否补检索、换过滤条件、读取全文或停止。它提高了复杂问题的覆盖率,也引入更多循环和成本,因此必须用召回率、引用正确性、拒答表现和检索轨迹共同评估。第11.11节给出了用 Codex实施这一架构的工程路径。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

6.3.3 知识写入、更新与发布需要独立治理

知识库不是一次性导入工程。增量更新负责吸收新文档和新证据,周期性整理负责去重、合并冲突、淘汰过期内容和重建索引;对政策、医疗、法律、财务或生产操作等高影响知识,候选更新应经过独立复核后才能发布。

检索权限必须在后端按用户身份和文档 ACL执行,不能只依靠 Prompt提醒。删除、撤回和版本替换要同步影响原文、索引、缓存与引用;答案应返回来源标题、定位信息和版本时间,找不到足够依据时明确拒答。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

6.4 Skills:把程序性知识变成可复用能力

Skill适合封装需要判断的重复流程与领域知识,例如代码审查、发布、研究检索和数据清洗。一个完整 Skill应包含清晰描述、输入要求、步骤、输出、验证、停止条件,并按需引用模板、脚本和示例。

触发描述决定智能体是否会正确选用 Skill。描述过宽会误触发,描述过窄会漏掉场景;多个 Skill边界重叠会增加选择困难。团队应使用真实任务建立样例,测试自动触发、人工调用、失败处理和上下文成本。

报告插图 2

图 6-1 持久指令、Skills、MCP、Subagents 与 Hooks 的上下文加载方式

来源:Claude Code 官方文档,Extend Claude Code(检索日期:2026-08-10)

Skill中的脚本和依赖属于供应链的一部分。第三方 Skill安装前要审查来源和执行内容,内部 Skill要版本化、指定责任人并保留变更记录。

Skill 是程序性记忆,也是需要测试和治理的软件资产。

6.5 工具、MCP 与外部系统连接

工具把模型决策转化为可验证动作。数据工具读取信息,行动工具改变系统,编排工具管理任务和委派。工具名称、描述、参数、权限和错误返回必须清晰;相似工具过多会导致选择困难,宽泛工具会扩大风险。

MCP为外部服务提供标准连接,但连接本身不等于安全。需要评估身份认证、授权范围、传输、数据保留、工具写入能力、输出大小和审计。来自 MCP 的内容也可能携带提示注入,应被视为不可信数据。

Skills与 MCP解决不同问题:MCP提供连接,Skill提供如何有效使用连接的知识与流程。二者组合时,应让权限控制留在工具层,让业务步骤和验收留在 Skill层。

工具等级 典型权限 默认控制
L0 只读 搜索、读取公开资料 自动
L1 本地可撤销 写工作区、运行测试 沙箱+日志
L2 外部写入 工单、数据库、邮件草稿 范围限制+回读
L3 高影响 发布、付款、删除、权限变更 强审批+双人复核

工具决定 Agent 能触及现实的范围,也决定错误可能造成的影响。

6.5.1 五类工具与两种设计路线

按系统作用可以把工具分为五类:感知工具读取网页、文件、数据库和多模态输入;执行工具修改环境;协作工具委派或交换结构化消息;事件触发工具把定时器、Webhook和外部状态变化送入运行时;用户通信工具负责澄清、审批、进度和交付。前两类决定基本行动闭环,后三类决定 Agent能否异步、长期和协同工作。

工具设计有两条互补路线。高风险、强合规和高频固定动作适合专用工具,以窄参数、服务器端鉴权和明确回执降低自由度;探索、数据转换和长尾组合适合通用执行器配合 Skill,用代码把多个简单原语组合成新能力。选择依据不是“哪种更智能”,而是结果能否验证、动作能否限制、失败能否恢复。

6.5.2 工具契约必须让模型参数与真实执行参数一致

一个可用工具契约应定义名称、用途、输入类型、取值范围、默认值、权限、超时、幂等性、副作用、结构化返回和错误码。模型看到的 Schema必须与服务器实际执行保持一致;若描述写“只读”而实现允许写入,或参数名在网关中被重新解释,所有上层安全判断都会失效。

工具数量增长后,应采用主动发现与渐进披露:先让 Agent根据自然语言需求发现相关服务器或工具,再只加载少量候选的完整定义。MCP统一了发现和调用接口,但不会自动解决工具选择、版本兼容、身份授权和提示注入,这些仍属于 Harness与服务端共同责任。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

6.6 Hooks 与确定性控制

Hook适合无论模型怎样判断都要发生的动作,例如编辑后格式化、命令前阻止危险前缀、会话结束记录摘要、权限请求前附加审查、上下文压缩后重新注入关键状态。它的价值是把自然语言建议转成确定性机制。

Hook本身也会失败或被滥用。需要处理超时、退出码、并发和日志;来自插件的 Hook等同自动执行代码,应审查脚本、网络和秘密访问。复杂业务判断不应全部塞入 Hook,否则会形成难以观察的隐式工作流。

需要保证发生的机械动作交给 Hook,需要理解和取舍的流程交给 Skill或智能体。

6.7 Subagents、Agent Teams 与委派边界

Subagent适合读取大量材料、执行独立测试或做专业审查,并把摘要返回主会话;Agent Team适合多个独立会话共享任务、互相沟通和协商。前者强调上下文隔离,后者强调协作自治。

委派说明应包含目标、输入、工具、可编辑范围、输出格式和验收。主智能体不能把最终责任一并委派,它要检查子结果的证据、冲突和覆盖范围,并决定是否合并。

并发数量应由任务可分性、模型成本、环境资源和合并能力决定。多个智能体共同修改一组强耦合文件,常常比顺序执行产生更多返工。

委派要隔离上下文和责任边界,而不是复制更多聊天窗口。

6.7.1 多 Agent 的分类轴:上下文与拓扑

多 Agent系统可以沿两个轴理解。上下文上,可以共享完整历史、共享结构化任务状态,或完全隔离后只交换结果;拓扑上,可以采用顺序流水线、管理者—工作者、对等协商或去中心化网络。共享越多,交接成本越低但污染和泄露风险越高;隔离越强,专业化越清楚但需要更严格的接口。

多 Agent真正有价值的条件是获得单 Agent难以同时取得的并行环境、独立信息源、专业工具或相互校验,而不是简单增加推理副本。若所有角色读取同一上下文、使用同一模型并重复同一路径,结果可能只放大共同盲点。

6.7.2 协作失败需要在设计阶段显式处理

常见失败包括并发写入冲突、错误级联、结论同质化、责任推诿、通信死循环和“理解债务”。理解债务是指人类越来越难解释多个 Agent如何形成最终结果;它会随着层级、消息量和隐式状态增加而累积。

控制措施包括:为共享资源设置所有者或锁;用结构化任务单和产物接口替代自由聊天;限制委派深度、轮数和预算;让关键角色使用差异化信息源;要求管理者对合并结果承担验证责任;保留取消、超时和人工接管。多 Agent优化的是信息获取、执行并行和独立验证,不能替代清楚的任务分解。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

6.8 Worktree、云环境与后台运行

Worktree在同一 Git项目中提供独立工作副本,解决本地并行修改冲突;云环境提供远程、可配置和可持续运行的执行空间;后台任务则关注时间上的持续性。三者可以组合,但解决的问题不同。

隔离环境必须具备完成任务所需的依赖、配置和测试。被忽略文件、秘密和本地服务不能默认存在;环境差异应通过设置脚本和显式变量管理。任务完成后要有移交、审查、分支和清理流程。

并行可靠性首先来自环境和文件隔离,其次才是模型并发。

6.9 可观测性:日志、轨迹、成本与审计

可观测性至少包括输入版本、计划变化、工具调用、权限请求、文件差异、外部回执、测试结果、模型与成本、人工干预和最终状态。没有这些信息,失败无法定位,成功也无法复现。

日志要区分调试、审计和业务证据。调试日志可以详细但有保留期限;审计记录要防篡改并关联身份;业务证据应直接支持交付结论。敏感数据需要脱敏和访问控制,不能为了可观测性无限保存全部上下文。

没有运行证据的智能体只能被演示,不能被治理。

7. 安全与治理:让能力、权限和责任相匹配

智能体安全不是任务完成后的末端审核,而是贯穿输入、规划、执行、验证、发布和复盘的连续控制过程。

不可信内容、身份与权限、网络访问、秘密数据、扩展供应链、审批、审计和回滚需要形成相互衔接的治理链条。

7.1 威胁模型:谁能输入、Agent 能做什么、结果影响谁

智能体风险由数据与权限组合产生。同一模型在只读公开资料任务中风险较低,在连接邮箱、终端和生产系统后风险完全不同。威胁模型要画出外部内容怎样进入上下文、模型能调用哪些工具、凭据如何提供、结果写到哪里。

尤其要区分可信指令与不可信内容。用户和组织策略可以授权动作,网页、邮件、Issue和文档只提供数据,不能因为内容中出现“请执行”就提升为授权。

先画清数据流和权限流,才能讨论智能体安全。

7.2 最小权限与能力分级

任务开始时只开放必需目录、命令、域名和账号。读取不等于无风险,敏感数据读取也可能导致泄露;写入要区分草稿、测试环境和正式系统;外发、付款、删除和生产变更必须单独控制。

权限可以随证据逐级放大,但不能由智能体自行决定永久升级。短期任务使用短期凭据和临时范围,完成后撤销;多个项目使用独立环境和身份,避免一个智能体跨越无关边界。

授权应围绕当前任务最小化,而不是围绕产品功能最大化。

7.3 沙箱、审批、规则与回滚

治理智能体需要区分四个概念。权限决定智能体具有什么身份;沙箱决定技术上能访问哪些文件、进程和网络;审批决定跨越边界时由谁确认;审计记录说明做过什么、使用了什么工具和数据。它们互补,但不能互相替代。

最小权限原则应落实为具体配置:只开放本次任务必需的目录、命令、域名和账号;默认关闭不必要网络;敏感凭据使用短期、范围受限的方式提供;对付款、发布、删除、对外发送和生产操作设置人工确认;所有重要变更保留 diff、日志或系统回执。

治理底线|沙箱回答“技术上能触及什么”,审批回答“跨越边界时谁来确认”。两者必须同时设计;仅依赖模型识别提示注入或自行克制是不够的。

沙箱回答“技术上能访问什么”,审批回答“跨越边界时由谁确认”,规则对特定命令或工具前缀允许、询问或禁止,回滚则保证错误发生后能够恢复。四者共同形成闭环,任一项都不能替代其他项。

低风险基线通常是工作区写入、受限网络和按需审批。完全访问加永不审批会移除主要控制,只应在明确隔离、可恢复和经过授权的环境使用。自动审批改变的是审查者,不应被误解为扩大沙箱边界。

阶段 关键控制 证据
输入 来源信任、注入隔离、敏感分类 输入标签
规划 范围、权限、停止条件 任务说明书
执行 沙箱、最小权限、审批 工具日志
验证 独立检查、回读、对账 测试与验收
发布 人工批准、回滚准备 批准记录
复盘 失败分类、指标与改进 评测报告

边界、审批、规则和回滚是四个不同控制面。

7.4 凭据、隐私与数据生命周期

凭据应通过环境或秘密管理器按需提供,避免写入提示、项目文件、记忆和日志。使用范围最小、有效期短、可撤销的令牌,并让不同工具获得不同身份。对本地和云环境分别配置,不能复制个人全量凭据。

数据治理还包括输入来源、跨境和合规要求、供应商保留策略、训练使用、导出和删除。自动记忆、会话历史和工具日志可能保存敏感内容,必须有查看、纠正、保留和清理机制。

智能体的数据边界覆盖上下文、工具、记忆、日志和供应商,而不只是输入框。

7.5 扩展与供应链安全

扩展可以带来指令、脚本、二进制、依赖、网络连接和自动触发行为。审查应关注来源、维护者、版本、发布记录、权限、数据流、安装脚本和更新机制。市场上可安装不等于组织允许。

内部扩展也需要代码审查、测试、签名或校验、版本锁定、责任人和回滚。高权限环境应使用允许列表,并在隔离环境先验证更新,避免自动升级改变行为。

Agent 扩展生态应按软件供应链治理,而不是按提示词素材治理。

7.6 审计、责任与事件响应

每次关键动作应能回答谁发起、使用哪个智能体和模型、读取什么数据、调用什么工具、获得什么批准、修改什么对象、如何验证。对外发送和生产变更还要关联业务责任人。

事件响应预案应覆盖凭据泄露、误删除、越权写入、恶意扩展、记忆污染和后台任务失控。需要能够立即停止任务、撤销令牌、隔离环境、恢复数据、保存证据并复盘控制缺口。

责任不能归给“AI”;组织必须保留可追溯的授权链和处置流程。

7.7 组织政策与受管配置

组织政策应规定可用产品和模型、允许连接的数据、默认沙箱与审批、扩展来源、后台任务权限、日志保留和高风险动作。政策要通过受管配置和技术控制落地,不能只停留在培训文档。

同时要提供可操作的例外流程。过度僵化会推动员工绕过控制,清晰的申请、审查、时间限制和撤销机制能让治理成为效率基础设施。

好的治理用默认配置降低风险,用例外流程保持业务速度。

7.8 从试验到生产的治理成熟度

个人实验以公开或脱敏数据、只读和隔离环境为主;团队试点建立任务模板、项目规则、扩展审查和人工验收;受控生产增加身份、审计、事件响应和服务责任;规模化阶段通过受管配置、评测平台和资产目录统一治理。

每个阶段都有退出条件。若任务成功率不稳定、失败不可见、扩展无人维护或权限无法回收,就不应进入更高阶段。治理成熟度要与自主程度同步提升。

阶段 特征 升级条件
探索 个人试用、人工逐步确认 任务模板和基本日志
受控试点 限定数据/工具/团队 稳定评测和失败分类
流程集成 接入真实系统、例外审批 身份、审计、回滚
规模运营 多团队、多智能体、持续监控 责任制度和组合治理

先建立可控运行,再扩大覆盖;先证明稳定,再减少人工。

8. OpenClaw 深度解析:自托管多渠道个人智能体

OpenClaw(龙虾)把消息渠道、Gateway、Agent、工具、记忆与持续运行组合成一个可由个人控制的长期智能体入口。

它的价值不在于提供另一种聊天界面,而在于让用户能够从手机或日常消息平台发起任务,由自托管环境中的 Agent 继续执行并返回结果。与此同时,常驻在线、远程触发和主机权限也使它必须按基础设施而不是普通应用来治理。

8.1 产品定位:常驻个人智能体的多渠道入口

OpenClaw 官方将产品描述为跨 Discord、Google Chat、iMessage、Matrix、Microsoft Teams、Signal、Slack、Telegram、WhatsApp、Zalo 等渠道连接 AI agents 的自托管 Gateway。一个 Gateway 可以同时服务多个渠道插件,并把消息交给相应 Agent。

这种定位把模型与运行时区分开来。模型负责理解和推理,OpenClaw 负责入口、会话、路由、工具连接、状态与运维。用户可以选择不同模型提供方,也可以把不同 Agent 分配给不同 workspace 或发送者。

因此,评估 OpenClaw 不能只问回答质量,还要问 Gateway 是否稳定、渠道身份是否可靠、会话能否隔离、后台任务怎样恢复、工具权限是否可控,以及部署者能否长期维护。

OpenClaw 的核心产品是个人可控制的 Agent Gateway,而不是一个新的基础模型。

资料依据:OpenClaw 官方文档 Overview、Agents、Capabilities、Gateway Security,检索截至 2026-08-10。

8.2 核心架构:Channels—Gateway—Agent—Nodes

OpenClaw 的基本链路可以概括为 Channels → Gateway → Agent。渠道插件负责接收和发送消息,Gateway 是会话、路由和渠道连接的单一事实源,Agent 结合模型与上下文决定行动,并调用工具、Skills 或 Plugins。

Gateway 还连接 CLI、Web Control UI、桌面与移动 Nodes。Control UI 提供聊天、配置、会话和节点管理;节点则通过配对向 Gateway 暴露特定设备能力。整个系统既是数据面,也是控制面。

报告插图 3

图 8-1 OpenClaw 以 Gateway 连接消息渠道、Agent、控制界面与移动节点

来源:OpenClaw 官方文档,Overview(检索日期:2026-08-10)

主要职责 关键对象 治理重点
入口层 接收与返回消息 渠道插件、WebChat 发送者与群组允许列表
控制层 会话、路由、连接与状态 Gateway、Control UI 认证、网络暴露、日志与恢复
Agent 层 理解任务并组织调用 Agent、session、workspace 上下文、隔离与模型配置
能力层 执行动作与复用流程 Tools、Skills、Plugins 最小权限、来源与版本
设备层 提供远程设备能力 桌面与移动 Nodes 配对、令牌与执行批准

这一结构的优势是渠道和能力可以独立扩展,缺点是 Gateway 成为高价值单点。配置文件、渠道令牌、模型密钥、插件和日志都围绕它集中,部署时需要备份、更新、监控和恢复方案。

理解 Gateway 的控制面地位,是理解 OpenClaw 能力与风险的起点。

8.3 渠道、会话与多智能体路由

多渠道解决的是用户从哪里触达 Agent,多会话和多智能体路由解决的是不同输入进入哪一个信任边界。工作账号、个人账号、家庭群组和公开社区不应默认共享同一上下文、记忆和工具权限。

OpenClaw 可以按 Agent、workspace、sender 等维度组织隔离会话。合理做法是让不同用途拥有独立 Agent 与工作目录,并为私信、群组和频道设置允许列表与配对流程。跨渠道需要共享的事实,应经过明确写入,而不是直接合并全部历史。

多 Agent 路由还可以把研究、家庭自动化、工程任务或运营通知分开。但路由标签只是选择器,不能代替认证;谁能触发高权限工具仍要由渠道身份、Gateway 权限和工具策略共同决定。

多渠道带来可达性,多会话与多 Agent 才能把可达性转化为可控性。

8.4 Tools、Skills、Plugins 与能力扩展

OpenClaw 把扩展分成不同层次。Tools 是模型可调用的结构化动作,例如文件、终端、Web、浏览器、消息、自动化和节点操作;Skills 向 Agent 提供按需加载的工作方法;Plugins 则可以加入工具、渠道、模型提供方、Hooks 和其他运行时代码。

这种分层有助于使用最小表面原则:一次性动作使用已有 Tool,稳定流程沉淀为 Skill,确需新运行时代码或分发时才引入 Plugin。不是每个需求都应该通过安装新的扩展解决。

扩展也是主要供应链风险。Skills 可能引用脚本和外部依赖,Plugins 在 Gateway 进程内运行。团队应使用来源允许列表、固定精确版本、审查解包内容、隔离测试和更新回归,避免把社区目录天然视为可信。

扩展生态提升能力上限,也把软件供应链安全带入个人智能体。

8.5 记忆、工作区与自动化

长期运行需要把当前会话、稳定工作区和长期事实分开。会话保存任务过程,workspace 提供文件、指令和工具环境,记忆只应保存跨会话仍有价值且经过确认的信息。全部历史永久加载既浪费上下文,也会放大错误记忆。

Cron、Webhooks 和后台事件使 OpenClaw 能够生成定时简报、提醒、巡检或消息转发。自动化的关键不是能否触发,而是触发来源是否可信、任务是否幂等、失败是否通知、重试是否有限、结果是否可回读。

对于长期任务,应保存下一次运行所需的最小状态,明确停止条件和人工接管点。涉及外部发送、文件修改或设备控制的任务,应在动作前保留批准或复核。

长期状态与后台运行越强,越需要可观察、可撤销和可审查。

8.6 Control UI、CLI 与移动节点

Control UI 是浏览器中的管理入口,用于聊天、配置、会话和节点;CLI 负责安装、onboarding、诊断、安全审计和自动化;桌面或移动 Nodes 则通过配对提供设备侧能力。三者共享 Gateway 状态,但面向的操作者和风险不同。

节点能够扩展相机、语音、Canvas 或系统执行等场景,也意味着 Gateway 可以远程调用真实设备。节点配对、令牌轮换、离线队列、命令批准和移除设备必须形成统一流程。

报告插图 4

图 8-2 OpenClaw 官方文档展示的 Control UI / 移动端交互界面

来源:OpenClaw 官方文档,Overview(检索日期:2026-08-10)

控制界面不应直接暴露在未经保护的公网。远程访问优先使用私有网络或受控隧道,并验证反向代理、认证和 WebSocket 配置。管理入口与普通消息入口应采用不同权限。

节点不是普通客户端,而是 Gateway 可调用的远程能力边界。

8.7 使用路径:从单渠道只读试点到常驻运行

当前官方快速路径包括安装 OpenClaw、运行 onboarding 并启动 Gateway 服务,再通过 dashboard 或一个消息渠道进行交互。命令和平台要求变化较快,实际部署应以当时官方文档和 release notes 为准。

更稳妥的采用方式分为四步。第一步使用独立系统账号、独立目录和一个渠道,只连接低风险模型与只读工具;第二步建立 sender 允许列表、会话隔离和日志;第三步启用少量经过审查的 Skills、记忆或 Cron;第四步才评估写操作、节点和更多渠道。

每一步都要用真实任务记录完成质量、人工介入、连续运行、故障恢复和安全事件。扩展前先验证备份、停止服务、撤销令牌和恢复配置,而不是等到 Gateway 失控后才设计应急流程。

OpenClaw 应按权限和运行半径分阶段启用,而不是一次性连接全部个人环境。

8.8 安全模型、适用场景与边界

OpenClaw 官方安全文档明确采用个人助理信任模型:每个 Gateway 对应一个可信操作者边界。它不是让多个相互不信任用户共享同一 Agent 和主机权限的对抗性多租户安全边界。

若存在混合信任或不同组织,应拆分 Gateway、凭据,并优先拆分 OS 用户或主机。渠道使用私信与群组允许列表,工具遵循最小权限,执行设置批准,插件固定来源和版本,网络保持最小暴露。

官方提供 openclaw security audit、–deep、–fix 和 –json 等检查方式,用于发现开放群组策略、工具爆炸半径、执行审批漂移、网络暴露和浏览器控制风险。审计是诊断工具,不能替代组织自己的威胁模型。

OpenClaw 适合个人助理、跨渠道任务入口、受控家庭或工作自动化,以及工程智能体的远程触发;不适合在没有隔离和专门治理时直接作为公共高权限机器人。

OpenClaw 的价值来自常驻连接,其主要风险也来自常驻连接。

9. Hermes Agent 深度解析:可学习的开放个人智能体

Hermes Agent 强调通过持久记忆、Context Files 和自动生成或改进的 Skills 积累经验,使一个开放、多模型的 Agent 在长期使用中形成更强的个性化与程序性复用。

与 OpenClaw 的 Gateway 中心路线相比,Hermes 更突出学习循环、开放工具与多种执行后端。它同样覆盖消息渠道和持续任务,但“自我改进”并不意味着无需监督;记忆、Skills 和工具越能够改变后续行为,越需要评测、版本和安全边界。

9.1 产品定位:能够积累经验的开放个人智能体

Hermes Agent 由 Nous Research 开源,官方将其描述为具有内置学习循环的 self-improving AI agent:从经验创建 Skills,在使用中改进,并把值得保留的信息写入跨会话记忆。它不是只依附 IDE 的 coding copilot,也不是围绕单一 API 的聊天外壳。

准确理解这一定位很重要。所谓改进主要发生在上下文选择、记忆、程序性 Skills 和工具编排层,并不等于模型权重会在本地自动训练,也不保证每次自动写入都会提升质量。

报告插图 5

图 9-1 Hermes Agent 官方文档中的 CLI 界面布局:状态横幅、会话区与固定输入区

来源:Hermes Agent 官方文档,CLI Interface(检索日期:2026-08-10)

截至 2026 年 8 月 10 日,官方产品页和 GitHub release 将当前版本标为 v0.20.0。该版本继续扩展语音、引用、A2A、Webhook 和桌面能力,也说明产品表面仍在高速变化。

Hermes 的核心价值是把个人经验变成可复用资产;核心风险是错误经验同样可能被长期放大。

资料依据:Hermes Agent 官方文档、Nous Research 产品页与 GitHub v0.20.0 release,检索截至 2026-08-10。

9.2 运行形态:CLI、桌面、消息网关与远程环境

Hermes 提供 CLI、桌面应用和消息网关,可从 Telegram、Discord、Slack、WhatsApp、Signal、Email 等平台访问。它可以运行在个人电脑、VPS、GPU 集群或远程执行后端,并连接多种模型提供方。

不同界面并不是独立产品,而是同一 Agent 状态的入口。配置、上下文、记忆、Skills、工具和计划任务共同决定行为。跨界面保持连续性很有价值,但也必须避免个人、工作和团队身份共享无边界状态。

主要职责 代表对象 主要风险
交互层 统一多入口会话 CLI、Desktop、消息网关、Voice 身份混淆与上下文串线
知识层 保存事实、背景与程序 Memory、Context Files、SOUL.md、Skills 错误积累与秘密泄露
行动层 调用工具与外部系统 Tools、MCP、Browser、Code 越权、副作用与供应链
协作层 委派和持续运行 Subagents、Cron、Webhooks、A2A 无人值守与合并责任
执行层 隔离运行环境 Local、Docker、SSH、Singularity、Modal 环境漂移与边界配置

开放模型和执行环境便于实验、成本控制和定制,但也会引入模型差异、依赖漂移和运行复现问题。团队试点应固定版本、模型、工具集和后端,再比较任务效果。

Hermes 的开放性扩大了可部署范围,也把环境管理变成使用的一部分。

9.3 Memory、Context Files 与 SOUL.md

Hermes 把长期事实、项目背景、人格和历史过程分成不同资产。Memory 保存跨会话仍有价值的用户、项目或偏好信息;Context Files 为特定工作目录提供稳定背景;SOUL.md 描述默认人格和表达方式;历史搜索用于在需要时回看过去会话。

这种分层避免每次对话加载全部历史。稳定规则放在可审查文件中,事实记忆按需检索,临时任务过程留在会话。真正重要的不是能保存多少,而是能否在正确时机取回正确事实。

报告插图 6

图 9-2 Hermes Agent 内置持久记忆的文件分工与容量边界

来源:Hermes Agent 官方文档,Persistent Memory(检索日期:2026-08-10)

记忆写入必须允许查看、纠正和删除。秘密、短期状态、未经验证的推断以及可能属于另一项目的数据不应进入长期记忆;团队场景还需要保留来源、时间和所有者。

记忆质量取决于选择、验证和纠错,而不是保存数量。

9.4 Skills 与内置学习循环

Skills 是 Hermes 的程序性记忆层。Agent 可以从成功经验生成 Skill,也可以在使用过程中改进已有 Skill,把工具顺序、检查步骤、脚本、模板和失败处理固化为以后可复用的方法。

程序性复用可以显著减少重复探索,但也可能把偶然成功、危险命令或过期依赖变成长期行为。高质量 Skill 应明确触发条件、输入、输出、权限、验证、负责人、版本和回滚。

自动创建的 Skill 应先进入候选或审查状态,在隔离环境用代表性任务测试,再提升为默认能力。若记忆或 Skill 被纠正,应通过回归任务验证错误是否真正消失。

学习循环只有与评测和版本治理结合,才会变成可靠复用。

9.5 Tools、MCP、浏览器与多模态能力

Hermes 官方文档当前列出 60 余种内置工具,并覆盖终端、文件、Web 搜索、浏览器、代码执行、图像和语音等任务。工具集可以按场景启用,避免把全部能力无差别暴露给模型。

MCP 允许 Hermes 连接外部工具和数据源。每个 MCP server 都应使用专用身份、窄参数和最小权限;来自外部系统的文本仍属于不可信输入,不能因为进入工具返回就被当成系统指令。

v0.20.0 强化了实时语音、来源引用、A2A v1.0、签名 outbound webhooks 和桌面 artifacts。这些能力扩大了交互和协作,但在组织采用时仍需单独验证稳定性、数据流与权限。

工具广度决定可做什么,权限和验证决定是否应该做。

9.6 Subagents、消息渠道与定时任务

Hermes 的 Subagents 可在独立会话、终端或脚本中承担研究、测试和数据处理,减少主上下文噪声。主 Agent 负责拆分目标、提供材料、设定工具边界,并验证返回结果。

消息网关让用户从日常平台远程发起任务和接收结果,自然语言调度可安排报告、备份和简报。委派、消息与 Cron 组合后能够形成持续工作,但也把身份、交付和错误恢复连接起来。

无人值守任务应使用窄工具集,限制最大运行时间和重试次数,并设置清晰通知。多个 Subagents 操作共享目录时,应采用独立工作区或明确只读/写入范围,最终合并责任必须由主任务承担。

委派和调度提升吞吐,但不能替代任务边界、证据和责任人。

9.7 沙箱、批准与安全边界

Hermes 支持 local、Docker、SSH、Singularity、Modal 等执行后端。不同后端决定文件系统、进程、网络、GPU 和秘密如何暴露;选择后端时应从任务风险和复现要求出发,而不是只看启动便利。

命令批准、授权、DM pairing 与容器隔离分别控制不同层次的风险。沙箱限制环境,批准保留人类决策,渠道授权限制谁能发起任务,秘密管理限制执行过程中可以取得什么凭据。

对高影响任务,建议使用专用账号和隔离后端,默认只读或限制写根目录,收紧出站网络,记录工具调用和人工批准。定时任务还应验证停止与恢复,避免后台任务在失败后持续重试。

沙箱提供环境边界,批准提供决策边界,两者必须同时设计。

9.8 使用路径、迁移与选型建议

使用 Hermes 可以从 CLI 与只读工具开始:固定模型、项目目录和 Context Files,用一组重复任务建立质量基线;随后启用可审查 Memory,再测试单个 Skill、MCP 或 Subagent;最后才接入消息渠道、Cron 和高权限执行。

官方提供从 OpenClaw 导入设置、记忆、Skills、允许列表、消息配置和部分密钥的迁移路径,并支持 dry-run。迁移不应机械复制所有资产,应先排除秘密、过期记忆和未经审查的 Skills,再重新验证权限。

若核心需求是成熟的多渠道 Gateway、会话路由和设备节点,可优先评估 OpenClaw;若核心需求是开放工具、多执行后端、记忆与 Skill 学习循环,可优先评估 Hermes。两者都要求部署者承担更新、扩展审查和安全运维。

Hermes 适合愿意治理长期记忆与开放工具的用户,不适合把“自我改进”当作无人监管。

10. Claude Code 深度解析

Claude Code 将模型能力嵌入代码库、终端、IDE、桌面和浏览器,使需求理解、代码修改、真实测试、差异审查和交付形成连续工程闭环。

其价值不仅来自生成代码,还来自 CLAUDE.md、Skills、MCP、Hooks、Subagents、Agent Teams和插件共同构成的可复用工程体系。

10.1 产品定位与四类使用界面

Claude Code官方将其描述为能够读取代码库、编辑文件、运行命令并集成开发工具的 agentic coding tool。它覆盖终端、IDE、桌面应用和浏览器;不同界面共享底层工程能力,但对本地文件、云端环境、并行任务和可视化审查的侧重点不同。

把 Claude Code理解为“代码补全工具”会低估它的价值。补全关注当前文件附近的下一段代码,而工程智能体关注一个目标在代码库中的完整生命周期:理解需求、定位实现、修改多个文件、运行真实工具、根据失败继续修复、审查差异并准备交付。

用户提供的《Claude Code完全教程》展示了中文环境下的具体操作路径,包括上下文管理、CLAUDE.md、Auto Memory、Skills、MCP、Subagents、Hooks 和插件。报告将这些路径置于官方产品架构中解释,避免把某位作者的个人阈值或便捷做法误写成产品硬规则。

截至检索日期,Claude Code官方将其描述为能读取代码库、编辑文件、运行命令并与开发工具集成的 agentic coding tool,可在终端、IDE、桌面和浏览器使用。选择界面时应首先考虑代码和依赖在哪里、是否需要本地服务、任务是否长时间运行、结果怎样审查。

终端适合完整命令行循环,IDE适合围绕当前文件和符号协作,桌面适合管理多个项目和会话,Web适合远程与后台任务。界面之间的差异不是简单偏好,而是权限、文件、网络和持续运行环境的差异。

选择 Claude Code 界面,本质是在选择任务的执行环境和控制面。

资料依据:Claude Code Docs:Overview;用户提供《Claude Code完全教程》

10.2 从问题到可验证变更的工程闭环

Claude Code最值得形成团队共识的不是某个命令,而是一套标准闭环。以下以“修复一个跨文件的登录状态 Bug”为例说明。

  1. 明确现象与范围:给出错误日志、复现步骤、受影响版本和不能改变的行为。

报告插图 7

图 10-1 Claude Code 的智能体闭环:收集上下文、执行行动、验证结果并循环修正

来源:Claude Code 官方文档,How Claude Code works(检索日期:2026-08-10)

  1. 探索代码库:定位入口、状态流转、相关测试和历史实现,不急于编辑。

  2. 形成计划:说明根因假设、预计修改文件、兼容性风险和验证方式。

  3. 实施最小改动:保持变更聚焦,避免顺便重构无关代码。

  4. 运行验证:先跑针对性测试,再运行受影响模块的更广检查。

  5. 检查 diff:确认没有秘密、调试代码、无关格式变化和遗漏文件。

  6. 准备交付:总结根因、修改、验证、剩余风险,创建提交或 PR 草稿。

人在闭环中的关键职责是确认范围和取舍。智能体可以给出多个实现方案,但接口兼容、迁移节奏、性能预算和产品行为往往需要业务或架构判断。高质量协作不是让人手写每一行代码,而是让人把决策放在高杠杆节点。

团队应把闭环固定为共同操作语言:先明确现象、范围和不可改变行为,再定位代码与测试,形成根因假设和计划,实施最小修改,运行针对性与扩展验证,检查 diff,最后总结依据、证据和剩余风险。

如果没有真实验证,Claude Code仍可能生成看似合理但不兼容的代码。测试失败、依赖缺失和环境差异应直接呈现;任务结束时不仅要给结果,还要列出未运行的验证和需要人工判断的取舍。

阶段 智能体动作 人类控制点 可验证证据
理解 读取仓库、规则、问题 确认目标范围 计划/引用文件
修改 编辑代码与配置 高影响决策 diff
验证 运行测试和检查 判断例外 测试日志
审查 解释改动和风险 批准合并 审查记录
移交 整理提交/PR 决定发布 提交与回滚说明

Claude Code 的交付单位应是“带验证证据的变更”,不是代码片段。

10.3 怎样下达高质量工程任务

工程任务输入应包含目标、现象、边界、约束和完成标准。不要只写“修复登录 Bug”,可以写成:“复现退出后页面仍显示已登录的问题;定位根因并做最小修复;不要改变登录 API;补充回归测试;运行 auth 模块测试和 lint;最后给出 diff 摘要与未解决风险。”

上下文可以由多种材料组成:本地文件、图片、终端错误、日志片段、Issue描述和多行要求。提供材料时要说明它们的地位,例如“日志是生产环境证据”“截图用于复现视觉问题”“设计文档只作为参考,现有 API 不得修改”。

实操建议|先要求 Claude Code“只读探索并给出计划”,确认范围后再允许写入。对大型任务,把每个里程碑的完成标准写进同一会话,避免结果只停留在代码生成。

高质量任务要说明问题如何复现、受影响范围、已有日志、不能改变的接口、允许修改的目录、测试命令和最终交付。对大型任务先要求只读探索和计划,可以显著减少智能体在错误假设上大量修改。

图片、日志、Issue和设计文档的地位要说明清楚,避免系统把参考方案当成必须实现的要求。涉及新依赖、数据库迁移、公开 API和生产配置时,应设置单独批准点。

层级 示例写法
目标 修复导入流程在空表头下崩溃的问题
范围 只修改 importer 与相关测试;不改公共 API
约束 遵守 CLAUDE.md;不访问生产数据
验证 复现失败;单元测试;完整测试;说明兼容性
停止 需要改数据模型或权限不足时先询问

输入越接近工程任务书,输出越接近可合并变更。

10.4 上下文窗口、压缩与会话续接

当前会话上下文是 Claude Code 的工作内存,包含目标、打开或读取的文件、工具结果、日志和对话历史。上下文并非无限,日志和搜索输出过多时会稀释真正重要的信息。可以通过 /context 等界面了解构成,通过阶段性总结或 /compact 压缩历史。

压缩不是简单“删掉旧消息”,而是把关键事实、决策和进度提炼后继续。实践中应在自然里程碑压缩:根因已经确认、方案已经决定、第一阶段验证完成。教程中作者可能在某个占用比例主动压缩,这可以作为个人习惯,但不应写成产品统一阈值。

任务彻底转向时应清理当前上下文,避免旧目标干扰;需要续做时应恢复历史会话。阶段摘要应至少保存:当前目标、已修改文件、验证结果、未完成事项、已否决方案和下一步。

长日志、重复搜索和无关文件会增加上下文压力。自然里程碑包括根因确认、方案决定、阶段验证完成和任务转向。在这些位置形成摘要,比等到上下文接近极限再被动压缩更可靠。

续接摘要应保存目标、已修改文件、关键决策、测试结果、未完成和下一步。教程中的具体占用比例可以作为个人习惯,但不应当作产品统一阈值;应以任务结构和信息质量决定压缩时机。

压缩的目标是保存任务状态,而不是简单减少字数。

10.5 CLAUDE.md、Rules 与持久项目指令

CLAUDE.md 最适合保存跨任务稳定成立的工程事实,例如构建和测试命令、目录职责、架构约束、依赖策略、禁止修改的接口和交付要求。临时需求、一次性调试过程和容易过期的状态不应长期堆积其中。

大型代码库可以按目录分层维护规则:根目录描述全局约束,子目录补充局部约定。更具体的规则应服务于明确边界,不能通过重复和冲突让智能体猜测优先级。团队需要定期清理失效规则。

项目指令应尽量短而可执行。与其写“保持高质量”这样的口号,不如明确测试命令、格式化工具、允许修改的目录和兼容性要求。规则变更也应像代码一样经过审查,并用代表性任务验证。

CLAUDE.md用于保存每次会话都应知道的项目事实和工作约定。官方文档区分组织策略、用户指令、项目指令和本地指令等范围。项目级文件适合纳入版本控制,记录构建与测试命令、目录结构、架构约束、代码风格和审查清单;本地文件适合保存个人机器相关但不应共享的偏好。

好用的 CLAUDE.md 应具体、简洁、无冲突。写“修改 JavaScript 后运行 npm test”比“认真测试”更可执行;写“API handler 位于 src/api/handlers/”比“保持结构清晰”更有帮助。过长文件会占用上下文并降低遵循度,多步骤操作应迁移到 Skill,特定目录规则可以使用路径范围配置。

CLAUDE.md是上下文,不是强制执行器。若某个动作无论模型如何判断都必须禁止,应通过权限规则或 PreToolUse Hook拦截。团队需要定期清理过时指令,避免根目录和子目录文件互相矛盾。

CLAUDE.md适合核心项目事实、构建命令和始终适用的规则;路径范围的 Rules适合特定语言、目录或组件;较长参考和流程应移到 Skills。官方扩展指南建议保持 CLAUDE.md聚焦,避免所有内容每次都进入上下文。

团队要将指令视为代码资产:审查变更、清理过时内容、解决冲突并用真实任务验证遵循。安全硬约束仍需要 Hook、权限或 CI,而不应只用自然语言声明。

CLAUDE.md 是项目宪法的摘要,不是知识仓库或强制执行器。

资料依据:Claude Code Docs:Features Overview;Memory / CLAUDE.md

10.6 Auto Memory、会话历史与知识沉淀

Auto Memory由 Claude 根据纠正、偏好和工作过程自动记录,适合保存构建命令、调试线索和重复出现的经验。它与 CLAUDE.md互补:前者是 Claude写的学习笔记,后者是人明确维护的项目约定。两者都会进入每次会话的上下文。

自动记忆的好处是减少重复解释,风险是错误经验可能被长期保留。因此用户应能查看、编辑和删除记忆;不应把秘密放入记忆;对必须遵守的安全要求和团队规范,仍应使用可审查的项目指令或权限机制。

Auto Memory适合保存重复出现的构建线索、偏好和项目经验,但自动写入内容可能过时或错误。用户需要能够查看和纠正,不应让秘密进入记忆。对于团队底线,仍要写入可审查规则。

知识沉淀应经过选择:一次调试细节保留在会话,反复出现的经验进入记忆,稳定规则进入 CLAUDE.md,多步骤方法进入 Skill,机械检查进入 Hook。分层可以减少上下文噪声。

把经验放到正确层,比单纯增加长期记忆更重要。

10.7 Skills:按需加载知识与工作流

Skill 适合承载会重复出现但不必每次占用主上下文的方法,例如发布检查、数据库迁移评审、故障复盘和依赖升级。说明文件定义触发条件与步骤,脚本、模板和参考资料则作为按需资源加载。

高质量 Skill 应清楚说明适用场景、输入、输出、前置条件、允许工具、验证方式和失败处理。触发描述过于宽泛会造成误调用,过于狭窄则难以复用;两者都需要通过真实任务校准。

Skill 发布前应在干净环境中测试,并记录负责人、版本、依赖和回滚方式。团队还需要检查其中的脚本和外部资源,防止技能包成为绕过项目规则或引入供应链风险的隐蔽入口。

Skills用 SKILL.md封装指令、资源和可选脚本。Claude可以根据描述自动加载,也可以由用户通过 /skill-name直接调用。与 CLAUDE.md不同,Skill正文只在实际使用时进入上下文,因此适合较长的检查清单、发布步骤、审查流程和领域知识。

一个好的 Skill 应说明何时使用、需要什么输入、执行哪些步骤、产生什么输出、如何验证、什么情况停止。支持文件可以包含模板、示例、脚本和参考资料。个人技能适合跨项目复用,项目技能适合随仓库共享,成熟后可装入插件分发。

例如“审查未提交变更”Skill可以先动态读取 git diff,再从功能正确性、测试、秘密、性能和兼容性五个维度输出风险。团队可以用真实 PR 建立评测集,持续迭代触发描述和检查清单,而不是只凭一次使用感觉判断质量。

Claude Code Skills可作为参考知识或可调用流程,默认只在使用时加载完整内容。官方扩展指南将其视为最灵活的扩展:既可由用户命令调用,也可由 Claude根据描述选择,还可在隔离上下文中运行。

团队应优先把反复复制的流程和较长参考转成 Skill,避免 CLAUDE.md膨胀。Skill描述要能区分相邻场景,步骤要包含验证和停止,脚本要审查。

Skill 让项目知识按需进入上下文,也让重复工作具备版本和评测对象。

资料依据:Claude Code Docs:Skills;Features Overview

10.8 MCP:连接 Issue、监控、数据库与设计系统

MCP 把外部系统能力暴露为结构化工具,但连接成功并不等于可以无限授权。每个工具都应采用窄参数、明确副作用、稳定错误返回和可回读结果,使智能体能够验证真实状态。

面向 Issue、监控和数据库的连接应使用专用身份与最小权限,写操作默认限制范围或进入审批。来自外部系统的文本仍是不可信输入,不能因为经过 MCP 返回就被当成系统指令。

MCP让 Claude Code连接问题跟踪、监控、数据库、设计、消息和自定义 API。当团队经常把 Jira、Sentry、Figma或 Slack内容复制到对话中时,MCP可以把“复制粘贴”变成可授权、可调用的工具接口。

连接工具后,任务可以跨系统闭环:读取 Jira Issue,查看 Sentry错误,修改代码,运行测试,在 GitHub创建 PR,并生成待人工确认的沟通草稿。MCP同时扩大了攻击面,因为服务器可能返回外部不可信内容,也可能拥有写入能力。

使用 MCP前应确认服务器来源、传输方式、OAuth范围、可用工具、输出上限和审计方式。对数据库写入、消息发送、生产操作等工具设为每次询问或禁止;对输出很大的工具设置范围过滤,避免上下文被数据淹没。

MCP可以减少复制粘贴,让 Claude Code直接读取 Issue、Sentry、数据库、设计和消息系统。真实闭环可能从错误工单开始,读取监控证据,修改代码,运行测试,再生成 PR和沟通草稿。

连接前要审查服务器来源、OAuth范围、工具写入能力、输出大小和日志。外部系统返回内容不可信,生产写入和对外发送应保持审批。Skill可以补充如何使用 MCP的领域知识,但不能替代 MCP层的权限。

MCP 扩大上下文和行动半径,也把外部系统风险带入工程会话。

10.9 Subagents 与 Agent Teams

Subagent 适合边界清楚的探索、测试或审查任务。主会话应提供目标、必要材料、允许工具和期望输出,子智能体则在隔离上下文中工作并返回证据,避免把全部过程噪声带回主线。

Agent Teams 由多个独立会话共享任务和消息,适合真正可以并行且需要相互讨论的复杂工作。它仍属于需要谨慎评估的协作方式;若任务无法清楚拆分,通信、冲突和合并成本可能高于速度收益。

Subagent是在独立上下文中执行特定侧任务的专业智能体。它适合处理会产生大量搜索结果、日志或文件内容的工作,最终只把摘要返回主会话。每个 Subagent可配置专门的系统提示、工具、权限、模型和持久记忆。

典型用法包括 Explore负责定位代码,Test负责补充和运行测试,Security Reviewer负责检查风险。只有输出边界清晰的任务才适合委派;多个 Subagent同时编辑强耦合文件会增加冲突。若需要多个完整会话并行、互相协调或长时间运行,应考虑背景 Agents或 Agent Teams,而不是把所有并行都塞进单个会话。

成本控制同样重要。探索可使用更快、更便宜的模型,关键架构和最终审查使用更强模型。子智能体要限制工具和目录,不应默认继承超过任务所需的权限。

Subagents在独立上下文运行并返回摘要,适合探索、测试和审查;Agent Teams由多个独立 Claude Code会话共享任务并直接通信,适合竞争假设和复杂协作。官方文档同时提示 Agent Teams属于实验性并默认关闭,实际部署应核验当前限制。

主会话要保留全局目标和合并责任。子角色应限定工具、目录和输出,避免多个代理同时修改强耦合文件。并行收益需要用实际周期、成本和返工衡量。

先用 Subagent隔离上下文,只有需要会话间协商时再考虑 Agent Team。

资料依据:Claude Code Docs:Subagents;Agent Teams;Features Overview

10.10 Hooks:确定性自动化与安全门

Hooks 适合必须稳定执行的检查,例如命令阻断、格式化、测试、日志记录和通知。它们由生命周期事件触发,不依赖模型临时判断,因此可以作为智能体流程中的确定性安全门。

Hook 的失败策略需要明确:阻断型检查失败时应停止后续动作并返回原因,提示型检查则记录问题但允许继续。脚本必须设置超时、输出限制和可诊断错误,避免自身成为任务卡死点。

团队应把 Hook 与普通项目脚本一起测试和审查。涉及文件修改、网络请求或秘密的 Hook 需要更高权限审查,并应确保触发时机不会重复执行产生副作用。

Hooks是在 Claude Code生命周期特定节点自动运行的命令、提示、Agent或 HTTP动作。它们提供确定性控制:编辑后自动格式化、提交前运行 lint与测试、阻止修改受保护文件、上下文压缩后重新注入关键信息、任务结束时发送通知。

Hooks适合硬约束和机械动作,不适合承载复杂的自然语言判断。一个 Hook必须处理超时、退出码和失败信息;脚本本身需要纳入版本控制与代码审查。来自第三方插件的 Hook等同于会自动执行的代码,应在安装前审查。

官方扩展指南把 Hook与 Skill明确区分:Hook在匹配事件必然触发,适合 lint、阻断危险命令、日志和通知;Skill由 Claude解释,适合需要推理和知识的流程。PreToolUse可以把“不要读秘密”变成技术阻断。

Hook输出可能进入上下文,脚本可能访问文件和网络。设计时要控制输出、超时和失败模式,安装第三方 Hook前视同自动执行代码进行审查。

必须保证的机械控制写成 Hook,不能只写进提示。

资料依据:Claude Code Docs:Hooks;Features Overview

10.11 Plugins 与 Marketplace:团队分发层

插件可以把 Skills、Agents、Hooks、MCP和其他组件装入一个可安装、可版本化的包。独立 .claude/配置适合个人或单项目实验;当能力需要跨项目复用、团队共享、版本更新或通过 Marketplace分发时,插件更合适。

安装插件前应查看它包含哪些命令、Agents、Skills、Hooks、MCP/LSP服务器、上下文成本和更新时间。官方 Marketplace提供 curated目录,但任何扩展都可能带来指令、脚本、依赖和网络访问,不能把“在市场上”理解为适合本组织所有环境。

成熟路径通常是:先在项目内做一个 Skill或 Hook,使用真实任务验证;再把相关能力组合为插件;最后建立版本、变更记录、责任人、回滚方式和允许安装范围。

Plugin把多个扩展打包为可安装单元,适合跨仓库、团队和组织分发。命名空间可以减少技能名称冲突,Marketplace提供发现和更新路径。成熟流程通常先在项目内验证单个 Skill或 Hook,再组合成插件。

团队应为插件建立允许来源、版本、责任人、变更记录、权限说明和回滚。市场存在并不等于经过本组织风险评估;尤其要检查自动 Hook、MCP服务器和安装依赖。

插件是软件产品,需要发布工程和供应链治理。

10.12 权限、安全与可信执行

Claude Code默认以权限为基础运行。读取通常风险较低,编辑、命令执行和外部工具需要更明确的授权;沙箱可限制 Bash命令的文件系统和网络范围。安全目标不是让智能体永远不犯错,而是让错误被限制在可恢复、可审查的区域。

提示注入可能来自 Issue、网页、文档、代码注释、邮件或 MCP返回。不能只依赖模型识别攻击。应把外部内容视为不可信输入,限制凭据与网络,审查高影响命令,验证关键文件变化,并在必要时使用 VM或隔离环境运行第三方脚本。

团队使用时还要处理供应链问题:Skills、Plugins、Hooks和 MCP服务器可能执行代码或访问数据。建立允许来源、版本锁定、审查与更新机制,比单纯培训用户“谨慎点击”更可靠。

Claude Code能读取代码、执行命令和连接外部系统,风险来自不可信内容与高权限工具的组合。Issue、网页、代码注释和 MCP结果可能诱导系统越权,不能只依赖模型自我识别。

安全基线包括先读后写、最小目录和命令、受限网络、秘密隔离、高影响动作确认、隔离运行第三方脚本、扩展来源审查以及 diff和测试证据。权限应与任务阶段匹配,而不是一次授权整台机器。

能力越接近真实开发环境,越要用技术边界保护人类意图。

资料依据:Claude Code Docs:Security

10.13 团队采用路线与资产体系

团队要把 Claude Code 从个人效率工具转变为可持续工程能力,首先需要分开建设代码库基线、任务基线和扩展基线。三类基线分别回答“系统应遵守什么”“交付怎样验收”和“哪些能力可以被重复调用”。

代码库基线应包含 CLAUDE.md、构建与测试命令、目录边界、依赖策略和敏感信息规则;任务基线应沉淀缺陷修复、测试补充、文档更新和依赖升级等代表性任务,并保留成功与失败样本。

Skills、Hooks、MCP、Subagents 和插件属于扩展基线。它们需要明确负责人、来源、版本、权限、测试和回滚方式,避免个人脚本在没有审查的情况下演变为团队关键路径。

Claude Code团队试点可以从一个代码库和两类任务开始:修复小范围 Bug、补测试或更新文档。先建立项目 CLAUDE.md和基础验证命令,要求所有交付包含 diff摘要与测试证据。两到四周后再把高频流程做成 Skills,把必须执行的检查做成 Hooks,把外部系统通过受控 MCP接入。

  • 开始前:确认仓库状态、任务范围、允许修改目录、依赖安装规则和禁止事项。

  • 探索时:先读后写,记录根因假设,不把第一种方案当成结论。

  • 修改时:保持最小 diff,不顺手改无关文件,不隐藏失败。

  • 验证时:运行针对性测试、受影响模块检查、格式化和静态分析。

  • 交付时:说明修改、依据、验证、剩余风险和需要人工判断的内容。

  • 扩展时:第三方 Skills、Plugins、Hooks、MCP先审查来源、脚本、权限和更新机制。

第一阶段选择一到两个仓库和小任务,完善 CLAUDE.md、构建测试和交付格式;第二阶段把重复流程做成 Skills,把必须检查做成 Hooks;第三阶段连接受控 MCP和专业 Subagents;第四阶段再推广插件和并行团队。

资产目录应记录规则、Skills、Hooks、MCP、插件、责任人、版本和评测结果。没有责任人的扩展会逐渐过时,最终成为隐藏风险。

Claude Code 规模化依赖可复用工程资产,而不是每个人自己摸索。

10.14 案例:跨文件登录缺陷修复

案例开始前应先建立基线:在未修改代码的状态下复现退出后仍显示登录状态的问题,保存失败步骤、控制台输出和相关测试结果。只有基线稳定,后续修复才有可比较的证据。

探索阶段可以并行检查缓存失效逻辑、路由守卫和认证状态同步,但修改阶段应回到单一主线,优先选择影响范围最小且能够被自动测试覆盖的方案。并行探索不等于并行写入同一组文件。

验证需要从直接相关的单元测试开始,再扩展到跨标签页、刷新、网络中断和移动端等场景。若测试暴露数据模型或公共接口问题,应暂停自动修改,整理证据并把架构取舍交给维护者决定。

交付物不能只有代码 diff,还应包含复现方式、根因判断、修改范围、执行过的测试、仍未覆盖的风险和建议的回滚路径。审查者应能够在不重放完整会话的情况下理解证据链。

如果修复依赖新的浏览器行为、第三方认证服务或尚未确认的产品规则,Claude Code 应把这些内容明确标为外部假设。系统可以继续准备方案和测试,但不应把未经确认的假设写成既定事实。

任务要求复现退出后页面仍显示登录状态的问题,不改变认证 API,补充回归测试,运行 auth模块测试和 lint,并给出 diff摘要。第一轮只读探索定位状态缓存、路由守卫和相关测试,形成两个根因假设;人确认兼容要求后再修改。

实施时由主会话修改缓存失效逻辑,测试 Subagent补充退出与跨标签页用例,PostToolUse Hook运行格式化和局部 lint。测试失败揭示模拟时钟未恢复,系统修正测试夹具后重新验证。最终交付列出根因、三处修改、测试命令、未覆盖的移动端风险和回滚方式。

案例说明,最有价值的不是一次生成正确补丁,而是智能体能够通过真实失败收敛,并把人工判断集中在接口行为和风险取舍。

工程闭环把模型的不确定性包裹在可观察、可修正、可审查的流程中。

11. Codex 深度解析

Codex 通过 CLI、IDE、桌面应用、工作树和云任务组织工程工作,使本地即时协作、隔离并行执行与后台长任务能够在同一体系中衔接。

理解 Codex 需要同时观察项目规则、记忆、计划、工作树、子智能体、扩展机制、沙箱和审批,而不能只把它看成单一终端工具。

11.1 产品定位:在项目、工具和云端之间组织工程工作

Codex是 OpenAI面向软件开发的工程智能体,可在桌面应用、CLI、IDE和云端环境中理解代码库、编辑文件、运行本地工具、审查变更并处理长任务。当前产品体验正在与 ChatGPT桌面、Web和 Work能力融合,但 Codex仍以代码库、开发工具和可验证变更为核心。

用户提供的《Codex全解》强调 Local与 Worktree的“前台/后台”关系、上下文和三类持久信息、大型项目计划、Skills/CLI/插件/MCP以及自动化任务。本报告保留这些易理解的中文操作框架,同时用官方文档区分环境边界、指令与记忆、沙箱与审批。

报告插图 8

图 11-1 Codex 应用的官方产品发布页

来源:OpenAI, Introducing the Codex app(检索日期:2026-08-10)

Codex可在本地和云环境理解代码库、编辑文件、运行工具、审查变更和处理长任务。桌面应用更强调项目、多个 chat、Worktree、Handoff和后台工作;CLI与 IDE贴近现有开发循环;Cloud提供远程隔离环境和集成入口。

用户提供的《Codex全解》用“前台 Local、后台 Worktree、远程 Cloud”解释环境关系,适合操作理解;报告同时按官方文档校准 AGENTS.md、Subagents、Worktrees、沙箱与审批等当前机制。

Codex 的核心是把工程目标、项目规则、执行环境和验证证据组织在同一任务中。

资料依据:OpenAI Codex官方文档;用户提供《Codex全解》

11.2 Local、Worktree 与 Cloud:三类环境如何选择

在桌面应用中,Codex任务可以运行在 Local、Worktree或 Cloud环境。Local直接操作当前项目目录,适合人与智能体快速交替、需要本地调试或依赖当前机器状态的任务;Worktree在同一台电脑上创建隔离的 Git工作副本,适合多个任务并行而不干扰主工作区;Cloud在配置好的远程环境中运行,适合后台长任务和多个独立尝试。

教程用“前台与后台”解释 Local和 Worktree很直观:Local是人正在操作的前台,Worktree是不打断当前工作的后台。但 Worktree并非云端;Local与 Worktree都在本机。Cloud才是独立远程环境。

Local适合需要当前机器状态、人机快速交替和本地调试的任务;Worktree适合同一仓库多个任务并行,避免直接干扰主工作区;Cloud适合独立配置、长时间运行和远程委托。Local与 Worktree都在本机,Cloud才是远程执行。

环境选择要核对依赖、秘密、网络、被忽略文件、服务和验证工具。不能因为任务在独立环境运行就忽略数据和权限,也不能假设本地可用的状态会自动出现在 Worktree或 Cloud。

形态 适合任务 环境特点 协作方式
CLI 当前仓库快速修改 本地终端 即时对话
IDE 边编码边委托 编辑器上下文 局部审查
桌面应用 并行任务与工作树 隔离 checkout 任务管理与交接
云任务 长时、后台、可并行 隔离云环境 异步回收结果

先选择正确环境,再选择模型和工作方式。

11.3 CLI、IDE、桌面与云端控制面

Codex CLI适合终端中的聚焦循环:启动于仓库目录,探索代码、规划修改、编辑文件、运行本地工具,并在同一会话中审查命令和 diff。codex exec等非交互方式可嵌入脚本与 CI,但必须为失败、输出格式和权限设置明确约束。

IDE扩展适合围绕当前打开文件、选区和符号做局部协作,减少切换成本;桌面应用更适合跨项目管理多个任务、审查结果、安排 Worktree和 Scheduled任务;Cloud为长任务提供隔离环境,可从 Web、GitHub、Linear或 Slack发起,完成后审查摘要和 diff再合并。

多个界面不是重复产品,而是同一工程工作的不同控制面。一个常见路径是:IDE中发现问题并澄清局部上下文,桌面端在 Worktree中委托实现,CLI中做本地复现或细调,最后在桌面或 GitHub审查 diff和 PR。

CLI适合命令行和脚本化工程循环,IDE适合当前文件与符号,桌面适合跨项目管理和并行任务,Cloud适合后台执行与外部触发。一个任务可以在不同控制面之间移交,但目标、环境和验证状态应保持一致。

常见路径是 IDE中澄清局部问题,桌面将实现放入 Worktree,CLI本地复现和细调,最后在桌面或 GitHub审查 diff。界面切换应服务于证据和环境,不应造成上下文断裂。

多个控制面不是重复功能,而是工程任务在不同阶段的入口。

11.4 Codex 的标准工程闭环

Codex同样应以“可验证变更”而非“生成代码”作为交付目标。以下是一个推荐闭环。

  1. 在任务开头写明目标、范围、不可修改项、验证命令和停止条件。

  2. 检查 AGENTS.md、Git状态、项目结构和现有测试,形成只读探索结果。

  3. 对复杂任务先进入计划,明确里程碑、依赖和验收,再开始写入。

  4. 选择 Local、Worktree或 Cloud,保证执行环境与所需工具和数据一致。

  5. 实施最小变更,及时运行针对性验证,并根据真实输出修正。

  6. 检查 diff、测试、静态分析、生成文件和依赖变化,避免无关修改。

  7. 形成可审查交付:摘要、验证证据、风险、未完成事项和合并建议。

如果任务中途改变目标,应显式重置计划或开启新线程;如果只是延续同一问题,则保持在同一线程以利用已有上下文。工程协作的关键不是连续聊天,而是让任务状态、环境和验证证据保持一致。

Codex开始工作前应读取项目规则和 Git状态,复杂任务先形成计划,选择 Local、Worktree或 Cloud后再实施。过程中运行真实测试和工具,根据输出修正;交付时提供 diff、验证、未完成和风险。

任务中途如果目标彻底改变,应开启新 task或重置计划;同一问题的延续则保持在同一 task,利用已有上下文。Handoff改变运行位置,不应改变完成标准。

阶段 智能体动作 人类控制点 可验证证据
理解 读取仓库、规则、问题 确认目标范围 计划/引用文件
修改 编辑代码与配置 高影响决策 diff
验证 运行测试和检查 判断例外 测试日志
审查 解释改动和风险 批准合并 审查记录
移交 整理提交/PR 决定发布 提交与回滚说明

任务状态、执行环境和验证证据一致,是 Codex 闭环的核心。

11.5 AGENTS.md:全局与项目规则的指令链

Codex 会沿目录层级发现项目指令:全局配置提供通用约束,项目根目录定义仓库规则,更深目录可以补充局部要求;更具体的指令在发生冲突时具有更高优先级。AGENTS.override.md 可用于明确覆盖。

当前官方说明还给出了默认指令链大小限制,因此 AGENTS.md 不应成为无限增长的知识仓库。构建命令、目录边界、验证要求和安全规则适合写入;动态进度、长篇背景和一次性任务材料应保留在任务上下文或项目文档中。

团队应把 AGENTS.md 纳入代码审查:新增规则要说明解决的问题,删除规则要确认没有依赖,目录级规则要通过对应模块的真实任务验证。规则本身也需要版本、责任人和失效清理机制。

Codex在开始工作前读取 AGENTS.md。全局范围位于 Codex home目录,适合个人通用偏好;项目范围从项目根目录向当前工作目录逐层发现,越靠近当前目录的文件越具体。AGENTS.override.md可覆盖同层基础文件,用于特殊目录或临时规则。

项目级 AGENTS.md应记录仓库结构、构建和测试命令、依赖管理、代码风格、禁止事项、审查标准和交付格式。它最适合必须稳定加载、能被团队审查并随仓库版本化的规则。对代码审查,可以在最接近相关代码的文件中定义 Code Review Rules。

AGENTS.md不宜塞入很长的操作手册。重复流程适合 Skill,外部工具适合 MCP或插件,机械强制适合 Hook或权限规则,项目设置适合 config.toml。把不同类型信息放到正确表面,可以降低上下文成本和冲突。

官方文档说明 Codex在开始工作前读取 AGENTS.md,并从全局范围到项目根再到当前目录构建指令链。更接近当前目录的文件更具体,AGENTS.override.md可替代同层基础文件。组合大小存在配置上限,过长内容应拆分。

项目文件应记录构建测试、目录结构、依赖规则、禁止事项和交付标准。团队要避免根目录和子目录矛盾,特殊临时要求用 override并在完成后清理。

AGENTS.md 把团队工程约定变成每次任务的稳定起点。

资料依据:OpenAI官方文档:Custom instructions with AGENTS.md

11.6 Local Memories:软回忆与硬规则的分工

Local Memories是可选的本地回忆层,默认关闭。启用后,Codex可以从符合条件的历史对话中提炼有用上下文,在会话空闲后后台更新,而不是每次会话结束立即写入。主要文件保存在 Codex home下的 memories目录。

每个会话可以控制是否使用既有记忆,以及当前会话是否成为未来记忆的输入。自动记忆会尝试过滤秘密,但在共享 Codex home或导出记忆前仍需人工检查。记忆文件属于生成状态,不应作为团队硬规则的唯一来源。

最重要的区分是“硬规则/软回忆”:AGENTS.md是明确维护的工作约定,Local Memories是从历史中提炼的参考。必须运行的测试、禁止删除文件等规则应留在 AGENTS.md、权限或 Hook中,而不能只依赖记忆。

Local Memories适合从历史任务提炼可参考上下文,但不应成为团队硬规则的唯一来源。任务可以选择是否使用记忆和是否成为未来记忆输入;共享或导出前需要检查秘密和个人信息。

必须运行的测试、禁止操作和架构底线写入 AGENTS.md、Rules或 Hook;经验、偏好和历史线索可进入 Memories。定期审查过期和冲突内容,防止错误经验长期影响。

硬规则由人维护并可审查,软回忆帮助减少重复解释。

11.7 Plan、Goal 与长任务

复杂项目的首要风险不是执行慢,而是方向错误。Plan阶段应通过问答确认用户、范围、依赖、架构约束、里程碑和完成标准。计划不是装饰性的任务列表,而是后续判断“下一步做什么、何时完成”的依据。

对于需要很多步骤的工作,官方文档建议给出清晰结果、约束和定义完成,并把相关工作留在同一 chat中。桌面应用可使用 Goal模式跟踪持续目标;Web中的长任务则把结果和评审标准直接写进 prompt。

长任务需要里程碑而不是无限循环。每个里程碑应产生可验证产物,例如架构方案、可运行原型、测试覆盖、迁移脚本和回滚说明。遇到证据冲突、权限不足或关键决策时,应暂停并向人请求判断。

复杂任务先通过 Plan确认范围、依赖、架构、里程碑和完成标准。计划应随证据更新,而不是一次生成后不再使用。长期目标需要阶段产物、预算和停止条件,避免无限推进。

桌面环境中的 Goal或长任务机制适合持续跟踪,但仍要把关键状态写入可恢复摘要。遇到权限不足、证据冲突和业务取舍时应请求人工输入,而不是自主扩大范围。

长任务的可靠性来自里程碑与状态,不来自更长的单次运行。

11.8 Worktrees 与 Handoff:本地并行的文件隔离

桌面应用中的 Worktree 为任务创建独立 checkout,并与主仓库共享 Git 元数据。任务可以并行读取和修改文件而不直接占用主工作区,但使用者仍需理解分支、提交和合并关系。

工作树通常处于 detached HEAD,完成后应通过 Handoff 把任务移回本地工作区或明确创建分支。由于同一分支不能同时在两个工作树中检出,交接前需要检查目标分支和未提交变更。

被 Git 忽略但任务运行必需的配置可以通过 .worktreeinclude 机制复制到新工作树。该机制不应复制秘密或机器专属状态;环境文件、依赖缓存和生成物需要分别制定安全策略。

Worktree利用 Git worktree为每个任务创建独立 checkout,使多个 Codex会话可以在同一项目并行而不直接修改主工作区。它们共享 Git元数据但拥有独立文件副本,适合实现不同功能、比较方案和运行后台任务。

Codex管理的 Worktree通常从所选分支 HEAD开始,并可把本地未提交变化应用到新 Worktree。被忽略但运行所必需的文件可通过 .worktreeinclude选择性复制。不要把所有 .env和秘密无差别复制;只包含任务真正需要的路径。

Worktree的常见坑包括同一分支不能同时在多个工作树 checkout、依赖与缓存占用磁盘、忽略文件缺失导致无法运行、结果完成后没有移交回 Local。Handoff用于在 Local与 Worktree间移动会话,比手工抢占同一分支更安全。

官方文档指出,桌面应用中的 Worktree让多个独立 chat在同一 Git项目并行而不互相干扰;它有独立文件副本并共享 Git元数据。Handoff用于在 Local与关联 Worktree间安全移动 task和代码。

被忽略但运行必需的文件可通过 .worktreeinclude选择性复制,不能无差别复制秘密。同一分支不能同时在多个 worktree checkout,结果完成后要创建分支、移交 Local或在原 worktree验证。

Worktree 解决并行修改隔离,Handoff解决前台与后台的安全移交。

资料依据:OpenAI官方文档:Worktrees

11.9 Subagents:探索、测试与审查的并行角色

Codex Subagents适合代码库探索、独立测试、安全审查和资料检索等可独立验收的侧任务。主智能体保持全局目标和合并责任,子智能体在独立上下文中工作后返回结果。

并行策略应遵循“最小依赖、清晰交付、独立验证”。例如一个子智能体只输出调用链地图,另一个补测试,第三个审查安全,而主智能体最终决定改动。多个子智能体直接编辑同一核心文件会增加冲突和认知成本。

子智能体继承当前沙箱策略,工具权限仍要按任务限制。团队应记录并发数量、模型成本、失败率和合并返工,不要把“更多 Agents”当成效率的自动来源。

Codex Subagents适合代码库探索、测试补全、安全审查和资料检索等有清晰输出的侧任务。主智能体负责全局目标和合并,子智能体返回证据与摘要。

配置角色时应限制任务范围和工具,避免多个子智能体修改同一核心文件。官方机制和当前可用界面可能随版本变化,实际并发和配置应以文档与当前环境为准。

Subagent 的价值是隔离高容量侧任务,不是把主任务责任分散。

资料依据:OpenAI官方文档:Subagents

11.10 Skills、Plugins、MCP 与 Hooks

Codex 的扩展机制可以按职责区分:Skills 描述可复用方法,Plugins 负责打包和分发,MCP 连接外部系统,Hooks 在生命周期节点执行确定性控制。把不同职责混在一个巨大脚本中会降低可审查性。

扩展的引入顺序应从最小表面开始。一次性要求先留在任务说明中,稳定项目规则进入 AGENTS.md,重复流程再沉淀为 Skill;只有确需外部系统或组织分发时,才增加 MCP 和 Plugin。

每项扩展都应有来源、负责人、版本、权限、测试和回滚记录。升级时不仅检查功能是否可用,还应检查工具参数、网络访问、凭据范围和默认行为是否发生变化。

最小表面原则有助于保持系统清晰:一次性要求放在 prompt或线程上下文;仓库规则放 AGENTS.md;重复流程做 Skill;需要统一安装和外部连接时做 Plugin/MCP;必须强制的生命周期动作做 Hook。混合需求可以拆分,不必强迫一个文件承担所有职责。

Skills遵循渐进加载,把主指令、参考和脚本按需要读取;插件适合跨项目和团队共享;MCP让 Codex访问第三方文档和工具;Hooks在工具调用、命令或文件编辑前后执行机械控制。任何扩展都可能扩大权限,安装前需要审查源代码、依赖、配置和数据范围。

一次性要求留在 prompt,仓库规则写入 AGENTS.md,重复流程做成 Skill,跨项目组合和分发使用 Plugin,外部工具通过 MCP连接,必须触发的机械控制使用 Hook。不同层可以组合,但应保持职责清楚。

插件和 MCP会扩大工具与数据边界,Hooks可能自动执行代码。组织需要扩展清单、来源审查、版本管理、权限说明和回滚。

把需求放到最小、最清晰的扩展表面,能降低上下文和治理复杂度。

11.11 用 Codex 构建 RAG 与项目知识库

在知识密集型项目中,Codex 更适合被定位为“项目代理层”:它读取需求与仓库,拆解数据摄取、检索、生成、评测和交付任务,调用工具实现代码并用测试验证结果;真正面向用户提供服务的 RAG 运行时,仍应由可部署、可观测、可审计的确定性组件承担。二者的关系不是“让 Codex 代替知识库”,而是让 Codex 组织并持续改进知识库工程。

推荐主线:需求 Prompt → Codex 拆解与计划 → 盘点数据和代码 → 实现摄取与检索 → 接入生成 → 评测与安全加固 → 交付,并把稳定规则沉淀到 AGENTS.md、Skill 或 Plugin。每一步都要有输入、产物、验证方式和停止条件。

11.11.1 RAG 的六层工程架构

RAG(Retrieval-Augmented Generation,检索增强生成)不是“上传文件后直接问答”,而是一条从数据治理到证据化回答的完整链路。下表给出最小可落地结构。

层次 关键任务 典型产物 主要验证
1 数据源 接入 PDF、Markdown、Notion/Confluence 导出、数据库、工单和代码仓库;识别时效与权限。 来源目录、采集清单、ACL 与更新时间字段 可访问性、权限正确性、增量更新
2 清洗 去页眉页脚与重复内容,恢复标题层级、表格和代码块,统一编码与格式。 清洗文档、解析报告、失败队列 抽样准确率、缺失率、重复率
3 分块 按章节和语义边界切分,保留标题、路径、时间、作者、权限和来源 URL。 Chunk 结构与元数据规范 边界完整、引用可定位、不过度切碎
4 索引 选择托管 vector store,或 pgvector、Qdrant、Chroma 等自管索引。 索引任务、向量与关键词字段 状态完成、覆盖率、更新与删除一致
5 检索 查询改写、元数据过滤、Top-k、混合检索和 rerank;先做权限过滤。 检索 API、排序策略、缓存 Recall@k、来源正确率、延迟
6 生成 向模型提供证据、引用、置信规则和拒答条件;避免证据外推。 回答 API、引用对象、拒答模板 有据性、引用正确率、拒答率与人工评审

选型上,OpenAI 托管 file_search 能以较少代码完成文件存储、语义与关键词检索,适合原型和快速交付;自管 pgvector、Qdrant 或 Chroma 更便于定制分块、排序、权限和部署边界,但需要承担索引生命周期、备份、监控与容量治理。选择标准应是数据合规、定制需求、运维能力和成本,而不是单纯追求组件数量。

11.11.2 把 Prompt 写成可执行的项目需求

不要只写“帮我做一个 RAG”。应把 Prompt 写成小型 PRD,让 Codex 能据此拆任务、识别边界并设计验收。以下模板可以直接作为项目启动提示。

代码清单 11-1 RAG 项目需求 Prompt

目标:
做一个面向内部工程文档的 RAG 问答服务。

背景:
文档位于 docs/ 和 Notion 导出目录;用户会询问部署、排障和接口规范。

范围:
- 支持文档导入、语义分块、向量化、检索和回答
- 回答必须附来源标题和 URL;无依据时明确拒答

非目标:
- 本期不做多租户;用户权限只保留接口和元数据字段

技术约束:
- 后端使用 FastAPI;向量库使用 pgvector
- 模型调用封装在 app/llm.py;引入重型框架前先说明理由

验收标准:
- pytest 通过;新增至少 3 个 RAG eval case
- 命中文档时返回可定位引用;无依据问题不得编造

执行方式:
先阅读仓库并给出可验证的子任务、风险、实现顺序和测试方案;
等待确认后再修改代码,完成时汇总改动、测试结果与剩余风险。

建议的仓库布局把数据摄取、检索、回答、评测和工具接入分开,避免把所有逻辑塞进一个脚本。AGENTS.md 记录长期工程约束,.codex/config.toml 连接项目工具,.codex/hooks/ 承担确定性检查。

代码清单 11-2 最小可维护的 RAG 项目目录

rag-project/
  app/ingest.py          # 解析、清洗、分块与入库
  app/retrieval.py       # 过滤、召回与重排
  app/answer.py          # 证据组装、引用与拒答
  app/api.py             # 服务接口
  app/schemas.py         # Chunk、Citation 等数据结构
  evals/cases.jsonl      # 问题、期望来源与判分规则
  tests/test_retrieval.py
  tests/test_grounding.py
  tools/internal-kb-mcp/server.ts
  .codex/config.toml
  .codex/hooks/
  AGENTS.md

11.11.3 使用 OpenAI file_search 快速建立托管知识库

托管方案的最小链路是:创建 vector store、上传文件、把文件加入存储、等待索引状态变为 completed,再通过 Responses API 的 file_search 工具检索。生产环境还需持久化文件与存储 ID,记录索引状态和失败重试,并为删除、版本更新、权限过滤和引用展示建立完整生命周期。密钥应来自环境变量或密钥管理系统,不得写入代码或报告。

代码清单 11-3 使用 vector store 与 file_search 的最小 Python 示例

from openai import OpenAI

client = OpenAI()
store = client.vector_stores.create(name="engineering-kb")

with open("docs/runbook.pdf", "rb") as f:
    uploaded = client.files.create(file=f, purpose="assistants")

client.vector_stores.files.create(
    vector_store_id=store.id, file_id=uploaded.id
)
# 查询前轮询文件状态,确认其已经 completed。
response = client.responses.create(
    model="<MODEL_ID>",
    input="部署失败时先检查什么?请给出来源。",
    tools=[{
        "type": "file_search",
        "vector_store_ids": [store.id],
        "max_num_results": 6,
    }],
    include=["file_search_call.results"],
)
print(response.output_text)

如果知识带有部门、项目或密级边界,应在索引元数据中保存 ACL,并在检索发生前做服务端授权与 metadata filter;不能依赖提示词要求模型“不要看无权内容”。检索结果数量可用 max_num_results 控制,评测时可通过 include 返回检索结果,定位召回和回答问题分别出在哪里。

资料来源:OpenAI, “File search”, https://developers.openai.com/api/docs/guides/tools-file-search/(核验日期:2026-08-19)。

11.11.4 让 Codex 分阶段实现并以评测收口

一个稳妥的实施顺序是:第一步只读盘点数据、权限和现有代码;第二步完成摄取与可重复索引;第三步建立关键词或向量检索基线;第四步加入回答、引用和拒答;第五步用固定问题集做检索与生成评测;第六步再进行性能、安全、监控和部署加固。每一阶段都要求 Codex 先运行最小验证,再进入下一阶段。

验收不应只看回答“像不像”。检索层至少记录 Recall@k、命中来源、权限过滤和延迟;生成层检查答案是否被证据支持、引用是否能定位到原文、无依据时是否拒答;工程层检查索引可重建、文档可更新和删除、失败可重试、日志不泄露敏感信息。把代表性失败案例写入 evals/cases.jsonl,才能让后续修改不反复退化。

11.12 MCP Server:把知识与工具接入工作流

MCP(Model Context Protocol)的价值是把 Codex 本地没有的知识和动作包装成边界清楚、输入输出稳定、可审计的工具。RAG 服务仍负责检索、权限和数据治理;MCP Server 只暴露完成任务所需的窄接口。可以把关系概括为:MCP 提供能力,AGENTS.md 或 Skill 规定何时、按什么顺序使用能力,Hooks 和审批机制负责硬约束。

11.12.1 先定义工具契约,再写服务器

工具应“一次只做一件事”,名称和描述要让模型能够正确选择;读取与写入动作分离,写入类工具默认要求确认。权限校验必须在服务器端执行,readOnlyHint、destructiveHint 等注解只是帮助客户端理解风险,不能替代鉴权。

工具 主要输入 输出 权限与审批
search_docs query、filters、top_k 片段、标题、URL、分数与文档 ID 只读;查询前做 ACL 过滤
get_doc doc_id 正文或受控摘要、元数据 只读;再次校验文档权限
list_sources 可选 source_type 可用语料库及更新时间 只读;隐藏无权语料库
create_eval_case question、expected_sources 评测用例 ID 与保存位置 写入;默认 prompt/人工确认

11.12.2 一个可运行骨架:TypeScript MCP Server

下面示例使用官方 MCP SDK,通过标准输入输出连接 Codex,并注册只读 search_docs 工具。searchIndex 是项目自己的检索适配器,应在其中完成身份识别、ACL 过滤、超时、审计日志和后端错误处理。返回结构同时提供 structuredContent 和文本内容,便于模型消费与程序化处理。

代码清单 11-4 internal-kb MCP Server 的最小实现

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer(
  { name: "internal-kb", version: "1.0.0" },
  { instructions: "Search before answering project questions; cite title and URL." }
);

server.registerTool("search_docs", {
  title: "Search internal documentation",
  description: "Use before answering project knowledge questions.",
  inputSchema: {
    query: z.string().min(3),
    source: z.string().optional(),
    top_k: z.number().int().min(1).max(20).default(6),
  },
  annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
}, async ({ query, source, top_k }) => {
  const chunks = await searchIndex({ query, source, top_k });
  return {
    structuredContent: { chunks },
    content: [{ type: "text", text: JSON.stringify(chunks) }],
  };
});

await server.connect(new StdioServerTransport());

实际服务器还应注册 get_doc、list_sources 和 create_eval_case,并为每个工具定义输入长度、分页、超时、错误码和审计字段。远程服务可使用 Streamable HTTP 暴露 /mcp;上线前用 MCP Inspector 或单元测试验证正常输入、非法输入、权限拒绝和后端超时。

11.12.3 在项目中配置 MCP,并用 AGENTS.md 固化工作流

Codex 的 MCP 配置可放在用户级 ~/.codex/config.toml,受信任项目也可使用项目级 .codex/config.toml。以下示例限制可见工具,并对只读搜索自动批准,对写入型 create_eval_case 保持默认询问。令牌只从环境变量读取。项目级配置会随仓库共享,因此只应在受信任项目中启用,并避免提交真实密钥。

代码清单 11-5 项目级 .codex/config.toml

[mcp_servers.internal_kb]
command = "node"
args = ["./tools/internal-kb-mcp/server.js"]
env_vars = ["KB_API_TOKEN"]
enabled_tools = ["search_docs", "get_doc", "list_sources", "create_eval_case"]
default_tools_approval_mode = "prompt"
startup_timeout_sec = 20
tool_timeout_sec = 30

[mcp_servers.internal_kb.env]
KB_API_URL = "https://kb.example.com"

[mcp_servers.internal_kb.tools.search_docs]
approval_mode = "approve"

若 Codex 不是从仓库根目录启动,应把 server.js 改成经过验证的稳定绝对路径或使用包装脚本解析项目根目录。配置完成后运行 codex mcp list 检查发现状态,再分别测试搜索、取全文、低相关结果、无权限文档、超时和写入审批。

代码清单 11-6 写入 AGENTS.md 的 RAG 工具规则

## RAG workflow
- 回答项目知识问题前,优先调用 internal_kb.search_docs。
- 每项事实必须引用 source title 和 URL,并保留 doc_id 便于追溯。
- 证据低于阈值、来源冲突或 ACL 拒绝时,不得猜测,应说明缺口。
- 需要全文时再调用 get_doc,避免无目的地读取大量内容。
- create_eval_case 会写入仓库,只有在用户确认后才能调用。
- 修改检索策略后运行 tests 与 evals,并汇报 Recall@k 和失败案例。

资料来源:OpenAI, “Model Context Protocol” 与 “Build an MCP server”, https://developers.openai.com/codex/mcp/;https://developers.openai.com/plugins/build/mcp-server/(核验日期:2026-08-19)。

11.13 Hooks:安全拦截与自动检查

Hooks 是在 Codex 生命周期关键点运行的确定性命令,适合执行“必须发生”的规则:在提示提交时筛查密钥,在调用 Bash、apply_patch 或 MCP 工具前阻断危险动作,在工具结束后检查失败和泄密信号,在 Codex 准备停止时要求补做测试与总结。它们把自然语言约束变成可测试的程序化护栏。

11.13.1 事件应放在哪个检查点

事件 触发时机 典型用途 可采取动作
UserPromptSubmit 用户提示提交后、Codex 处理前 检测 API key、生产密码;补充固定项目上下文 阻断提示或添加上下文
PreToolUse Bash、apply_patch、MCP 等工具执行前 拦截递归删除、破坏性数据库命令、修改敏感文件 allow、deny 或修改输入
PermissionRequest Codex 请求审批时 将项目风险分级映射为自动允许、拒绝或正常询问 allow、deny、ask
PostToolUse 工具已完成并返回结果后 识别测试失败、异常堆栈、secret 泄露或缺少产物 反馈并阻止继续采用结果;不能撤销副作用
Stop Codex 准备结束任务时 确认测试、lint、评测和变更总结已完成 允许结束,或要求继续一轮

11.13.2 配置三个关键 Hook

Hook 配置与 MCP 一样写入 config.toml。matcher 使用正则匹配工具名;Windows 可单独提供 command_windows。下面把提示筛查、工具前策略和工具后审查都指向项目内脚本。示例中的 Windows 路径是占位符,使用时必须替换为仓库的已验证绝对路径。

代码清单 11-7 config.toml 中的 Hooks 配置

[[hooks.UserPromptSubmit]]
[[hooks.UserPromptSubmit.hooks]]
type = "command"
command = 'python3 "$(git rev-parse --show-toplevel)/.codex/hooks/security_policy.py"'
command_windows = 'py -3 C:\\path\\to\\repo\\.codex\\hooks\\security_policy.py'
timeout = 10

[[hooks.PreToolUse]]
matcher = "^Bash$|^apply_patch$|^mcp__internal_kb__.*$"
[[hooks.PreToolUse.hooks]]
type = "command"
command = 'python3 "$(git rev-parse --show-toplevel)/.codex/hooks/security_policy.py"'
command_windows = 'py -3 C:\\path\\to\\repo\\.codex\\hooks\\security_policy.py'
timeout = 10
statusMessage = "Running safety policy"

[[hooks.PostToolUse]]
matcher = "^Bash$|^mcp__internal_kb__.*$"
[[hooks.PostToolUse.hooks]]
type = "command"
command = 'python3 "$(git rev-parse --show-toplevel)/.codex/hooks/post_tool_review.py"'
command_windows = 'py -3 C:\\path\\to\\repo\\.codex\\hooks\\post_tool_review.py'
timeout = 20

11.13.3 用 JSON 输入输出实现安全策略

Codex 通过标准输入向 Hook 传递 JSON。PreToolUse 可读取 tool_name 和 tool_input;对 Bash 与 apply_patch,命令或补丁文本通常位于 tool_input.command。下面脚本同时处理用户提示和工具前检查,并给出 Codex 能识别的阻断结果。真实项目应把规则分级、记录命中审计,并为允许的运维操作设置受控例外,而不是只靠关键词无限扩张。

代码清单 11-8 .codex/hooks/security_policy.py

import json
import re
import sys

data = json.load(sys.stdin)
event = data.get("hook_event_name", "")

SECRET = re.compile(
    r"(?i)(api[_-]?key|access[_-]?token|secret|password)\s*[:=]\s*['\"]?[A-Za-z0-9_./+-]{12,}"
)
DANGEROUS = [
    re.compile(r"(?i)\brm\s+-rf\b"),
    re.compile(r"(?i)\bRemove-Item\b.*\b-Recurse\b"),
    re.compile(r"(?i)\b(DROP\s+DATABASE|TRUNCATE\s+TABLE)\b"),
    re.compile(r"(?i)(^|[ /\\])\.env($|[ ./'\"])"),
]

if event == "UserPromptSubmit":
    prompt = data.get("prompt", "")
    if SECRET.search(prompt):
        print(json.dumps({
            "decision": "block",
            "reason": "提示中疑似包含密钥;请先脱敏。",
        }, ensure_ascii=False))
        raise SystemExit(0)

if event == "PreToolUse":
    tool_input = data.get("tool_input") or {}
    payload = str(tool_input.get("command", tool_input))
    if any(rule.search(payload) for rule in DANGEROUS):
        print(json.dumps({
            "hookSpecificOutput": {
                "hookEventName": "PreToolUse",
                "permissionDecision": "deny",
                "permissionDecisionReason": "命中破坏性操作策略。",
            }
        }, ensure_ascii=False))
        raise SystemExit(0)

print("{}")

PostToolUse 应解析 tool_response,而不是重新猜测命令意图。若发现 pytest FAILED、Traceback、secret 扫描告警或预期文件缺失,可输出 decision=block 和 reason,把失败反馈给 Codex 并要求修复;但动作已经发生,PostToolUse 无法撤销副作用。Stop Hook 也可在没有近期成功测试记录时返回 decision=block,要求再运行测试并汇报结果。测试状态应来自 CI、时间戳或机器可读记录,不能仅从模型总结中推断。

代码清单 11-9 post_tool_review.py 的核心检查

import json, re, sys

data = json.load(sys.stdin)
response = json.dumps(data.get("tool_response", ""), ensure_ascii=False)
failed = re.search(r"(?i)(pytest.*FAILED|Traceback|secret detected)", response)

if failed:
    print(json.dumps({
        "decision": "block",
        "reason": "工具输出包含失败或泄密信号,请检查并修复。",
    }, ensure_ascii=False))
else:
    print("{}")

11.13.4 Hooks 的边界与上线检查

Hooks 是强有力的工程护栏,但不是完整安全边界。部分调用路径可能不经过本地函数工具 Hook;PostToolUse 又晚于副作用发生。高风险项目必须同时使用 sandbox、最小权限、网络或域名限制、MCP 服务端鉴权、人工审批、分支保护和 CI。Hook 脚本本身也应进入版本控制、代码评审和自动测试,修改安全规则时应像修改生产策略一样审慎。

上线前至少验证:提示中含测试密钥时能阻断且不回显;递归删除、数据库破坏性语句和敏感文件修改能在执行前拒绝;只读 search_docs 正常运行且受 ACL 约束;测试失败能触发后置反馈;Stop 规则不会无限循环;Hook 超时或异常时行为符合团队的失败开闭策略;日志能关联会话、工具和决策但不记录秘密。

资料来源:OpenAI, “Hooks”, https://developers.openai.com/codex/hooks/(核验日期:2026-08-19)。

11.14 Cloud、外部集成与可复现环境

Codex Cloud在隔离环境中运行任务,适合让多个较长工作并行继续。正式使用前要为仓库配置依赖、工具、环境变量和秘密,保证任务环境可复现。结果完成后,应审查摘要和 diff,必要时要求后续修改,再创建 PR。

Cloud任务可以从 Web、GitHub、Linear或 Slack等入口发起。集成提高了任务进入系统的效率,但也带来身份与上下文问题:谁有权触发任务、允许访问哪些仓库、外部消息是否可信、结果返回哪里、谁负责合并,都需要组织规则。

云端与本地的文件、凭据和网络并不相同。不要假设本地可运行的命令在云端一定存在,也不要把个人机器上的秘密直接复制。应使用环境配置、最小范围凭据和域名允许列表。

Cloud任务需要显式依赖、设置脚本、环境变量、秘密和网络规则,完成后审查摘要和 diff再合并。外部集成提高任务进入效率,但也必须明确谁能触发、访问哪些仓库、结果返回哪里和谁负责合并。

云端与个人机器状态不同。不要假设本地服务、未提交文件和个人凭据存在;环境配置应可复现,秘密使用最小范围,网络限制到任务所需域名。

Cloud 的价值来自隔离与可复现,不是把本地环境原样搬到远程。

11.15 Scheduled Tasks 与持续工作

持续任务应把触发条件、输入范围、运行环境、超时、最大重试、通知对象和停止方式写清。后台运行并不减少责任,反而要求更稳定的日志、状态记录和异常升级。

定时任务应优先使用最小权限和可复现环境。若任务依赖本地未提交文件、交互式凭据或无法回滚的外部动作,就不适合直接无人值守运行,应拆分为准备与审批两个阶段。

Scheduled Tasks可以从 Web或桌面应用创建和管理。独立 Scheduled任务每次从保存的 prompt开始并在 Scheduled界面报告;嵌入现有 chat的任务可以继续使用该 chat的上下文,适合轮询长操作、持续研究或 PR跟进。CLI和 IDE不提供 Scheduled管理界面,但可以先在其中测试 prompt、Skill或脚本。

项目级 Scheduled任务可以在 Local或独立 Worktree中运行。Local会直接改动主工作区,Worktree可把后台变化与未完成工作隔离。涉及本地文件时,需要电脑开机、桌面应用运行且项目路径可用;Web任务可用上传资料和连接工具,但不能直接操作电脑上的文件夹。

定时任务无人值守,因此应使用最窄访问,先手动测试,再观察前几次运行。任务 prompt要写清每次做什么、什么情况值得报告、没有变化时如何处理、何时停止或请求输入。频繁运行会放大成本、误报和 Worktree占用。

定时任务适合日志汇总、PR跟进、依赖监测和周期报告。正式调度前先手动测试,写清有变化和无变化时的输出、失败阈值、通知责任和停止条件。项目级任务应优先使用独立 Worktree以避免干扰本地未完成工作。

频繁调度会放大成本、误报和工作区占用。后台任务使用默认权限和非交互策略时风险更高,因此要使用窄访问、可审查输出和前几次人工观察。

持续工作必须有观察策略、失败策略和责任人。

11.16 沙箱、审批、Rules 与网络

Codex 将沙箱范围与审批策略分开配置。沙箱决定系统能够读取、写入或执行什么,审批策略决定哪些越界或高影响动作必须询问人;两者不能相互替代。

只读模式适合检查和规划,工作区写入适合大多数可撤销的本地工程任务,完全访问只应在风险已经理解且环境受到额外保护时使用。审批可以从不可信动作逐次确认,也可以按需或在受控环境中减少打断。

网络和凭据需要单独治理。即使允许写工作区,也不意味着应开放任意域名或继承全部用户凭据。依赖下载、外部 API 和代码托管连接应使用域名限制、专用身份和审计记录。

Codex把“能访问什么”和“何时询问”分开控制。常见沙箱模式包括 read-only、workspace-write和 danger-full-access;审批策略包括 untrusted、on-request和 never。workspace-write允许在工作区内编辑和执行常规命令,是低摩擦的本地工作基线;danger-full-access移除边界,只适合明确需要并能承担风险的情形。

自动审批或 auto-review不会改变沙箱边界,它只是审批请求的审查者。若流程只需要某个特定命令前缀的例外,应使用 Rules进行允许、询问或禁止,而不是扩大全部文件和网络权限。需要多个目录时可以添加特定 writable roots。

网络访问应默认关闭或限制到任务必需域名。后台 Scheduled任务使用默认沙箱并可能采用非交互审批策略,风险更高。组织可通过 requirements.toml等管理策略限制允许的沙箱和审批组合,避免个人配置绕过底线。

安全配置|不要把“never approval”理解成“更高效率”的通用选项。无人值守任务应优先使用 workspace-write、最小网络和可审查输出;只有在可隔离、可回滚且明确授权时才扩大权限。

OpenAI官方文档将沙箱与审批分开:read-only、workspace-write和 danger-full-access定义访问边界;untrusted、on-request和 never决定何时停下;reviewer决定由用户或自动审查处理符合条件的请求。自动审查不会改变沙箱范围。

低风险本地自动化通常以 workspace-write和 on-request为基线,跨目录使用特定 writable roots,命令例外使用 Rules,网络限制到必要域名。danger-full-access与 never组合移除主要边界,只应在明确授权和隔离环境使用。

维度 常见选项 设计问题
沙箱 只读/工作区写入/完全访问 系统能触及什么
审批 不可信/按需/从不 何时必须问人
网络 关闭/域名限制/开放 外部数据和供应链风险
凭据 不提供/按工具注入/继承 是否最小权限和可审计
审查 用户/自动审查 谁对升级请求做决定

“永不询问”不是安全模式;边界和审查者必须分别配置。

资料依据:OpenAI官方文档:Sandbox;Agent approvals & security;Rules

11.17 团队落地路线

Codex 的团队落地适合围绕项目和执行环境分层。项目层负责 AGENTS.md、验证命令和代码审查规则;环境层负责 Local、Worktree 与 Cloud 的选择、网络和凭据策略,以及任务结果怎样回到主工作区。

Local 适合需要即时判断和本地状态的短任务,Worktree 适合多个修改并行且必须隔离文件的任务,Cloud 适合长时间运行、可独立验证和可以异步回收结果的任务。环境选择应成为任务模板的一部分。

团队运营还应记录每类环境的成功率、人工接管时间、失败原因和回滚成本。只有当并行收益、验证质量和治理成本形成稳定证据后,才适合扩大后台任务和自动化调度的范围。

Codex落地应从代码库基线开始,而不是先安装大量插件。第一阶段选择一个仓库,建立 AGENTS.md,确认构建与测试命令,使用 Local或 CLI处理小任务;第二阶段引入 Worktree并行和计划模式;第三阶段把高频流程做成 Skills和 Hooks;第四阶段再连接 MCP、Cloud和 Scheduled任务。

组织需要同时建立工程和治理指标:任务成功率、测试通过率、PR返工率、平均人工干预、权限升级次数、提示注入或秘密暴露事件、自动化误报率和成本。只有当结果稳定、失败可见、变更可回滚时,才适合扩大自动化范围。

  • 仓库基线:AGENTS.md、构建命令、测试、格式化、代码审查规则完整。

  • 任务基线:目标、范围、环境、验收、停止条件写清楚。

  • 隔离基线:并行任务使用 Worktree或 Cloud,不直接抢占主工作区。

  • 验证基线:每次交付包含 diff、测试与未完成风险。

  • 扩展基线:Skill、Plugin、MCP和 Hook有来源、责任人、版本与回滚。

  • 自动化基线:先手动测试,前几次人工观察,后台任务使用最小权限。

第一阶段完善 AGENTS.md、构建测试和交付格式;第二阶段在 Local/CLI处理小任务并引入 Worktree;第三阶段把高频流程做成 Skills和 Hooks;第四阶段连接受控 MCP与 Cloud;第五阶段才安排 Scheduled任务和更高自主程度。

指标要覆盖任务成功、测试通过、PR返工、人工干预、权限升级、扩展风险和成本。团队资产应有责任人、版本和评测。

Codex 落地应从仓库和验证基线开始,而不是从安装更多扩展开始。

11.18 案例:并行完成依赖升级与回归验证

这个案例的关键不在于同时启动多少任务,而在于先形成依赖升级的约束集:目标版本、兼容范围、禁止修改项、测试矩阵、网络条件和回滚标准都应明确。缺少约束的并行,只会更快地产生相互冲突的修改。

探索任务可以分别分析发布说明、受影响模块和现有测试缺口;实现任务应在独立 Worktree 中修改锁文件与适配代码;审查任务则检查许可、安全公告、生成文件和间接依赖变化。主任务负责合并证据,而不是重复子任务的全过程。

验证应由窄到宽推进:先运行依赖相关单测,再执行模块集成测试、静态检查和构建,最后覆盖关键端到端路径。若云端环境与本地环境不同,应分别记录运行镜像、系统依赖、网络访问和失败差异。

交付时需要把“代码已经更新”和“升级已经可接受”区分开。前者由差异与构建结果证明,后者还需要回归证据、性能或体积变化、已知风险、回滚方式以及维护者确认。

采用这种方式,Codex 的价值体现为组织并行探索、隔离修改和汇总证据,而最终决策仍由明确的验收门控制。并行能力只有与可复现环境和可审查交付结合,才会转化为工程吞吐。

任务拆分还要遵守依赖方向。发布说明与安全公告的研究可以独立开展,代码修改却必须等待影响范围初步明确;端到端回归通常依赖构建通过。把这些先后关系写入任务说明,可以避免子任务在缺少前提时生成无效结果。

每个并行任务都应返回结构化摘要,包括读取过的关键文件、作出的假设、产生的修改、运行的命令、验证结果和未解决问题。主任务只接受带证据的结论,并对相互矛盾的结果安排复核。

合并阶段要特别检查多个 Worktree 是否修改了同一锁文件、生成文件或公共配置。即使文本冲突能够自动解决,语义上的版本选择和构建顺序仍可能互相覆盖,因此合并后必须重新生成并执行完整验证。

若升级失败,应按可诊断性处理,而不是连续让模型尝试不同版本。先区分下载或网络故障、解析器冲突、编译接口变化、运行时行为变化和测试本身过期,再为相应类型选择恢复动作。

对于高风险依赖,安全公告和许可证变化应进入审查记录。Codex 可以帮助检索和整理,但版本是否满足组织政策仍要以受控数据源、软件物料清单和安全团队规则为准,不能只依赖自然语言摘要。

成本评估也应覆盖推理、云端执行、人工审查和失败重跑。若并行任务节省的等待时间低于协调与复核成本,应回到单任务闭环;并行是一种调度策略,不是所有工程任务的默认答案。

最终可把稳定做法沉淀为依赖升级 Skill、AGENTS.md 规则和 CI 检查,但应保留任务级判断。自动化负责重复步骤,维护者负责是否接受兼容性取舍和发布时间。

验收矩阵应同时覆盖操作系统、运行时版本和关键功能路径。若项目无法承担完整组合,可以依据生产分布和故障影响确定最低集合,并明确哪些组合尚未验证;没有运行过的测试不能被记为通过。

回滚方案也要真正演练。仅保留旧版本号并不足够,还要确认锁文件、缓存、数据库迁移和生成产物能否恢复,必要时准备前向修复。若回滚会导致数据不兼容,升级必须采用更严格的分阶段发布。

人工审查应聚焦模型最难证明的部分:公共接口语义是否变化、默认配置是否改变、间接依赖是否引入新许可、错误处理是否仍符合业务预期。格式和静态规则则尽量交给确定性工具完成。

任务结束后,团队应把失败类型和人工接管点加入评测集。下一次升级可先运行这些历史用例,判断新模型、规则或执行环境是否真正降低了风险,而不是只比较任务完成速度。

当该流程稳定后,Codex 可以承担更多准备、并行验证和报告整理工作,但发布批准仍应与代码生成解耦。谁拥有生产变更权限、谁确认业务兼容性、谁负责事故响应,都要在组织制度中明确。

任务要求升级一个核心依赖,保持公开 API不变,修复类型错误,运行完整测试并提供回滚说明。主任务先读取 AGENTS.md和锁文件,形成风险清单;一个 Worktree尝试最小版本升级,另一个只研究上游变更,测试 Subagent分析失败分布。

主智能体比较结果后选择最小升级路径,限制网络到包源并保持 workspace-write。依赖安装需要外部访问时按需批准;测试通过后 Handoff到 Local,在现有开发服务中做最终验证,审查锁文件和生成文件。

交付包含版本变化、兼容性修改、测试证据、尚未覆盖平台和回滚命令。案例表明,Worktree隔离适合比较方案,Subagent适合知识与测试侧任务,最终合并仍需要统一决策。

Codex 的并行优势来自环境隔离和清晰移交,而不是同时启动更多模型。

12. 产品比较、选型与组合使用

产品选型不是功能数量比较,而是任务、环境、团队生态与治理条件的匹配问题。四个产品分别代表不同的运行入口、连续性和控制方式。

统一维度下的真实任务评测,能够区分演示优势与稳定交付能力,也能识别组合使用和迁移策略。

12.1 选型原则:任务、环境、生态与治理匹配

选择产品时应先回答任务是什么、运行在哪里、需要哪些工具、谁负责审批和维护。OpenClaw适合希望自托管、渠道丰富和常驻在线的个人智能体;Hermes适合重视多模型、长期记忆、技能积累和实验性的用户;Claude Code适合希望在多个开发界面中建立工程闭环并通过丰富扩展体系复用流程的团队;Codex适合需要本地、Worktree与 Cloud协同、复杂项目并行和明确沙箱治理的工程场景。

产品价值取决于任务和组织条件。常驻个人助理重视渠道、记忆和主机控制;工程团队重视代码库理解、测试、diff、环境隔离和 PR流程;研究团队重视浏览、引用、长任务和多格式交付。

选型前应固定任务集和验收,避免用不同任务比较不同产品。还要计算账号、模型、基础设施、扩展维护、权限审查和人工复核的总成本。

没有脱离任务和治理条件的绝对最强。

12.2 四个产品的统一比较

  • 个人希望从 Telegram/WhatsApp 等渠道随时调用自己的主机工具:优先考察 OpenClaw,并把身份、网络和宿主机隔离作为前置条件。

  • 研究者或高级用户希望多模型、可自部署、长期记忆和技能自我积累:可考察 Hermes,但要投入更多版本、安全和技能审查。

  • 团队主要使用 Anthropic生态,希望把工程流程沉淀为 CLAUDE.md、Skills、Subagents、Hooks 与 Plugins:Claude Code更顺手。

  • 团队需要 Local/Worktree/Cloud统一组织、并行项目、Scheduled任务和明确沙箱审批:Codex更有优势。

  • 如果任务高度确定且风险高,不要为了“智能体化”而放弃成熟工作流;让智能体只处理开放性步骤。

OpenClaw突出多渠道自托管 Gateway,Hermes突出多模型与程序性学习,Claude Code突出围绕 Claude的工程闭环与丰富扩展,Codex突出 Local/Worktree/Cloud和多控制面组织。它们的功能持续变化,表格用于建立当前结构理解,不作为长期不变排名。

维度 OpenClaw Hermes Claude Code Codex
核心定位 常驻个人网关 开放自改进框架 工程智能体 工程智能体平台
典型入口 消息渠道 终端/消息 终端/IDE/桌面 CLI/IDE/桌面/云
长期性 项目/会话 本地+后台
验证基础 任务自定义 任务自定义 测试/diff 测试/diff/隔离任务
主要治理 频道和网关权限 工具与记忆 权限/钩子/规则 沙箱/审批/工作树

统一维度让产品比较从功能堆叠转向系统设计。

12.3 Claude Code 与 Codex 的关键差异

两者的共同基础远大于表面差异:都读取代码库、编辑文件、运行命令、与 Git和测试结合,并支持持久指令、Skills、MCP、Subagents、Hooks和插件化。选择不应只看模型偏好,还应看团队现有账号、IDE/终端习惯、云端环境、权限治理和扩展生态。

Claude Code以 CLAUDE.md与 Auto Memory形成“人写规则 + Claude学习”的结构,官方文档对 Skills、插件 Marketplace和多 Agent能力描述非常丰富;Codex以 AGENTS.md与 Local Memories区分“硬规则 + 软回忆”,Worktrees和 Local/Cloud环境成为并行工程的重要控制面,Scheduled任务与沙箱/审批配置也更突出。

最稳妥的选型方法是用同一组真实任务做 A/B试点:一个跨文件 Bug、一次仓库探索、一个测试补全任务、一次 PR审查和一个后台报告任务。比较完成质量、验证证据、人工干预、权限配置和团队可复用性,而不是只比较生成速度或一次性代码风格。

两者都能读取代码库、编辑文件、运行命令、使用 Skills、MCP、Hooks和子智能体。差异更多体现在环境组织和生态:Claude Code以 CLAUDE.md、Rules和 Anthropic扩展体系为核心;Codex以 AGENTS.md、Local/Worktree/Cloud、Handoff和 OpenAI/ChatGPT控制面为核心。

选型不应只比较一次任务的代码质量,还应比较同一仓库多轮运行的稳定性、上下文成本、权限提示、并行冲突、扩展维护和团队审查习惯。

观察点 Claude Code Codex 选型问题
配置入口 CLAUDE.md、Settings AGENTS.md、配置 团队规则放在哪里
扩展机制 Skills、MCP、Hooks、Plugins Skills、MCP、Hooks、Plugins 是否需要确定性控制
并行协作 Subagents、Agent Teams Subagents、桌面多任务、云任务 隔离和协调成本
运行环境 本地为主,多入口 本地+工作树+云 是否需要后台运行
安全模型 权限模式与工具控制 沙箱与审批分离 风险由谁批准

Claude Code 与 Codex 共同基础接近,关键差异在环境组织和生态治理。

12.4 决策树:从任务入口选择产品路线

如果主要入口是消息渠道和全天在线,先评估 OpenClaw;如果希望多模型、Profiles和自我生成程序性知识,评估 Hermes;如果团队以 Claude生态和终端/IDE工程为主,评估 Claude Code;如果需要桌面项目、多 Worktree、Cloud和 ChatGPT/Codex协同,评估 Codex。

决策树只负责缩小范围。最终仍需用代表性任务 A/B试点,核对账号与数据政策、可用模型、平台支持和组织受管配置。

首要需求 优先考察 下一步问题
多消息渠道、常驻个人入口 OpenClaw 自托管和频道治理能力?
开放框架、长期记忆与自定义 Hermes 能否承担运行维护?
深度本地代码库协作 Claude Code/Codex 团队生态和安全要求?
并行后台任务、隔离环境 Codex 是否需要云任务与工作树?
复杂多智能体协作实验 Claude Code/Codex 是否有明确拆分和协调收益?

先按入口和环境筛选,再用真实任务和治理要求决策。

12.5 统一实测设计:怎样比较而不被演示误导

实测应包含至少四类任务:陌生代码库定位、小范围 Bug修复、测试补全、带来源研究或文档更新。每个任务提供相同目标、材料、边界和验收,记录环境、模型、权限和扩展。

指标包括完整成功率、测试通过、无关改动、引用正确、人工干预、运行时间、成本、权限升级和失败可见性。至少重复多轮并由不同人员使用,避免把单次幸运结果当成能力。

复盘需要区分模型、产品运行时、工具、项目说明和用户操作的影响。否则即便比较出胜负,也无法知道改进哪一层。

步骤 要求 输出
选题 20—50个真实、可复现任务 任务集
盲测 统一环境、权限和模型预算 原始运行记录
验收 预先定义自动与人工标准 评分表
安全 注入、越权、敏感数据测试 红队结果
复盘 按失败类型而非平均分改进 决策报告

统一任务和完整证据,才是产品选型的可靠基础。

12.6 组合使用与迁移策略

组织可以组合产品:OpenClaw或 Hermes作为消息与调度入口,Claude Code或 Codex处理代码任务;研究智能体生成 Issue,工程智能体实现,独立审查智能体验证。组合前必须明确身份、数据传递、权限和责任。

可迁移资产包括任务说明书、验收标准、项目规则、Skills、MCP接口和评测集。具体配置格式不同,但内容层可以保持统一。迁移时先迁移规则和测试,再迁移自动化,避免把旧环境的权限和隐含依赖直接复制。

把知识和验证资产做成产品无关层,可以降低锁定并提高组合能力。

13. 组织落地:从试点到规模化运营

智能体进入组织流程,需要任务、数据、工具、验证、身份、治理和人员能力同步准备。试点的目标是形成证据与资产,而不仅是完成一次展示。

从任务盘点、受控试点到能力固化和规模运营,组织应逐步沉淀规则、技能、工具、评测集与责任制度。

13.1 准备度:流程、数据、工具、验证和治理

准备度不以采购席位数量衡量。需要检查任务是否有明确交付,数据能否合法获得,工具是否稳定,验证是否自动化,权限能否最小化,失败是否有责任人。缺少验证的流程应先建设验收,缺少接口的流程应先整理数据和工具。

准备维度 未准备信号 就绪信号
任务 目标模糊、无法验收 输入输出和边界清楚
数据 来源混乱、权限不清 分级、版本、访问策略明确
工具 接口不稳定、无回读 参数清楚、错误可观测
治理 谁负责不清楚 审批、审计、回滚明确
人员 只会聊天提问 能写任务说明并验收

Agent 准备度首先是流程和工程准备度。

13.2 试点组合:一个高频任务、一个高价值任务、一个治理任务

高频任务用于观察复用和成本,例如周报或测试补全;高价值任务用于观察跨步骤能力,例如缺陷修复或研究报告;治理任务用于验证提示注入、权限拒绝、回滚和审计。三类结合比只选一个精彩演示更全面。

试点范围控制在少数团队和仓库,使用真实但可恢复的数据。所有任务采用统一说明书和验收记录,运行前登记权限和扩展,运行后记录人工干预与失败。

试点既要证明价值,也要主动验证失败和治理。

13.3 90 天路线图

第 1—15 天梳理任务和风险,建立评测集;第 16—30 天完成项目规则、环境和验证基线;第 31—50 天运行只读与受控写入试点;第 51—65 天把高频流程技能化;第 66—80 天补充扩展审查、审计和事件响应;第 81—90 天基于数据决定扩大、调整或停止。

路线图必须设置阶段退出条件。若成功率、验证覆盖或权限管理未达到门槛,应延长当前阶段,而不是按日历强行上线后台自动化。

阶段 重点工作 退出条件
0—30天:发现 任务盘点、基线、风险分级、工具筛选 选定3—5个试点
31—60天:试点 任务模板、沙箱、评测、培训、周复盘 稳定成功率与失败可见
61—90天:固化 技能化、接入流程、监控、责任制度 可复制并通过治理评审

按证据升级自主程度,是 90 天试点的主线。

13.4 角色与责任:业务、工程、安全和平台共同负责

业务所有者定义价值和最终责任,领域专家提供规则和例外,工程团队建设工具与验证,平台团队管理身份、环境和可观测性,安全法务定义边界与事件响应,使用者负责在授权范围内运行和反馈。

任何后台任务和高权限扩展都要有明确责任人和替代人。产品厂商、模型和智能体不能成为责任主体,最终授权和对外结果仍属于组织。

Agent 运行跨越流程、软件和治理,不能只交给单一团队。

13.5 组织知识资产:规则、Skills、工具和评测集

资产目录应包含项目指令、任务模板、Skills、Hooks、MCP、插件、环境设置、评测集和安全策略。每项记录用途、范围、责任人、版本、依赖、权限、评测结果和退役日期。

高质量资产来自运行反馈。重复错误更新规则,稳定流程生成 Skill,机械检查生成 Hook,跨系统需求形成工具接口,典型成功和失败样本进入评测集。

规模化的核心不是更多 Prompt,而是可维护的 Agent 资产体系。

13.5.1 从运行轨迹到四类能力载体

Agent运行会持续产生轨迹、工具结果、用户纠正和评测信号。经验只有在改变后续行为并通过验证后,才算形成系统能力。按照表达性质,更新可以落到四类载体:事实、经验和例外写入知识;可语言化判断原则写入 Prompt或 Skill;确定性流程和硬约束写入程序、工具、Hook或工作流;难以显式表达的感知与策略才考虑通过监督微调、蒸馏或强化学习进入模型参数。

四类载体不是从低到高的单向阶梯。外部知识最易更新和审计,程序最适合强验证与复用,参数内化可降低推理时负担但更新成本和回滚难度最高。组织应优先选择可追溯、可局部修改、可自动验证的载体,只有稳定重复且外部规则难以承载的能力才进入后训练。

13.5.2 在线执行与离线进化必须分离

生产中的稳定版 Agent负责处理任务并记录证据,不应在一次未验证反馈后直接改写自己的核心规则。离线进化循环负责聚合轨迹、寻找共同根因、生成候选更新、运行目标回归与安全评测,再通过版本化、灰度、监控和回滚晋升为新稳定版。

可信根——权限策略、审计、验证器和回滚机制——不能由普通进化流程自行解除。候选知识要标出来源和适用边界,候选 Prompt或 Skill要做敏感性与冲突测试,候选程序要经过代码审查和 CI,模型更新要检查旧能力退化。持续进化的目标不是让 Agent无限自改,而是把真实经验转化为受控的软件发布循环。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

13.6 指标与运营节奏

周度看任务量、成功、人工干预和异常;月度看质量、返工、成本、权限升级和扩展健康;季度审查资产使用、过期规则、供应链和场景收益。指标要按任务类型和风险分层,避免平均值掩盖高风险失败。

运营会议应抽查真实轨迹和交付,不只看仪表盘。对失败进行根因分类,明确改进落到任务说明、模型、工具、环境、规则还是组织流程。

Agent 需要像软件服务一样持续运营,而不是一次上线后不再维护。

13.7 人员能力与变革管理

培训重点不应停留在“怎样写提示词”,而要教会员工定义交付、提供上下文、设置边界、审查证据、识别不确定性和处理权限请求。领域专家的知识决定 Agent能否做出正确取舍。

建立共享案例、办公时间、内部支持和安全试验空间,让成功经验进入资产。管理者要允许小范围失败并要求透明复盘,避免员工因为担心问责而隐藏 Agent使用。

Agent 放大领域能力,也放大任务定义和判断能力的重要性。

13.8 规模化模式:平台化、联邦治理与持续优化

  1. 建立术语共识:Agent是系统,不是一个模型,也不等于完全自治。

  2. 选择两到三个可验证、可回滚的真实任务做试点,避免只看演示。

  3. 把任务说明书、验证证据和停止条件变成统一工作规范。

  4. 把稳定经验沉淀到项目指令、Skills和 Hooks,而不是依赖个人提示词。

  5. 建立扩展来源、沙箱、审批、网络、凭据和后台任务的治理基线。

最终判断|智能体最重要的能力不是“能自己做多少”,而是在不确定任务中能否持续产生可验证结果,并在高风险节点把控制权可靠地交还给人。

中央平台提供身份、模型、环境、日志、评测、资产目录和受管配置;业务团队拥有场景、规则和验收;安全法务提供底线和例外审查。这种联邦模式既避免每个团队重复建设,也保留领域适配。

规模化不意味着统一成一个超级 Agent。更可靠的方向是多个边界清楚的任务系统,共享基础设施和治理。平台通过指标和反馈持续优化模型、工具和资产。

统一基础设施与分散场景所有权,是组织级 Agent 的稳健结构。

14. 趋势、结论与行动主张

智能体竞争正在由单一模型能力转向完整系统能力,交互方式也由短会话转向持续任务与数字同事。

多模态、工具协议、安全治理和组织知识资产将共同决定下一阶段的发展速度,最终评价标准仍是能否持续交付可验证结果。

14.1 竞争从模型能力转向完整系统能力

智能体时代的关键变化,是模型获得了工具、记忆、运行时和治理。模型决定理解与推理上限,工具决定能做什么,记忆决定能否跨步骤和跨会话保持方向,运行时决定计划能否落地,安全机制决定系统可被允许进入多大范围。

OpenClaw与 Hermes展示了个人智能体运行时的路径,Claude Code与 Codex展示了工程智能体的路径。四者都在向记忆、技能、插件、委派、后台任务和权限治理收敛,说明未来差异化将更多来自系统集成、可靠性和生态,而不仅是底层模型。

模型仍是智能体上限的重要因素,但真实差异越来越来自工具质量、上下文加载、环境复现、反馈闭环、扩展生态、并行组织和权限治理。模型迭代很快,系统资产和组织流程决定能力能否持续转化为工作结果。

未来的领先 Agent 产品更像可靠运行系统,而不是更华丽的聊天界面。

14.1.1 模型会吸收 Harness,但不会消灭 Harness

模型进步会把格式遵循、基础工具选择、错误恢复等能力逐步内化,减少部分显式编排;与此同时,Harness会向新的前沿移动,承担动态业务知识、身份权限、长期状态、异步事件、真实环境验证和组织责任。二者形成共同进化:运行系统产生轨迹和评测,推动模型与外部资产更新;更强模型又使 Harness能够组织更开放的任务。

因此,长期建设不应押注某一套临时 Prompt,也不能假设更换模型就会自动解决系统问题。应把独有数据、工具接口、评测集、用户信任、渠道和可恢复的业务流程沉淀为模型之外的资产。无论底层模型如何变化,“看见什么、能做什么、怎样验证”仍是 Agent工程最稳定的三条主线。

资料依据:李博杰《深入理解 AI Agent:设计原理与工程实践》相关章节。

14.2 交互从会话转向持续任务与数字同事

用户不再只在一个窗口持续提问,而是在项目、消息、IDE和云环境中启动任务、查看状态、批准关键动作并接收交付。智能体逐渐拥有持续目标和可恢复状态,但数字同事仍需要岗位边界、工作规范和监督。

持续性改变的是协作方式,同时提高了责任与治理要求。

14.3 Skills、Plugins 与工具协议成为能力分发层

模型能力会快速普及,组织差异将更多来自自有 Skills、工具接口、评测集和项目规则。插件与市场降低分发成本,也带来供应链、命名冲突、上下文成本和权限扩张。

Agent 时代的组织知识将更多以可执行、可评测资产存在。

14.4 多模态与 Computer Use 扩大工作对象

智能体能够跨网页、桌面、文档、表格、演示、图像和语音工作,更多没有 API的流程也可以自动化。但界面操作比 API更脆弱,容易受布局变化、提示注入和身份状态影响,必须加强视觉验证、动作确认和回滚。

行动半径扩大后,验证和隔离要同步升级。

14.5 安全与治理将成为产品能力

当多个产品都能调用工具和并行工作,组织会更关注谁能定义边界、怎样自动执行低风险步骤、何时升级审批、如何限制扩展、怎样查看轨迹和恢复。治理不是阻碍采用,而是减少审批疲劳、支持更高自主程度的基础。

真正可规模化的自主性,建立在可执行边界和可追溯证据上。

14.6 回答三个问题:系统、任务与方法

什么是智能体?它是在权限边界内围绕目标选择步骤、调用工具、维护状态并根据反馈修正的系统。智能体能做什么?它适合复杂、跨工具、需要中间判断且结果可验证的任务,特别是研究、软件工程、数据和业务协同。

如何使用智能体?从真实但可恢复的小任务开始,用任务说明书明确目标和边界,把验证写进完成标准,以最小权限运行,沉淀规则、Skills和测试,再逐级进入并行、后台和组织规模化。

四个产品展示了两条路线和共同收敛:OpenClaw与 Hermes强调常驻、渠道和长期学习,Claude Code与 Codex强调工程闭环和环境组织;它们最终都要回答状态、复用、行动和治理。

主线结论:从模型到系统,从回答到任务,从演示到可验证运行。

附录 A:智能体任务说明书模板

本模板把自然语言请求转化为可委托任务。使用时先填目标与验收,再决定工具和自主程度;不要先打开权限再寻找用例。

字段 应写内容 示例
目标 要解决的问题 完成专题报告
交付物 文件、格式、受众 80页以上Word报告
范围 包含与排除 四个产品,重点CC/Codex
约束 时间、工具、来源、风格 官方资料优先
验证 如何判断完成 页数、目录、渲染检查
权限 允许/需确认/禁止 只读检索;写本地文件
失败处理 何时重试或升级 来源冲突时标注
  1. 背景与目标|为什么做;要改变什么状态;与上游/下游任务是什么关系。

  2. 交付物|文件、格式、数量、受众、位置、截止时间和版本要求。

  3. 范围|必须包含、可以包含、明确排除以及不可触碰的系统。

  4. 输入与来源|可使用的数据、可信来源、版本日期和引用要求。

  5. 工具与权限|允许自动使用、需要审批、完全禁止的工具和动作。

  6. 验收标准|正确性、完整性、格式、性能、安全和人工复核标准。

  7. 失败与升级|最大重试、超时、冲突、权限不足和需要人决策的条件。

  8. 移交|完成摘要、证据、未完成项、风险、回滚和后续责任人。

附录 B:工程智能体任务验收清单

工程智能体的验收不能只看最终答案或代码差异,还要检查过程证据是否足以复现。下面的清单可用于任务创建、审查和交接,团队可按风险等级裁剪,但不应省略责任人与回滚条件。

使用时先确认任务范围、环境与权限,再核对变更和验证,最后检查安全与移交。若某一项无法确认,应明确记录为未验证事实,而不是用模型判断替代证据。

对于重复任务,可以把清单中的稳定检查固化为脚本、Hook 或持续集成门禁;需要业务判断的项目仍应保留人工签字或审批。

任务与范围

  • □ 目标、范围与不做事项已写清

  • □ 仓库规则和依赖约束已加载

  • □ 基线问题可复现

  • □ 高影响设计决策已得到确认

变更质量

  • □ diff 与任务直接相关

  • □ 没有无关格式化或大范围重写

  • □ 错误处理和边界条件已覆盖

  • □ 公共接口、数据结构与兼容性影响已说明

验证

  • □ 针对性测试通过

  • □ 相关完整测试通过

  • □ 静态检查、类型检查或构建通过

  • □ 失败日志未被隐藏

  • □ 必要时进行了真实回读或界面渲染

安全

  • □ 未引入密钥和敏感数据

  • □ 新增依赖来源、许可与版本已检查

  • □ 命令、网络和文件权限符合任务范围

  • □ 外部输入未直接成为高权限指令

移交

  • □ 完成摘要与文件清单准确

  • □ 测试命令和结果可复现

  • □ 剩余风险、限制与后续项明确

  • □ 提交/PR说明便于审查

  • □ 存在可行回滚路径

附录 C:智能体安全与治理检查清单

对象 检查问题 建议证据/控制
目标 是否存在范围漂移或隐藏目标? 任务说明、停止条件
输入 不可信内容能否影响系统指令? 内容隔离、来源标签
数据 是否处理个人、商业秘密或受监管数据? 分类、脱敏、驻留
身份 使用谁的身份执行? 专用身份、短期凭据
权限 是否最小化到任务所需? 白名单、只读优先
工具 参数、错误和副作用是否清楚? 契约、测试、回读
网络 能访问哪些域名和下载内容? 域名限制、恶意文件检查
记忆 内容能否查看、更正、过期和删除? 版本、来源、生命周期
扩展 MCP、Skills、Plugins来自何处? 签名、审查、锁定版本
审批 哪些动作必须由人决定? 风险分级、双人控制
审计 能否还原每一步和每次授权? 日志、证据、关联ID
恢复 失败后如何停止、回滚和通知? 熔断、备份、应急流程

附录 D:智能体评测量表与试点记录

下方四条记录为填写示例,每个产品各一条,仅用于说明记录方法,不代表任何产品的实际测评结论。

维度 1分 2分 3分 4分 5分
任务成功 未交付 部分交付 基本完成 完整通过 稳定一次通过
正确性 重大错误 多处错误 可修正 少量瑕疵 证据充分无误
效率 显著更慢 无收益 略有收益 明显节省 可规模复制
鲁棒性 失败无恢复 需频繁接管 可在提示下恢复 多数自动恢复 异常稳定处理
安全 越权/泄露 控制不足 基本合规 控制完整 主动最小化风险
可审查性 无法解释 证据不足 过程可读 证据完整 便于复现与审计
任务ID 任务类型 系统/版本 成功 人工分钟 失败类型 证据链接
OC-01 多渠道只读 OpenClaw 成功 8 日志、来源
HE-01 记忆检索 Hermes 成功 10 记忆快照
CC-01 补丁与测试 Claude Code 成功 20 diff、测试
CX-01 Worktree 并行 Codex 成功 16 任务、diff

附录 E:核心术语表

术语 本报告中的含义
Agent / 智能体 围绕目标选择步骤、使用工具、维护状态并根据反馈修正的受约束系统。
Agentic 具有智能体式的自主选择和行动特征。
Tool / 工具 智能体读取或改变外部环境的结构化接口。
Tool calling 模型选择工具并生成结构化参数的机制。
Runtime / 运行时 承载执行、状态、调度、隔离和恢复的系统。
Context / 上下文 当前任务可被模型直接读取的信息窗口。
Memory / 记忆 跨步骤或跨会话保存的状态、事实与经验。
Skill / 技能 按需加载、可复用并可测试的任务方法和资源包。
MCP 用于连接模型与外部工具/数据的开放协议与生态。
Hook / 钩子 在特定生命周期事件上确定性执行的规则或程序。
Plugin / 插件 将技能、连接器和配置打包分发的扩展单元。
Subagent / 子智能体 由主智能体委派、具有独立上下文的专门执行者。
Agent team 多个独立智能体会话通过共享任务和消息协作。
Orchestration / 编排 分解、分派、协调、汇总和处理失败的机制。
Sandbox / 沙箱 限制文件、网络、进程或系统访问的执行边界。
Approval / 审批 在高风险动作前请求人类明确授权的控制。
Least privilege / 最小权限 只授予完成当前任务所需的最低权限。
Worktree / 工作树 共享Git元数据但拥有独立工作目录的隔离checkout。
Prompt injection / 提示注入 外部内容试图改变系统目标或诱导越权的攻击。
Evals / 评测 用可重复任务和指标衡量质量、效率、安全与鲁棒性。
Human-in-the-loop 在人类控制点进行确认、审批或判断。
Observability / 可观察性 通过日志、轨迹和指标理解系统运行状态。
Rollback / 回滚 将错误动作恢复到已知安全状态。
Handoff / 移交 把任务状态、证据、风险和下一步交给人或其他智能体。
Definition of Done 预先约定的完成与验收条件。

附录 F:参考资料与进一步阅读

以下资料用于校准概念、产品能力和实践建议。产品能力变化较快,实施前应再次核对官方文档、更新日志、定价、平台范围和安全策略。

  1. 李博杰.《深入理解 AI Agent:设计原理与工程实践》. 中文版,2026. https://github.com/bojieli/ai-agent-book

  2. OpenAI. A practical guide to building agents. https://openai.com/business/guides-and-resources/a-practical-guide-to-building-ai-agents/

  3. OpenAI Developers. Codex documentation. https://developers.openai.com/codex/

  4. OpenAI. AGENTS.md. https://developers.openai.com/codex/guides/agents-md/

  5. OpenAI. Git worktrees. https://developers.openai.com/codex/app/worktrees/

  6. OpenAI. Sandboxing and approvals. https://developers.openai.com/codex/security/

  7. Anthropic. Claude Code overview. https://code.claude.com/docs/en/overview

  8. Anthropic. Claude Code features overview. https://code.claude.com/docs/en/features-overview

  9. Anthropic. Claude Code security. https://code.claude.com/docs/en/security

  10. Anthropic. Building effective agents. https://www.anthropic.com/research/building-effective-agents

  11. OpenClaw. Documentation overview. https://docs.openclaw.ai/

  12. OpenClaw. Tools, Skills and Plugins overview. https://docs.openclaw.ai/tools/

  13. OpenClaw. Gateway security and trust model. https://docs.openclaw.ai/gateway/security/

  14. Hermes Agent. Official documentation. https://hermes-agent.nousresearch.com/docs/

  15. Nous Research. Hermes Agent product page. https://nousresearch.net/hermes-agent/

  16. NousResearch/hermes-agent. Releases. https://github.com/NousResearch/hermes-agent/releases

  17. 用户提供:《Claude Code完全教程》. https://my.feishu.cn/wiki/Takxwov60iO5OOkOmpEcpOGynac

  18. 用户提供:《Codex全解》. https://my.feishu.cn/wiki/OCY5wzbGhiLDr8kMulkcLLuSnQd

  19. Microsoft Research. AutoGen and multi-agent research materials. https://www.microsoft.com/en-us/research/project/autogen/

  20. NIST. AI Risk Management Framework. https://www.nist.gov/itl/ai-risk-management-framework

  21. OpenAI. File search. https://developers.openai.com/api/docs/guides/tools-file-search/

  22. OpenAI. Model Context Protocol. https://developers.openai.com/codex/mcp/

  23. OpenAI. Hooks. https://developers.openai.com/codex/hooks/

  24. OpenAI. Build an MCP server. https://developers.openai.com/plugins/build/mcp-server/

What is an agent? What can an agent do? How to use an agent

Key cases: OpenClaw · Hermes · Claude Code · Codex

Core thread: From “model capabilities” to “a task system that can be entrusted, verified, and governed”

Content summary

This report focuses on three questions: what is an agent (Agent), what an agent can do, and how to use an agent. The report proposes that an agent is not a separate model or chat interface, but a task system that is composed of a model and Harness (model execution and interaction layer) and connects to the environment through observation and action interfaces; goals, context, tools, memory, runtime and governance determine whether this system can advance an answer into a verifiable task.

Capability analysis shows that agents have demonstrated consistent value in research synthesis, document and data processing, software engineering, digital operations, continuous automation, and multi-agent collaboration. Their suitability still depends on whether results are verifiable, actions are reversible, permissions are limited, and responsibilities are clear. The report provides methods for task specification, permission classification, verification design, memory layering, skill packaging, and evaluation, emphasizing: define completion before authorizing execution.

The product section uses OpenClaw, Hermes, Claude Code and Codex as four observation samples. Among them, Claude Code and Codex are the focus, starting from entrance, configuration, context, extension, multi-agent, long task, security, typical workflow and team implementation respectively, and absorb the key points of two Chinese tutorials provided by users. Finally, the selection coordinates, organizational readiness, 90-day roadmap and supporting templates are given.

Executive Summary: Ten Key Takeaways

  1. Agent is not a synonym for model, but a task system that combines goals, models, tools, memory, runtime and governance.

  2. The key change in the agent is that the interaction unit changes from “generating an answer” to “delivering a verifiable task within the boundary”.

  3. The value of a capability depends on the quality of the feedback. Strong feedback such as code testing, file rendering, and structured readback make engineering and knowledge work mature earlier.

  4. Applicability should be judged by four conditions: results can be verified, actions can be revoked, authority can be limited, and responsibilities can be clear.

  5. Effective use starts with task engineering: first write down the deliverables, scope, constraints, validation, permissions and failure handling, then discuss the degree of autonomy.

  6. Long-term availability relies on context, memory, skills, tools, and multi-agent orchestration, but each additional layer of capabilities also adds new governance objects.

  7. Security is not the end audit, but the complete chain from untrusted input, minimum permissions, sandbox, approval, secret protection to audit and rollback.

  8. OpenClaw and Hermes embody the resident personal agent route; Claude Code and Codex embody the engineering route with code base and verifiable changes as the core.

  9. The selection of Claude Code and Codex should not stop at the function list. Comparative evaluation should be carried out based on real tasks, unified environment, clear budget and failure classification.

  10. The order of organizational implementation should be task inventory - controlled pilot - capability solidification - large-scale operation; autonomy can only be gradually enlarged with evidence.

One-sentence conclusion|Agent’s competitiveness is ultimately not “whether it can act”, but whether it can continuously deliver verifiable results under controllable costs and risks.

Research Questions and Report Structure

This material does not equate the AI agent with a certain model or product, but rather regards it as a new task execution system: the model is responsible for understanding and decision-making, the tool connects to the real environment, the memory maintains the state, the runtime carries continuous execution, and governance restricts authority and responsibility.

This article focuses on three core questions: What is an agent? What can an agent do? How to use AI agents safely and effectively?

The full text discusses paradigm changes and system definition, capability map and applicable boundaries, task engineering and governance, four product cases, as well as model selection, organizational implementation and trend judgment.

The core judgment of the report is that the value of an AI agent is not to “chat for others”, but to turn tasks into operational units that are entrustable, observable, verifiable, reusable and manageable.

Table of Contents

1. Introduction: From dialogue paradigm to task delegation

The rise of AI agents does not stem from a mutation in the capabilities of a single model, but is the result of the joint maturation of models, tools, operating environments and organizational empowerment. The collaborative unit between humans and AI is gradually shifting from one-time answers to task delivery with boundaries and evidence.

Understanding this paradigm shift helps avoid reducing agents to chatbots or marketing labels and establishes a common starting point for subsequent discussions of system definition, capability boundaries, and governance.

1.1 Why now: from answering questions to delegating tasks

Chatbots often work around conversational turns: users ask questions and the system returns answers. No matter how long the answer is, the main product is still the text. The agent works around the goal and status: the user gives the desired result, allowable range and acceptance conditions, and the system decides the next step on its own during the running process, uses tools to obtain facts or changes the environment, and continuously judges whether it is close to completion.

This distinction can be understood using three interaction paradigms. Search is “I look for information”, dialogue is “I ask you questions”, and the agent is “I give the task to the system, but retain key control points”. AI agents do not require complete autonomy; many reliable systems embed humans into closed execution loops through manual approval, revocable operations, and staged acceptance.

Judgment criteria | If the system can only generate suggestions but cannot continue to act based on real environment feedback, it is closer to an assistant; if the system can continuously select steps, call tools and verify results within the constraints, it only has the characteristics of an AI agent.

The rise of agents is not driven solely by the growth of model parameters. What really changes the shape of products is when models begin to steadily call search, code execution, browsers, file systems, and enterprise interfaces, and can retain state, read feedback, and continue to modify in a single task. When reasoning capabilities are combined with an operational environment, artificial intelligence changes from a content generator to a process participant.

This change can be summarized by three interaction paradigms: search leaves information to humans to filter, dialogue leaves interpretation and generation to models, and agents entrust a constrained work to the system. Delegation does not mean giving up control, but shifting the focus from each operational step to goal setting, key decisions, permission approval and final acceptance.

For organizations, the most important signal is not whether a demonstration can run for dozens of steps, but whether the delivery unit has changed: in the past, model calls or chat seats were purchased, and now task templates, tool interfaces, validation scripts, permission policies, and running records are being built. These assets jointly determine whether the agent can enter real work.

The industrial significance of Agent lies in transforming the collaborative unit between humans and AI from “answers” into “boundary and evidence-based tasks.”

Data basis: OpenAI “A practical guide to building agents”; Anthropic “Trustworthy agents in practice”

1.2 Why technology and organizational conditions mature at the same time

The model capability addresses “whether it can be understood and made decisions”, the tool protocol addresses “whether it can reach the real system”, the runtime addresses “whether it can continue to work”, the verification basis addresses “whether it knows whether it is done correctly”, and organizational readiness determines “whether it can be authorized”. If one of the five is missing, the agent will easily stay in the demonstration stage.

Software engineering matures first because code libraries, compilers, tests, static checks, and version control naturally provide feedback. Research and knowledge work subsequently expanded as web pages, documents, tables, and presentations became actionable objects. Business processes advance more slowly, not because the model cannot write text, but because identity, data, approval, auditing, and exception handling are more complex.

Therefore, adopting an agent is not an automatic upgrade after purchasing a more powerful model. Organizations need to simultaneously sort out processes, data interfaces, acceptance standards, and responsibility chains, and transform vague job activities into tasks that can be delegated, observed, and rolled back.

The implementation of AI agents is the result of the joint maturation of model capabilities and tissue engineering.

1.3 Three core questions and four observation samples

This report first answers three basic questions. First, what is an agent and how to distinguish it from chatbots, fixed workflows and ordinary models; second, what tasks can an agent undertake, which capabilities are relatively mature, and which are still limited by the environment and verification; third, how to use an agent and how to organize task descriptions, permissions, verification and manual supervision into runnable methods.

OpenClaw and Hermes represent the resident personal agent runtime route, emphasizing message channels, long-term memory, skills and continuous operation; Claude Code and Codex represent the engineering agent route, forming verifiable changes around the code base, terminal, IDE, desktop and cloud environment. The four samples are not a full market ranking, but are used to observe how different products combine models, tools, status, and governance.

The report returns to common issues after product analysis: how to layer memories, how to skill repetitive processes, how to connect external systems, how to collaborate with multiple agents, how to audit background tasks, and how to enlarge permissions step by step. This reduces the product menu to a portable methodology.

Products are observation samples, and what really needs to be refined is a systematic approach that can be reused across products.

1.4 Evidence methods, version boundaries and reading paths

Product capabilities are mainly based on official documents, product pages and update logs; the “Claude Code Complete Tutorial” and “Codex Complete Solution” provided by users are used to supplement Chinese operation paths, interface understanding and practical experience; manufacturer research and independent papers are used to discuss effects, security and trends. Different evidence answers different questions. Operation tutorials cannot be used to prove optimal performance, nor can marketing cases be used to replace evaluations under uniform conditions.

Intelligent products change rapidly. The report clarifies the data retrieval date as August 10, 2026, and marks features that are preview, experimental, turned off by default, or platform-limited. Version numbers, pricing, platform support, quotas, and security policies should still be re-verified before actual deployment.

Managers can focus on reading Chapters 1-4, 7, 11-13; readers who want to establish usage methods can focus on reading Chapters 5-7; those who are concerned about personal agents can read Chapter 8; engineering teams should focus on reading Chapter 9 Claude Code and Chapter 10 Codex, and directly use the appendix template to conduct pilots.

Layering “product facts, practical experience, and evidence of effects” is a prerequisite for maintaining report reliability.

2. What is an AI agent: system structure, operational loop and autonomous boundary

An agent is not a separate model, but a task system composed of goals, models, tools, memory, runtime and governance. It continuously acts around a goal and adjusts next steps based on feedback from the environment.

The system definition must not only explain how the agent selects and performs actions, but also must explain the degree of autonomy, artificial control points, and responsibility boundaries.

2.1 A definition that can be used throughout the text

This report defines an AI agent as a system that, within the boundaries of constraints and permissions, can independently select steps around goals on behalf of the user, use tools, maintain task status, and correct actions based on environmental feedback. This definition deliberately places the “model” in the system, rather than equating the model itself with the agent.

The engineering quality of an agent depends on how these components are combined. Stronger models may reduce hallucinations, but they cannot replace correct tool interfaces, test environments, permission policies, and audit records. In turn, a system with moderate model capabilities but a clear operating environment, stable tools, and strict acceptance is often more reliable than a system with “stronger models but fuzzy boundaries.”

“Representing the user” in the definition emphasizes the authorization relationship, “centering around the goal” emphasizes task orientation, “independent selection of steps” emphasizes that the path is not completely hard-coded, “using tools and maintaining status” emphasizes that the system can be exposed to the real environment, “correcting based on feedback” emphasizes closed loop, and “within the authority boundary” incorporates security and governance into the definition itself.

This definition allows for the existence of different degrees of autonomy. A system that can only read the repository and propose modification plans can be a low-autonomous agent; a system that can modify, test and submit for review in an isolated workspace has a higher degree of autonomy; a system that is online for a long time and can be executed across applications requires stricter identity, permissions and auditing.

An agent is a constrained system that continuously acts around a goal and corrects itself based on feedback from the environment.

Data basis: OpenAI “A practical guide to building agents”; Anthropic “Trustworthy agents in practice”

2.2 Six basic components: goals, models, tools, memory, runtime and governance

The target layer translates user intentions into deliverables, scope, and stopping conditions; the model layer is responsible for understanding, reasoning, and next-step selection; the tool layer provides reading and action interfaces; the memory layer saves the current status, project facts, and reusable experiences; the runtime is responsible for execution, scheduling, isolation, and recovery; the governance layer defines permissions, approvals, audits, and responsibilities.

Six components have shortcomings. No matter how strong the model is, if the tool interface does not have clear parameters and error returns, the system will still be misused; no matter how many tools there are, if there are no acceptance criteria, the system may package failure as completion; no matter how long the memory is, if the content is outdated or contaminated, errors will be magnified; no matter how long the running time is, if there is no stop condition, costs and risks will only accumulate.

When evaluating a product, questions should be asked along each of the six components, rather than just comparing model names. It is necessary to know whether the model can be switched, whether the tool is controllable, whether the memory can be viewed and corrected, whether the operating environment can be reproduced, whether key actions are approved, and whether evidence is left during the entire process.

Components Questions Answered Common Failures
Goals What to deliver and when to stop? Task scope drift
Model How to understand and choose the next step? Errors in reasoning or fact
Tools What can I read and do? Miscall, interface failure
Memory How to preserve current state and long-term facts? Obsolescence, contamination, leakage
Runtime Where is it executed and how is it restored? Inconsistent environment, disconnected tasks
Governance Who authorizes, approves, and is responsible? Ultra vires, non-traceable

Agent quality is determined by the weakest system link, not by the model rankings alone.

2.2.1 Model—Harness—Environment: Three-layer boundary of the agent

The six basic components are suitable for making a construction list; from the perspective of operating mechanism, the agent can also be compressed into a three-layer relationship: Model is responsible for understanding, reasoning and selecting the next step, Harness is responsible for constructing context, exposing tools, maintaining loops and states, implementing permissions and verification, and Environment saves the real state and performs transfers. The model and Harness together form an AI agent, and the environment is located outside the AI agent.

This boundary clarifies three often confused issues. First, the model does not directly “see the world”, it can only process observations written by Harness into the context; second, the model does not directly change the world, it can only make tool calls, which are then executed by the action interface; third, environmental feedback is the source of truth, and the model’s readme cannot be used to replace file differences, database status, web page receipts or test results.

So any Agent can be checked with three questions: What can it see, what is it allowed to do, and how can it prove that it does it right? The observation range determines the cognitive boundary, the action range determines the capability and risk boundaries, and the verification mechanism determines whether the system can move from demonstration to reliable operation.

Hierarchy Core responsibilities Main engineering objects Typical failures
Model Understanding goals, reasoning, choosing next steps Model, reasoning budget, output protocol Misunderstandings, hallucinations, wrong strategies
Harness Organizational context, tools, loops, state, permissions, and validation Prompts, Skills, MCP, Hooks, sandboxes, reviews Context pollution, tool misuse, state loss
Environment Save the real state and respond to actions Files, databases, web pages, APIs, applications and users Concurrent changes, irreversible side effects, incomplete receipts

Table 2-1: Responsibilities and failure boundaries of Model-Harness-Environment

Data basis: Chapter 2 of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

2.2.2 From Prompt Engineering to Harness Engineering

Prompts are still important, but the reliability of production-level agents cannot rely solely on a longer system prompt. Harness Engineering focuses on the complete control loop: how to select and trim observations, how to provide stable tool contracts to the model, how to save task state, when to compress the context, which actions must be approved, how to correct or roll back after failure, and what evidence is used to decide to stop.

This shift also explains why the same model performs significantly differently in different products: products wrap the model in different context structures, tool sets, permission mechanisms, execution environments, and evaluation closed loops. The model determines the potential strategy space, and Harness converts potential into repeatable delivery.

The stronger model will absorb some of the strategies originally written in Harness, but Harness will not disappear. As capabilities expand, new observation interfaces, action interfaces, business constraints, and verification responsibilities will continue to be moved out to the system layer. The engineering focus will continue to shift from “teaching the model to complete one step” to “organizing the model to safely complete longer tasks.”

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

2.3 Operational loop: plan, act, observe, correct and transfer

The basic closed loop of an AI agent can be written as “understand the goal - formulate a plan - perform actions - observe the results - revise the plan - complete or hand over.” Each tool call brings new facts back to the system: whether the command succeeded, whether the file was changed, whether the test passed, whether the interface returned the expected data. The model proceeds based on these observations rather than assuming that the previous step has been successful.

Reliability comes from feedback and verification, not one-shot reasoning. For software tasks, observations may be compilation output, test logs, static check results, and diff; for research tasks, observations may be source content, timestamps, data consistency, and reference checks; for business processes, observations may be system receipts, status fields, and approval results.

Report figure 1

Figure 2-1: The coding agent forms a verifiable feedback closed loop between “human-interface-model-environment”

Source: Anthropic, Building effective agents (retrieval date: 2026-08-10)

  1. Understand the task: Identify the final deliverable, audience, limitations and irreversible risks.

  2. Form a plan: Break the goal into executable and checkable intermediate nodes.

  3. Call tools: read, calculate, edit or call external services within the scope of authorization.

  4. Observation results: Return real evidence such as command output, file differences, and interface responses to the system.

  5. Correction and retry: Adjust the path according to the cause of failure, and do not package failure as success.

  6. Acceptance and handover: Compare the completion standards to summarize the results, risks and next steps.

Each step in closing the loop should produce a state change or new evidence. A plan is not a static list, but a current hypothesis; actions must fall into the environment through tools; observations must read the real results of commands, files, interfaces, or pages; corrections must change the path based on the cause of failure; handovers must describe completion, incompleteness, and risk against acceptance criteria.

Reliable agents handle failures explicitly. Command timeouts, test failures, page structure changes, permission denials, and origin conflicts should not be condensed into a “done.” The system needs to retain failure context to determine whether to retry, change tools, narrow the scope, or request human input.

The running closed loop also explains why engineering agents develop rapidly: compilers, tests, diffs, and version control constitute strong feedback; while value judgments, strategic choices, and high-risk operations in the real world lack cheap, objective feedback, so manual participation is more needed.

Reliability comes from observation-correction-verification, rather than one-time generation that looks reasonable.

2.4 Chatbots, Fixed Workflows and Agents

The three are not mutually exclusive product categories, but different control methods. Chatbots are suitable for explanations, suggestions and lightweight generation; fixed workflows are suitable for tasks with stable rules, clear paths and high predictability; agents are suitable for tasks whose paths cannot be completely preset and require judgment based on new information in the middle.

Real products often use hybrid architectures. The agent is responsible for understanding fuzzy targets, finding information and proposing solutions; the fixed workflow is responsible for payment, production release, external sending, data deletion and other high-risk links; the chat interface is responsible for explaining the process and accepting manual decisions. Giving all steps to the agent or writing them into fixed processes is usually not the optimal solution.

A chat interface does not automatically imply an agent, nor does a non-chat interface imply the absence of an agent. The key is who controls the steps: a chatbot typically generates answers; a fixed workflow follows a preset path; an agent chooses the next step based on the current state. Actual systems can use three control methods simultaneously in the same product.

High-impact actions are suitable for preserving deterministic workflows. For example, the agent can collect refund materials, determine whether it is in compliance with the policy, and draft opinions, but the real payment goes through the rules engine and manual approval; the agent can prepare changes for production release, but the deployment system performs fixed checks and permission control.

Type Step Control Suitable for Task Key Risks
Chatbot User pushes round by round Explanation, generation, single round of Q&A The answer seems correct
Fixed workflow Developer preset path Stable, repetitive, clear rules Insufficient exception coverage
Agent The system selects the next step according to status Open path, multi-step task Goal drift and permission risk
Hybrid system Intelligent judgment + determined execution High-value real process Complex boundary design

The most reliable architecture is usually a combination of “intelligent judgment + deterministic execution + manual control points”.

2.5 Degree of autonomy and Human Control Points

“Whether it is an AI agent” does not equal “whether it is fully autonomous.” A more useful way is to break down the degree of autonomy into five levels: read-only analysis, controlled writing, tool execution, background tasks, and multi-agent collaboration. Each level should have independent acceptance gates, rather than automatically receiving higher permissions just because they performed well in the previous stage.

Responsibility remains with the organization and users. Agents can make judgments, perform steps and provide evidence, but who authorizes access to data, who approves high-impact operations, who publishes externally, and who bears compliance responsibilities must be clear in the process. The value of human oversight is not just a “last look” but deciding which nodes must be confirmed by a human.

The degree of autonomy includes at least five dimensions: readable data range, executable tools, writable systems, sustainable time, and self-delegable subtasks. Different dimensions can be configured independently, and agents should not be simply divided into “automatic” and “non-automatic”.

Human control points should be placed at high-leverage nodes: goals and success criteria require human confirmation; when multiple plans involve business trade-offs, human choice is required; permission upgrades, irreversible actions, and external releases require human approval; and independent review is required when the results have a significant impact. Low-risk, reversible, well-verified steps can be automated.

As the system matures, controls can shift from incremental approval to management by exception, but only if there are stable success rates, failure visibility, and audit records. Eliminating manual validation should not precede establishing technical boundaries and evaluation evidence.

Autonomy is not a single switch, but a set of empowerment dimensions matched to risk.

2.6 Single agent, multi-agent and organizational collaboration

Single agents are easiest to maintain consistent goals, context, and responsibilities and should be the default starting point. Splitting multiple agents only makes sense when the prompt logic is too complex, when the tools are highly similar making selection difficult, when certain side tasks generate a lot of context, or when the tasks can be clearly parallelized.

Common structures include the manager model and the peer-to-peer model. In the manager mode, the main agent holds user goals and delegates tasks such as research, testing, and security reviews as tools; in the peer-to-peer mode, multiple sessions share tasks and communicate with each other, which is more suitable for complex work that requires discussion and negotiation.

The costs of multi-agent include repeated reads, increased costs, version conflicts, inconsistent conclusions, and blurred merge responsibilities. When splitting, you need to define inputs, outputs, tools, editable scope and acceptance criteria for each role, and ultimately still need a clear merger.

Multi-agent is a complexity tool, not a demonstration of ability; when it can be solved with one agent, use one first.

3. What the agent can do: Capability map and scenario maturity

Agents are already able to participate in research synthesis, document and data processing, software engineering, digital operations, continuous automation and multi-agent collaboration, but the maturity of different scenarios varies significantly.

Judge value not just by the sequential steps in the demo, but also by looking at the deliverables, the strength of the feedback, the cost of verification, and the impact of errors.

3.1 Six types of relatively mature abilities

At present, the more mature AI agent capabilities can be summarized into six categories. What they have in common is not “the ability to generate content”, but the ability to organize multiple sources of input, multiple intermediate steps and verification actions into a complete task.

The common characteristics of mature capabilities are that inputs can be obtained, steps can be executed, and results can be verified. It does not matter whether a system “can summarize”, but rather whether it can find material, distinguish sources, generate deliverables, check formatting and evidence, and account for limitations when information is missing.

Competency Domain Typical Deliverables Verification Methods Maturity
Research synthesis Presentation/report with sources Source coverage, citation verification Higher
Documents and data Word/PPT/forms Rendering, formulas, sampling verification Higher
Software Engineering Code Change and Testing Diff, Testing, Static Checking Higher
Digital operations Cross-system recording or configuration Readback, screenshots, logs Medium
Continuous automation Regular monitoring and notification Operation history, abnormal alarms Medium
Open reality action External irreversible results Often require manual confirmation Caution

Using a complete task chain to describe capabilities is closer to the real value than using verbs such as “search, summarize, write code”.

3.2 Research, reporting and knowledge work

Research agents can generate search strategies around questions, browse websites, documents, update logs, and business company pages, extract key facts, mark sources and times, and organize the evidence into reports, tables, or presentations. The value of this type of task is to reduce data handling and format conversion, allowing people to focus on problem setting, evidence weight and conclusion judgment.

However, when studying AI agents, the most common problem is that “the references exist but the content does not support the conclusion.” Therefore, acceptance cannot just be based on whether there is a link, but whether the source directly supports the sentence in question, whether the information is out of date, whether different sources contradict each other, and whether commercial promotion and independent evidence are confused.

High-quality research agents need to include search scope, source priority, publication date, cross-corroboration, and citation locations in their tasks. For commercial products, official websites, documents, and update logs are often more timely than papers; for effects and risks, independent research, standards, and actual measurements are more important.

Humans should focus on research questions, weight of evidence, and conclusion boundaries. Agents can cover more sources and unify formats, but they cannot replace judgments about conflicts of interest, sample representativeness, and causality.

The core of studying AI agents is not to capture more information, but to establish a traceable chain of evidence.

3.3 Digital operation and business collaboration

When the agent connects to browsers, emails, calendars, databases and business APIs, it can read work orders and customer records, determine the type of problem, generate handling suggestions, update system fields and arrange follow-up. It can also turn meeting minutes into tasks, organize feedback from multiple channels into priority lists, or clean tabular data into usable analysis results.

Value often comes from cross-system connections. For example, customer complaint handling is not about writing a reply, but about reading historical tickets, identifying problems, finding policies, formulating solutions, updating CRM, creating schedules and maintaining audits. The closer it is to real business, the more important it is to distinguish between “generating a draft” and “formally sending”, “proposing updates” and “actual writing”.

Cross-system tasks typically include reading state, interpreting unstructured content, selecting processing paths, updating records, and scheduling follow-up. Agents are good at handling exception branches outside the rules, but write and outgoing actions should be drafted, suggested, approved, or automatically executed based on the impact level.

The difficulty in business adoption lies in identity and status consistency. The system must know who is currently represented, which version of the data is read, whether the action is truly successful, whether repeated execution is idempotent, and how to compensate after failure.

The value of business intelligence lies in the cross-system closed loop, and the risks are also concentrated in identity, writing and outgoing.

3.4 Software Engineering and Verifiable Changes

Software engineering is a field where agent capabilities are relatively mature because the code base provides structured context and the compiler, testing, static checking, and Git provide strong feedback. Engineering agents can start from Issues, error logs or requirement descriptions, locate relevant code, modify across files, run tests, check diffs, and form commits or PRs.

The real value is not in “generating a piece of code”, but in completing a reviewable engineering closed loop: it can explain what was changed, why it was changed, what was verified, and what risks there are. Both Claude Code and Codex are strengthening this complete way of working from exploration to verification.

The code base provides structured context, the toolchain provides high-density feedback, and version control provides review and rollback. The agent can complete code positioning, cross-file modification, testing, static inspection, diff review and PR preparation, and the results can be accepted more objectively.

Engineering agents still require domain knowledge. Requirement implications, compatibility strategies, architectural trade-offs, and production risks are often beyond test coverage. People who are familiar with the system can give better boundaries, evidence, and feedback, and therefore produce higher quality results.

The strongest thing about engineering agents is not to generate code, but to incorporate code changes into verifiable engineering processes.

3.5 Data analysis, tables and multi-modal delivery

Data tasks can start from raw tables or exported files and complete field identification, anomaly checking, calculations, visualization and report delivery. Multi-modal capabilities enable the system to read screenshots, design drafts and scanned documents and write analysis results into spreadsheets, Word or presentations.

The key to this type of task is to maintain the data lineage: the original data is not overwritten, the cleaning rules can be recorded, the formulas and results can be recalculated, and the graphs and text conclusions are consistent. Visual delivery also requires rendering checks to avoid occlusions, truncation, or font substitutions on the page if the file structure is correct.

For statistical conclusions, agents should report sample size, caliber, missing values, and uncertainty, and not just output a seemingly precise number. For analyzes that require specialized models, agents should call proven code or tools rather than relying on language model mental arithmetic.

Multimodal agents extend analysis into final delivery, but data lineage and visual acceptance must be preserved.

3.6 Continuous automation and background work

When task descriptions, tool permissions, and acceptance criteria have stabilized, the agent can go into the background or run on a schedule: checking daily error logs, summarizing weekly code changes, tracking PR status, scanning for dependency updates, generating operational reports, or monitoring specific metrics. Compared with traditional timed scripts, the agent can handle format changes and abnormal branches; compared with real-time conversations, it can continue to advance unattended.

The bar for continuous automation is higher because mistakes happen repeatedly. Before formal scheduling, you must manually run several rounds to confirm whether the input is stable, whether the failure is visible, whether the results are reviewable, and whether the stopping conditions are clear. One of the most common adoption mistakes is handing over high-privilege work to a timed agent without observation.

The background agent can handle input format changes and abnormal branches, but errors will also amplify with frequency. Before formal scheduling, multiple rounds should be manually run to record normal, unchanged, partial failures, and insufficient permissions behaviors, and then gradually reduce the frequency of manual observation.

Each background task must define a reporting strategy: what changes are worthy of notification, whether to be silent when there are no changes, how many consecutive failures to stop, where to write the results, and who is responsible for recovery. Simply setting a timed reminder without operational responsibility turns a one-time risk into an ongoing risk.

The prerequisites for continuous automation are stable task descriptions, narrow permissions, observable failures, and clear accountability.

3.7 Multi-agent collaboration

Multi-agent is suitable for tasks that can be parallelized and independently accepted. For example, one agent studies the market, another analyzes technical solutions, the third does security review, and the main agent finally summarizes. In engineering scenarios, different sub-agents can be allowed to explore the code, supplement tests and review risks respectively.

More parallelism is not always better. Subagents increase cost, context synchronization, and merging difficulty. Parallelism only really improves time when tasks have few dependencies on each other, delivery boundaries are clear, and failures do not contaminate each other. For highly coupled code modifications, it is more secure to have a main agent complete the overall design first, and then assign independent subtasks.

Parallelism is best suited for work with independent information sources, independent file scopes, or independent evaluation dimensions. Research can be divided by source or hypothesis, development can be divided by module, and review can be divided by security, performance, testing, and maintainability. The main agent is responsible for unifying the problem, eliminating conflicts, and forming final conclusions.

If multiple agents need to constantly read each other’s intermediate results, or modify the same core file at the same time, parallelism is usually not faster. At this time, one role should first complete the architecture and interface design, and then split the stable boundary.

Tasks can be independently accepted, which is the basic condition for multi-agent to generate net benefits.

3.8 Scenario Maturity Matrix: Value, Verifiability and Impact

Scenario maturity should be determined by task conditions rather than product hype. Whether input is stable, whether environmental feedback is timely, whether deliverables can be independently verified, whether actions are revocable, and whether permissions can be restricted are key variables in judging whether the degree of autonomy can be improved.

Research synthesis and software engineering typically have stronger feedback, making it easier to establish end-to-end processes; cross-system business operations may be of higher value, but identity, approval, and exception handling are more complex; and open reality actions should retain greater human control once they are irreversible.

Maturity is not a fixed attribute. By supplementing structured input, readback interfaces, test scripts, simulation environments and rollback mechanisms, the same task can be gradually upgraded from “assistance only” to “controlled execution”. Conversely, environmental changes or verification failures can also reduce maturity.

Pilot records should save both success and failure conditions to avoid treating a single successful operation as a universal capability. Scenario maturity is organizationally meaningful only if it can be delivered reliably across different inputs, exceptions, and permission boundaries.

When converting maturity judgments into pilot plans, you should first select tasks that are narrow in scope, provide fast feedback, and have manual baselines. It is not advisable to change data sources, business rules, and execution tools at the same time during the pilot, otherwise it will be difficult to attribute success or failure.

The pilot must record at least four sets of indicators: completion quality, time and cost, manual intervention location, risks and anomalies. The completion rate must be counted separately from the correctness of the results; just because a task seems to be completed does not mean that the deliverables have met business standards.

Increased autonomy can then be stratified by risk. Low-risk steps are allowed to be executed automatically, medium-risk steps are set for sampling review, and high-risk and irreversible actions are reserved for sequential approval. Every increase in level of autonomy must be supported by new verification evidence.

Therefore, a truly replicable scenario is not a beautiful demo, but a set of task products that include input contracts, execution boundaries, acceptance criteria, exception handling, and responsible persons. Organizations should engineer tasks first before discussing whether to expand agent authority.

High-value, easily verifiable, low-impact tasks are best suited for piloting first, such as open source research, small-scale test completion, internal reporting, and read-only diagnostics. High-value, easily verifiable but high-impact tasks are suitable for agent execution and human approval, such as production release preparation and customer refund recommendations.

Tasks that are difficult to verify and have high impact should not be automated. Agents are more suitable as analysis assistants or solution generators. Tasks with low value and stable rules should give priority to using scripts and traditional workflows to avoid introducing additional costs for “intelligence”.

Maturity is not a fixed attribute. Through supplementary testing, structured data, sandboxing, approval and rollback, originally higher-risk scenarios can be gradually transformed into delegated tasks.

Task characteristics Applicability judgment Suggested methods
Verifiable results, revocable actions, limited permissions Priority pilot Allow end-to-end execution
The results are verifiable but the impact is large Conditionally applicable Key node approval
Judgment is subjective and evidence is incomplete Auxiliary use Generates options and evidence, does not replace decision-making
High risk, irreversible, unclear responsibilities No entrustment for the time being Retain human leadership

Transforming validation and boundaries first, and then increasing the degree of autonomy is often more effective than pursuing a stronger model directly.

4. Capability boundaries, failure modes and evaluation methods

Agents can expand the range of tasks that can be automated and introduce new failure modes such as goal drift, factual errors, tool misuse, environmental inconsistencies, and unauthorized access.

Only when failure mechanisms, takeover conditions, and evaluation indicators are incorporated into system design can capability boundaries be transformed from abstract reminders into executable management rules.

4.1 When not to use agents

Tasks with fixed rules, stable paths, and low-cost programming should prioritize the use of scripts or workflows; tasks that cannot verify the results should first establish a checking mechanism; high-impact tasks such as payments, production changes, external sending, and data deletion should not be fully autonomous in the absence of approval; tasks that expose a large number of credentials or sensitive data should first reduce permissions and isolate the environment.

Scenario selection | Don’t just write isolated actions such as “summarizing, classifying, and writing code”; only by writing input, multiple intermediate steps, final products, and verification methods into complete tasks can you take advantage of the agent.

If the task path can be written as a deterministic script at low cost, traditional automation is usually cheaper and more stable; if there is no way to judge whether the result is right or wrong, the agent cannot be improved through closed loop; if the action is high-impact and irreversible, automatic execution should not be authorized without approval.

Not using it does not mean completely excluding agents. It can undertake preliminary material sorting, plan comparison, risk warning and draft generation, leaving the final action to a fixed system or person. The key is to get capabilities into the right parts, rather than automating complete processes for the sake of automating them.

Scenario boundaries determine project success more than model capabilities.

4.2 Cognitive Failure: hallucinations, Misunderstood Goals, and Overconfidence

Agents may cite non-existent sources, misread user intent, mistake partial successes for overall successes, or reach firm conclusions when there is insufficient evidence. Because it performs multiple steps, early misunderstandings can be magnified later.

Reducing cognitive failure requires writing goals, don’ts, and acceptances clearly, requiring exploration before action, using external evidence and structured output, and allowing the system to request input when critical information is missing, from conflicting sources, or with insufficient confidence. For high-stakes judgments, independent review should be arranged rather than having the same agent self-confirm.

Long chains of agents amplify early misunderstandings, so clarification and planning gates must be placed up front.

4.3 Execution failure: tool error, status drift and partial completion

The tool may time out, return truncated results, modify incorrect files, duplicate submissions, or only partially complete. Web interfaces change, API status updates occur concurrently, and long tasks may lose critical context after session compression. The execution system must treat return codes, file differences, and external receipts as sources of truth.

Consider idempotence, transactions, and compensation for write actions: is it safe to repeat, how to recognize partial success, and how to roll back after failure. Task status should be logged explicitly rather than just existing in the conversation. Phased acceptance prevents errors from propagating over long links.

The real danger is not that the tool reports an error, but that the system still reports success after the tool fails.

4.4 Security failure: prompt injection, unauthorized access and supply chain

Web pages, emails, issues, code comments, documentation, and MCP returns may contain malicious or misleading instructions. If the agent confuses these contents with user authorization, it may leak information, invoke high-privilege tools, or alter long-term memory.

Third-party Skills, Plugins, Hooks, and MCP servers are both capability sources and software supply chains. Risk control requires content isolation, tool least privilege, secret protection, source review, version pinning, network restrictions, and approval of high-impact actions, rather than just reminding the model to “ignore malicious instructions.”

Prompt injection is a permissions and data-flow problem, not merely a prompting problem.

4.5 Evaluation Framework: Task Success, Evidence, Controllability and Cost

Task success rate should be calculated based on complete acceptance, rather than self-reported by the model; evidence quality checks whether tests, citations, receipts, and diffs directly support the conclusion; controllability focuses on whether failures are visible, whether manual intervention points are reasonable, and whether misoperations are recoverable; costs are also calculated for model calls, manual reviews, infrastructure, and rework.

The evaluation set should be from real tasks, covering normal samples, boundary samples, missing inputs, insufficient permissions and malicious inputs. A single demonstration can only illustrate the possibility. Stable results from multiple consecutive rounds, different operators and different times support promotion.

Dimensions Core indicators Evidence
Task success End-to-end success rate, first-time pass rate Deliverables and acceptance records
Correctness Facts/tests/calculated error rates Quotes, tests, spot checks
Efficiency Labor time, total delay, cost Control group and log
Robustness Abnormal recovery, number of retries Failure classification
Security unauthorized action, sensitive data, approval hits Audit records
Usability Taking over burden, clarity of instructions User feedback

To evaluate Agent, you need to look at the complete task and running evidence, not just the final text.

4.5.1 Capability upper limit and service reliability should be measured separately

Pass@k answers the upper limit of the ability of “try k times independently and succeed at least once” and is suitable for exploring whether the model is possible to complete the task; Best@k focuses on whether the best result can be selected from multiple candidates. Real business is more concerned about continuous reliability: whether the same process is successful k times in a row can be observed by multiplying Pass consecutive@k or the approximate success probability.

The meanings of the two indicators are not interchangeable. A system with a single success rate of 90% seems to be very high; but if a business link contains multiple independent key steps, or is required to be correct ten times in a row, the overall reliability will be significantly reduced. The pilot report should also give the success of a single task, the success of continuous operations, the manual takeover rate and the recovery cost after failure.

Assessment perspective Questions to answer Applicable stages Misunderstandings that need to be prevented
Pass@k Can you succeed at least once in multiple attempts Capability exploration, model comparison Does not represent stable production performance
Continuous success Whether multiple consecutive runs always meet the standards Business launch, SLA evaluation Too few samples will overestimate reliability
Manual takeover rate How many tasks require people to supplement or correct errors Piloting and operation Low takeover may come from the risk of omissions
Recovery cost How long does it take to locate, rollback and rerun after failure High-impact process Don’t just count model costs

Table 4-1: Complementary indicators of capacity upper limit and business reliability

4.5.2 From final results to trajectories, boundaries and first error attribution

The end-to-end result evaluation determines whether the task is finally completed; the trajectory evaluation further checks what information the model saw, why a certain tool was selected, whether the permissions are compliant, whether the real receipt is read, and whether it is corrected correctly after failure. Looking only at the final answer will miss “getting it right by accident”, and looking only at the reasoning process may be divorced from the real result, so the two must be combined.

Trajectory prefix evaluation is suitable for testing boundary judgment: truncate the run at a critical node and let the system decide the next step based on the information available at that time. For example, whether the current command covers historical rules, whether dangerous actions should be confirmed again, and whether low-confidence searches should be rejected. It can turn occasional incidents into stable regression use cases.

First error attribution requires identifying the first node in the trajectory that is significant enough to cause a failure and distinguishing between task specification, context, model, tool, environment, permissions, or validation issues. When the root cause is unclear, teams tend to use longer prompts to cover up tool defects, or use stronger models to cover up unreproducible circumstances.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

4.5.3 Establish a sustainable Agent evaluation closed loop

The complete evaluation infrastructure consists of reproducible environments, task datasets, automated verifiers, LLM-as-a-Judge, rubrics, trace recording, and problem analysis. The executable facts are given priority with deterministic verifiers such as code, tests, amounts, and status fields; style, completeness, and policy explanations can be reviewed by models with scoring standards, but the evidence position must be retained and “insufficient evidence, reject scoring” is allowed.

Real failures should be entered into the evaluation set: retained input, environment version, tool output, first error node, final impact and repair method. After the system is modified, the target use case is run first, and then the general regression and safety boundary set are run; the gray scale is expanded only after passing the test. Evaluation is not an acceptance activity at the end of the project, but an ongoing engineering cycle of observation-hypothesis-experiment-validation-new hypothesis.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

4.6 ROI and total cost of ownership

Benefits from agents may come from shortened cycle times, improved coverage, reduced waits, standardized delivery, and freed up expert attention. The cost is not only model fees, but also includes tool construction, environmental maintenance, permission review, evaluation, manual review, failure recovery and extended supply chain management.

The most overlooked are the costs of rework and supervision. If users must review all output line by line, nominal automation translates into a new review burden. A good process will automate verification, focus differences, and explicitly mark high-risk parts, so that humans only review the parts that really require judgment.

The core of ROI is not how much less money is spent on models, but how much total cost each reliable delivery requires.

4.7 Manual intervention, stop conditions and responsibility rollback

Manual intervention should be triggered in at least three types of situations: continuous failure exceeds the threshold, action impact is high and irreversible, and key facts or authorization are unclear. The system should hand over the current goal, completed steps, evidence, errors, and suggested options to avoid people having to understand it from scratch.

Stop conditions not only prevent risks but also control costs. Can be stopped by maximum steps, maximum time, fee cap, number of failures, permission denied, or conflicting evidence. Stopping is not a cover for failure, but an integral part of the reliability of an agent’s system.

Being able to stop at the right time and hand over clearly is an important ability of a mature agent.

5. How to use agents: task engineering and human-agent collaboration

Effective use of agents starts with task engineering, not with a longer prompt. Deliverables, scope, constraints, permissions, validation, and failure handling collectively determine whether a task can be reliably delegated.

The role of humans has also shifted from step-by-step operations to goal setting, key decisions, permission approval and final acceptance, while low-risk and verifiable steps are continued by the system.

5.1 Start with the right task

The best pilot is not the grandest and most important task, but a task with “real value, many steps, controllable risks, and verifiable results.” For example: generate a research report with references based on public information; fix a small range of bugs based on test failures; read work orders and generate processing suggestions to be manually confirmed; summarize changes to the code base every week but do not automatically publish them.

Four questions to ask when selecting a task: Is the final deliverable clear? Are real tools and data available? Is there an objective acceptance method? If an agent makes a mistake, can it be undone or discovered by a human in time? If the answer to more than two of the four questions is no, the scope should be narrowed down first.

An ideal pilot has four conditions: real value, many steps, controllable risks, and verifiable results. Tasks should be small enough to recover from failure, but large enough to demonstrate cross-step value. Publicly available data research, small-scale bug fixes, test completion, and internal reporting are often better than directly automating emails or operating production systems.

First choose a verifiable small closed loop, and then gradually expand the tasks and permissions.

5.2 Upgrade prompts to task instructions

A single cue word is often insufficient for complex tasks. A reliable task specification contains at least six types of information: goals, context, scope, prohibitions, evidence and acceptance, and stopping conditions. It is the equivalent of giving the executive a brief project charter.

A task specification does not require every step to be spelled out. Its function is to clarify the “results and boundaries” and allow the agent to choose its own path within the boundaries. For exploratory tasks, the plan can be allowed to change dynamically, but phased summary and acceptance nodes must be maintained.

The task specification describes the results and boundaries, not all the steps. For exploratory tasks, plan changes can be allowed, but phased summaries must be required; for engineering tasks, verification commands and unmodifiable items must be listed; for business tasks, drafts, suggestions, writing, and external sending must be distinguished.

Field What to write Example
Goals Problems to be solved Complete special report
Deliverables Files, formats, audiences 80+ page Word report
Scope Inclusions and Exclusions Four Products, Focus on CC/Codex
Constraints Time, tools, sources, style Official information is preferred
Validation How to judge completion Number of pages, table of contents, rendering checks
Permissions Allow/Require confirmation/Prohibit Read-only search; write local files
Failure handling When to retry or upgrade Marking when sources conflict

Complex tasks require a micro-project charter, not a wish.

5.3 Five steps from read-only pilot to continuous automation

  1. Read-only pilot: Let the agent read, analyze, organize and propose solutions first, without writing to key systems.

  2. Controlled writing: Only directories and files necessary for the task are opened, and all changes are reviewed through diff or version control.

  3. Tool execution: Allows running low-risk tools such as testing, formatting, and querying, while maintaining manual approval for high-impact actions.

  4. Skilling: Encapsulate processes that have been verified many times as Skills, rules or project instructions to reduce re-interpretation each time.

  5. Background and parallelism: Enable scheduled tasks, cloud long tasks or multi-agent after the process is stable, and strengthen auditing.

The evidence of “passing” must be defined individually for each level. For example, when upgrading from read-only analysis to controlled writing, you should at least confirm that the agent can correctly identify the file range, will not accidentally modify irrelevant content, can run basic verification, and clearly report failures. Upgrading is a risk decision, not a product feature switch.

Evidence of success is redefined at each level. The read-only stage looks at fact and range identification, the write stage looks at diff and rollback, the tool stage looks at commands and receipts, the skilling stage looks at cross-sample stability, and the background stage looks at unattended failure and auditing. Only when the previous level is stable can you enter the next level.

Privilege escalation should be driven by operational evidence and should not be driven by product feature availability.

5.4 Plans, Milestones and Task Status

The plan should list task breakdown, dependencies, risks, validations, and stopping points. It is not to show that the agent “can plan”, but to allow people to judge the direction before investing a lot of execution costs. High-uncertainty tasks should be scheduled for exploration milestones first, and high-risk tasks should be scheduled for environment and rollback verification first.

Each milestone requires a status update: what was accomplished, what the evidence is, why the plan was adjusted, what are the next steps. Status should be written to a resumable summary or project file, and you cannot rely solely on long conversations.

The value of planning is to expose errors of direction in advance and provide recovery points for long tasks.

5.5 Write verification into “Definition of Done”

The criteria for completing an agent’s task cannot be just “generate content” or “modify code.” Research reports should check that references directly support the conclusions, source dates are valid, and numbers are consistent; engineering tasks should run tests, static checks, formatting, and review diffs; business tasks should check system receipts, field status, and approval records.

It is best to ask the agent to answer four questions upon delivery: What did it do? What is the basis? How to verify? What’s left unfinished or at risk? These four questions can significantly reduce the situation of “surface completion but actual unverification”.

Research report check citation and time, engineering task operation test and review diff, data analysis recalculation formula and caliber, business operation confirmation system receipt and approval. Validation must be part of the task, not an optional additional step after completion.

If there is no “how to know when you get it right” in the task description, it is easy for the agent to only optimize the superficial completion.

5.6 human-agent interaction: Feedback should be directed towards rules, evidence and trade-offs

Effective feedback should indicate which fact is incorrect, what constraint was violated, what evidence is missing, or what trade-offs are needed. For repeated errors, the project instructions or skills should be updated; for mechanical force, it should be changed to Hooks or rules; for one-time preferences, just keep them in the current task.

Users should also require agents to explicitly present uncertainties and rejected solutions. This way, follow-up personnel can understand the decision-making process and determine whether the failure resulted from the input, tool, model, or environment.

High-quality collaboration is not about more rounds of chatting, but about settling corrections into the appropriate system layer.

5.7 Context and long-term task management

More context is not always better. Large amounts of logs, search results, and duplicate files can crowd out a model’s attention. Long tasks should form a short summary at each milestone to record the current goal, completed, key decisions, unfinished items, verification status and next steps. When you need to delve deeper into a certain side of the task, you can use sub-agents to isolate high-capacity exploration.

Stable facts should be kept separate from interim procedures. Project build commands, architectural constraints, and review rules are suitable for writing into CLAUDE.md or AGENTS.md; reusable multi-step processes are suitable for making Skills; session processes and logs are only retained in the current task; automatic memory is more suitable for recording experience and preferences, rather than assuming hard rules that must be executed.

Long tasks should periodically compress logs and intermediate exploration, retaining only goals, key facts, decisions, completed, verification and next steps. Stable project rules are written into CLAUDE.md or AGENTS.md, repetitive processes are written into Skills, and the current session log should not permanently occupy the context.

The goal of context management is to maintain relevance, not to cram all information into the model forever.

5.8 Failure recovery, review and process upgrade

After failure, first differentiate between target misunderstandings, missing information, tool errors, environmental differences, insufficient permissions, and verification gaps. Different reasons correspond to different improvements: clarifying tasks, supplementing data, fixing tools, fixing the environment, adjusting permissions, or increasing acceptance. Simply rerunning the same prompt will often repeat the same problem.

Review should decide where to put improvements: project rules, skills, hooks, tests, sandbox configuration or organizational processes. Only when errors are transformed into reusable improvements can the agent system truly have a learning effect.

Precipitating failure into rules, tests, and skills is more reliable than asking the model to “pay attention next time.”

6. Critical infrastructure: context, memory, tools and multi-agent

To undertake long-term, repetitive and parallel tasks, agents must rely on infrastructure such as context management, hierarchical memory, tool interfaces, skill assets and multi-agent orchestration.

These mechanisms respectively solve the problems of information supply, state continuation, real action, method reuse and task division. They also bring new versions, permissions and coordination costs.

6.1 Context Engineering: Determining what the current task sees

Context is the work material that the agent can currently directly use, including user goals, system instructions, project rules, read files, tool results, and stage summaries. Contextual quality depends on relevance and structure, not sheer length. Reams of duplicate logs, irrelevant documentation, and broad tool descriptions dilute the information that really matters.

Context engineering answers four questions: which content must always be loaded, which content is loaded by file path, which content is only loaded when the task is triggered, and which content should be read by the sub-agent and returned with a summary. Stable and short rules are placed in the resident layer, domain materials and long processes are loaded on demand, and side tasks use isolated contexts.

Condensation and summarization should occur at natural milestones. The summary at least retains the goal, completed, key facts, decision, verification, unfinished, and next step; if only “done a lot of work” is retained, subsequent agents cannot reliably recover.

Context engineering pursues high signal-to-noise ratio and recoverable states, rather than the maximum amount of input.

6.1.1 Stable prefix, dynamic trajectory and task status bar

The context can be divided into stable prefixes and dynamic trajectories. The stable prefix includes system rules, core tool definitions and project-level constraints. It should be kept byte-level stable as much as possible to reuse KV Cache or server-side Prompt Cache; dynamic tracks append user messages, tool calls, results and stage summaries according to time. Frequently rewriting prefixes or cramming all tools into the context at once increases both cost and selection noise.

Long tasks also require a short, structured task status bar that continuously records goals, current stage, verified facts, open issues, risks, budget, and next steps. Rather than replacing the full trajectory, it allows the model to quickly recover “where it is now” at each round. The status bar should be updated by Harness based on the real operation to avoid relying solely on model free summary.

6.1.2 Compression, isolation and progressive disclosure are three different methods

Compression is suitable for completed history, folding a large number of processes into goals, decisions, evidence and remaining work; context isolation is suitable for search, long log analysis or special review, allowing sub-agents to return only conclusions and evidence; progressive disclosure is suitable for tools and Skills, loading the metadata directory first, and then reading detailed instructions or scripts after hitting the task. The three handle the contextual growth of time, task and capability catalogs respectively.

Roots of trust must be preserved before compression: current user directives, permission boundaries, outstanding commitments, key origins, and verification status. If the abstract only retains the conclusion and does not retain the location of evidence, subsequent rounds will mistake unverified intermediate judgments as facts.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

6.2 Persistent instructions: write stable rules to each task

Persistent directives are good for storing repository structure, build commands, coding style, don’ts, and delivery formats that you need to know every time you work on it. They should be short, actionable, versionable, and reviewable by the team. Vague statements such as “pay attention to quality” should be rewritten into specific actions and verification commands.

Documents at different levels should be consistent. Global rules define a common bottom line for an individual or organization, project rules define repository conventions, and subdirectory rules handle specific languages ​​or components. When conflicts arise, rely on clear priorities and more specific scope, rather than copying the same sentence into multiple places.

Persistent directives are not enforcers. If the rule must be unconditionally true, it should be checked with permissions, command rules, Hook or CI. Otherwise it remains within the context that the model needs to be interpreted and followed.

Persistent instructions preserve “know it every time”, and enforcement mechanisms guarantee “must do it every time.”

6.3 Memory stratification: working memory, project facts and long-term experience

Working memory serves the current task, project facts are maintained by humans and put into version control, automatic memory distills preferences and experiences from history, and conversational retrieval looks up past processes when needed. The writers, life cycles and credibility of the four are different and cannot replace each other.

Memory needs governance. Users should be able to view, correct, delete and export; secrets should not enter long-term memory; automatically generated experiences must have a source and update time; hard rules cannot only exist in model memory. Expired memory will cause hidden errors. The longer the memory, the more cleaning and conflict handling are needed.

The ideal memory writing has clear triggers: recurring project facts go into the rules file, proven multi-step methods go into the skill, personal preferences go into the user memory, and the in-betweens of the current task are archived or compressed after the task is completed.

Hierarchy Content Life cycle Governance points
Session state Current plan, tool results Single task Prevent context overflow
Project memory repository/process agreement Project period Editable and traceable
User preferences Stable expression and collaboration preferences Cross-task Requires confirmation and error correction
Organizational knowledge Policies, standards, cases Long term Versions and permissions
Skill memory Reusable steps and scripts Long term Test, release, rollback

The value of memory is not in “never forgotten”, but in being traceable, correctable and used on demand.

6.3.1 Distinguish between user memory and organizational knowledge base

User memory serves the individual scale, saving preferences, relationships, historical decisions, and proven habits; the knowledge base serves the team or organizational scale, saving policies, products, projects, and professional materials. The former emphasizes individual control, privacy, and right to correction, while the latter emphasizes source, permissions, versions, coverage, and consistency. Both can be retrieved, but write policies and governance responsibilities are different.

The reliable memory life cycle includes: reading according to relevance at the beginning of the task; recording candidate facts during operation rather than writing immediately and permanently; judging whether to add, update, delete or remain unchanged based on source, time, conflict and privacy in the background; retaining the provenance and verification time after writing. Simple notes are suitable for atomic facts, structured cards are suitable for updateable attributes, narrative records are suitable for event background, and procedural experiences are more suitable for Skills or executable scripts.

6.3.2 RAG is a retrieval system and a knowledge organization system

The basic RAG link includes collection and cleaning, semantic segmentation, indexing, retrieval, rearrangement, generation and reference. Dense retrieval is good at semantic approximation, while sparse retrieval such as BM25 is good at proper nouns and precise word forms. Production systems often use mixed retrieval and then rearrange. Chunking should not only be cut by a fixed number of words, but also preserve metadata such as title, path, time, document version, and access control.

When data size and problem complexity increase, flat vector indexing is not always sufficient. Hierarchical summarization can support drilling down from global topics to the original text, knowledge graphs are suitable for entity relationships and multi-hop problems, and file system directories can be used as natural interpretable levels. A practical principle is to place short, stable structural overviews in context, and to load long, thin pieces of evidence on demand through retrieval.

Agentic RAG hands retrieval as a tool to the Agent: the system first analyzes the problem, rewrites the query, selects a knowledge source, and then determines whether to complete the search, change filter conditions, read the full text, or stop based on the results. It improves the coverage of complex problems and also introduces more loops and costs, so it must be evaluated jointly with recall, citation correctness, rejection performance and retrieval trajectory. Section 11.11 gives a project path to implement this architecture using Codex.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

6.3.3 Knowledge writing, updating and publishing require independent management

The knowledge base is not a one-time import project. Incremental updates are responsible for absorbing new documents and new evidence, and periodic sorting is responsible for deduplication, merging conflicts, eliminating expired content, and rebuilding indexes; for high-impact knowledge such as policy, medical, legal, financial, or production operations, candidate updates should be independently reviewed before being released.

Retrieval permissions must be performed based on user identity and document ACL on the backend and cannot rely solely on Prompt reminders. Deletion, withdrawal and version replacement should simultaneously affect the original text, index, cache and citation; the answer should return the source title, positioning information and version time. If no sufficient basis is found, the answer should be explicitly rejected.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

6.4 Skills: Turn procedural knowledge into reusable abilities

Skills are suitable for encapsulating repetitive processes and domain knowledge that require judgment, such as code review, publishing, research retrieval, and data cleaning. A complete Skill should contain a clear description, input requirements, steps, output, verification, stopping conditions, and reference templates, scripts, and examples as needed.

The trigger description determines whether the agent will correctly select the Skill. If the description is too broad, it will be triggered by mistake; if the description is too narrow, the scene will be missed; if the boundaries of multiple Skills overlap, it will make selection difficult. Teams should build examples using real tasks to test automatic triggering, manual invocation, failure handling, and contextual costs.

Report figure 2

Figure 6-1: Context loading method of persistent instructions, Skills, MCP, Subagents and Hooks

Source: Claude Code official document, Extend Claude Code (retrieval date: 2026-08-10)

Scripts and dependencies in Skills are part of the supply chain. The source and execution content of third-party Skills must be reviewed before installation. Internal Skills must be versioned, responsible persons designated, and change records kept.

Skills are procedural memories and software assets that need to be tested and managed.

6.5 Tools, MCP and external system connections

Tools transform model decisions into verifiable actions. Data tools read information, action tools change systems, and orchestration tools manage tasks and delegation. Tool names, descriptions, parameters, permissions, and error returns must be clear; too many similar tools will make selection difficult, and broad tools will increase risks.

MCP provides standard connections for external services, but the connection itself does not equal security. Authentication, authorization scope, transport, data retention, tool write capabilities, output size, and auditing need to be evaluated. Content from MCP may also carry hint injection and should be considered untrusted data.

Skills and MCP solve different problems: MCP provides connections, and Skills provide the knowledge and processes on how to effectively use connections. When combining the two, permission control should be left at the tool layer, and business steps and acceptance should be left at the Skill layer.

Tool Levels Typical Permissions Default Controls
L0 read-only Search and read public information Automatic
L1 local revocable Write workspace, run tests Sandbox + log
L2 external writing Work orders, databases, email drafts Range limit + readback
L3 high impact Release, payment, deletion, permission change Strong approval + double review

The tool determines the scope of reality that the Agent can touch, and also determines the possible impact of errors.

6.5.1 Five types of tools and two design routes

Tools can be divided into five categories according to system functions: awareness tools read web pages, files, databases and multi-modal input; execution tools modify the environment; collaboration tools delegate or exchange structured messages; event trigger tools send timers, webhooks and external state changes into the runtime; user communication tools are responsible for clarification, approval, progress and delivery. The first two categories determine the basic action closed loop, and the last three categories determine whether the Agent can work asynchronously, long-term, and collaboratively.

There are two complementary lines of tool design. High risks, strong compliance, and high-frequency fixed actions are suitable for special tools, which use narrow parameters, server-side authentication, and clear receipts to reduce the degree of freedom; exploration, data conversion, and long-tail combinations are suitable for general-purpose executors and skills, and use code to combine multiple simple primitives into new capabilities. The choice is not based on “which one is more intelligent”, but whether the results can be verified, whether the actions can be limited, and whether failures can be recovered.

6.5.2 The tool contract must make the model parameters consistent with the real execution parameters

A usable tool contract should define name, purpose, input types, value ranges, default values, permissions, timeouts, idempotence, side effects, structured returns, and error codes. The Schema seen by the model must be consistent with the actual execution of the server; if the description is written as “read-only” but the implementation allows writing, or the parameter name is reinterpreted in the gateway, all upper-layer security judgments will be invalid.

After the number of tools increases, active discovery and progressive disclosure should be adopted: first let the Agent discover related servers or tools based on natural language requirements, and then load only the complete definitions of a small number of candidates. MCP unifies the discovery and calling interfaces, but does not automatically solve tool selection, version compatibility, identity authorization and prompt injection. These are still the joint responsibilities of Harness and the server.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

6.6 Hooks and deterministic control

Hooks are suitable for actions that must occur regardless of the model’s judgment, such as formatting after editing, blocking dangerous prefixes before commands, session end record summaries, additional review before permission requests, and re-injecting key states after context compression. Its value is to convert natural language suggestions into deterministic mechanisms.

Hooks themselves can also fail or be abused. Timeouts, exit codes, concurrency, and logs need to be handled; Hooks from plug-ins are equivalent to automatically executing code, and scripts, networks, and secret access should be reviewed. All complex business judgments should not be stuffed into Hooks, otherwise it will form an implicit workflow that is difficult to observe.

The mechanical actions that need to be guaranteed to occur are handed over to Hook, and the processes that need to be understood and made are handed over to Skills or AI agents.

6.7 Subagents, Agent Teams and Delegation Boundaries

Subagent is suitable for reading a large amount of material, performing independent testing or professional review, and returning the summary to the main session; Agent Team is suitable for multiple independent sessions to share tasks, communicate with each other and negotiate with each other. The former emphasizes context isolation, while the latter emphasizes collaborative autonomy.

Delegation instructions should include goals, inputs, tools, editable scope, output format, and acceptance. The main agent cannot delegate final responsibility altogether; it has to check the subresults for evidence, conflicts, and coverage, and decide whether to merge them.

The amount of concurrency should be determined by task separability, model cost, environment resources, and coalescing capabilities. Multiple agents jointly modify a set of strongly coupled files, often resulting in more rework than sequential execution.

Delegation isolates context and responsibility boundaries rather than duplicating more chat windows.

6.7.1 Multi-Agent classification axis: context and topology

Multi-Agent systems can be understood along two axes. In terms of context, the complete history can be shared, structured task status can be shared, or results can only be exchanged after complete isolation; in terms of topology, sequential pipelines, managers-workers, peer-to-peer negotiation, or decentralized networks can be used. The more sharing, the lower the handover costs but the higher the risk of contamination and leakage; the stronger the isolation, the clearer the specialization but requiring stricter interfaces.

The condition for multi-Agent to be truly valuable is to obtain a parallel environment, independent information sources, professional tools or mutual verification that is difficult for a single agent to obtain at the same time, rather than simply adding inference copies. If all actors read the same context, use the same model, and repeat the same path, the result may only amplify common blind spots.

6.7.2 Collaboration failure needs to be handled explicitly in the design phase

Common failures include concurrent write conflicts, error cascading, homogeneous conclusions, buck-passing, communication loops, and “understanding debt.” Understanding debt refers to the increasing difficulty for humans to explain how multiple agents form the final result; it accumulates as the level, message volume, and implicit state increase.

Controls include: setting owners or locks on shared resources; replacing free chat with structured task orders and product interfaces; limiting delegation depth, rounds, and budgets; letting key roles use differentiated information sources; requiring managers to take responsibility for verification of merged results; and retaining cancellations, timeouts, and manual takeovers. Multi-Agent optimizes information acquisition, execution parallelism and independent verification, and cannot replace clear task decomposition.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

6.8 Worktree, cloud environment and background operation

Worktree provides an independent working copy in the same Git project to resolve local parallel modification conflicts; the cloud environment provides a remote, configurable and sustainable execution space; background tasks focus on temporal persistence. The three can be combined, but the problems they solve are different.

The isolated environment must have the dependencies, configuration, and testing required to complete the task. Ignored files, secrets, and local services cannot exist by default; environmental differences should be managed through setup scripts and explicit variables. There should be a process for handover, review, branching, and cleanup after tasks are completed.

Parallel reliability comes from environment and file isolation first, and model concurrency second.

6.9 Observability: Logs, Traces, Costs and Audits

Observability includes, at a minimum, input versions, schedule changes, tool calls, permission requests, file differences, external receipts, test results, models and costs, human intervention, and final status. Without this information, failures cannot be located and successes cannot be reproduced.

Logs should be distinguished between debugging, auditing and business evidence. Debug logs can be detailed but have a retention period; audit records must be tamper-proof and associated with identities; business evidence should directly support delivery conclusions. Sensitive data requires desensitization and access control, and full context cannot be saved indefinitely for observability.

Agents without running evidence can only be demonstrated and cannot be governed.

7. Security and governance: Align capabilities, authority and responsibilities

Agent security is not an end-point audit after task completion, but a continuous control process throughout input, planning, execution, verification, release and review.

Untrusted content, identity and permissions, network access, secret data, extended supply chain, approval, auditing and rollback need to form an interconnected governance chain.

7.1 Threat model: who can input, what the agent can do, and who the results affect

Agent risks arise from the combination of data and permissions. The same model has lower risk in read-only public profile tasks, but completely different risks when connecting mailboxes, terminals, and production systems. The threat model should map out how external content enters the context, what tools the model can call, how credentials are provided, and where results are written.

In particular, distinguish between trusted instructions and untrusted content. User and organizational policies can authorize actions. Web pages, emails, issues, and documents only provide data and cannot be upgraded to authorization just because “please execute” appears in the content.

Before we can discuss agent security, we must first draw a clear picture of the data flow and permission flow.

7.2 Minimum permissions and capability classification

At the beginning of the task, only the necessary directories, commands, domain names and accounts are opened. Reading does not mean risk-free, and reading sensitive data may also lead to leakage; writing must be distinguished between drafts, test environments, and formal systems; outgoing, payment, deletion, and production changes must be controlled separately.

Permissions can be enlarged step by step with evidence, but cannot be permanently upgraded at the discretion of the agent. Short-term tasks use short-term credentials and temporary scope, and are revoked after completion; multiple projects use independent environments and identities to prevent an agent from crossing irrelevant boundaries.

Delegation should be minimized around the current task, not maximized around product functionality.

7.3 Sandbox, Approval, Rules and Rollback

Governing agents need to distinguish four concepts. Permissions determine what identity the agent has; the sandbox determines which files, processes, and networks can technically be accessed; approval determines who confirms when crossing boundaries; and audit records describe what has been done and what tools and data have been used. They are complementary but not substitutes for each other.

The principle of least privilege should be implemented into specific configurations: only open the directories, commands, domain names and accounts necessary for this task; close unnecessary networks by default; provide sensitive credentials in a short-term, limited-scope manner; set up manual confirmation for payment, publishing, deletion, external sending and production operations; retain diff, logs or system receipts for all important changes.

Bottom line of governance|Sandbox answers “what can be technically touched”, and approval answers “who will confirm when crossing the boundary”. Both must be designed simultaneously; relying solely on model recognition prompt injection or self-restraint is not enough.

The sandbox answers “what is technically accessible”, the approval answers “who confirms when crossing the boundary”, the rules allow, ask or prohibit specific commands or tool prefixes, and the rollback ensures recovery after an error occurs. The four together form a closed loop, and no one item can replace the others.

Low-risk baselines are typically workspace writes, restricted networks, and on-demand approvals. Full access plus never approval removes primary control and should only be used in clearly isolated, recoverable, and authorized environments. Automatic approval changes the reviewer and should not be misinterpreted as expanding the sandbox boundaries.

Stage Critical Controls Evidence
Input Source trust, injection isolation, sensitive classification Input tags
Planning Scope, authority, stopping conditions task specification
Execution Sandbox, Least Privilege, Approval Tool Log
Verification Independent inspection, readback, reconciliation Testing and acceptance
Release Manual approval, rollback preparation Approval record
Review Failure classification, indicators and improvements Evaluation report

Boundaries, approvals, rules, and rollbacks are four different control planes.

7.4 Credentials, Privacy and Data Lifecycle

Credentials should be provided on demand via the environment or secret manager to avoid writing prompts, project files, memories and logs. Use minimal scope, short-lived, revocable tokens, and let different tools have different identities. Configure the local and cloud environments separately, and full personal credentials cannot be copied.

Data governance also includes input sources, cross-border and compliance requirements, supplier retention policies, training usage, export and deletion. Automated memories, session histories, and tool logs may hold sensitive content and must have mechanisms for review, correction, retention, and cleanup.

The agent’s data boundaries cover context, tools, memories, logs, and providers, not just input boxes.

7.5 Scaling and Supply Chain Security

Extensions can bring directives, scripts, binaries, dependencies, network connections, and automatically triggered behaviors. The review should focus on sources, maintainers, versions, release records, permissions, data flows, installation scripts, and update mechanisms. What is installable on the market does not equal what the organization allows.

Internal extensions also require code review, testing, signing or verification, version locking, owners, and rollbacks. High-privilege environments should use allow lists and verify updates first in an isolated environment to avoid automatic upgrades that change behavior.

The agent extension ecosystem should be managed as a software supply chain, not as a collection of prompt materials.

7.6 Audit, Accountability and Incident Response

Each key action should be able to answer who initiated it, which agent and model was used, what data was read, what tool was called, what approval was obtained, what object was modified, and how to verify. Outbound delivery and production changes also need to be associated with the business person in charge.

Incident response plans should cover credential leaks, accidental deletions, unauthorized writes, malicious extensions, memory pollution, and out-of-control background tasks. Requires the ability to immediately stop tasks, revoke tokens, isolate environments, restore data, preserve evidence, and review control gaps.

Responsibility cannot be attributed to “AI”; organizations must maintain traceable chains of authorization and disposition processes.

7.7 Organizational Policies and Managed Configurations

Organizational policies should define available products and models, allowed data to connect to, default sandboxes and approvals, extension sources, background task permissions, log retention, and high-risk actions. Policies must be implemented through managed configuration and technical controls, not just training documents.

At the same time, an actionable exception process must be provided. While excessive rigidity pushes employees to bypass controls, clear mechanisms for application, review, time limits, and revocation make governance an efficiency infrastructure.

Good governance uses default configurations to reduce risk and exception processes to maintain business speed.

7.8 Governance maturity from pilot to production

Personal experiments focus on public or desensitized data, read-only and isolated environments; team pilots establish task templates, project rules, extended review and manual acceptance; controlled production adds identity, auditing, incident response and service responsibilities; the scale-up phase is unified through managed configuration, evaluation platform and asset catalog.

Each stage has exit conditions. If the task success rate is unstable, the failure is not visible, the extension is not maintained, or the permissions cannot be reclaimed, it should not enter a higher stage. Governance maturity needs to increase simultaneously with the degree of autonomy.

Stage Features Upgrade conditions
Explore Personal trial, manual step-by-step confirmation Task templates and basic logs
Controlled pilot Limited data/tools/team Stable evaluation and failure classification
Process integration Access to real systems, exception approval Identity, auditing, rollback
Scale operation Multi-team, multi-agent, continuous monitoring Responsibility system and portfolio governance

First establish controllable operation, then expand coverage; first prove stability, then reduce labor.

8. OpenClaw in-depth analysis: self-hosted multi-channel personal agent

OpenClaw combines message channels, Gateways, Agents, tools, memories and continuous operations into a long-term AI agent portal that can be controlled by individuals.

Its value lies not in providing another chat interface, but in enabling users to initiate tasks from their mobile phones or daily messaging platforms, and have an Agent in a self-hosted environment continue execution and return results. At the same time, always-on, remote triggering and host permissions also make it necessary to manage it as an infrastructure rather than an ordinary application.

8.1 Product positioning: multi-channel entrance for persistent personal agent

OpenClaw officially describes the product as a self-hosted gateway that connects AI agents across channels such as Discord, Google Chat, iMessage, Matrix, Microsoft Teams, Signal, Slack, Telegram, WhatsApp, Zalo, and more. A Gateway can serve multiple channel plug-ins at the same time and deliver messages to the corresponding Agent.

This positioning separates the model from the runtime. The model is responsible for understanding and reasoning, and OpenClaw is responsible for entry, session, routing, tool connection, status, and operation and maintenance. Users can choose different model providers and assign different Agents to different workspaces or senders.

Therefore, when evaluating OpenClaw, you can’t just ask about the quality of the answers, but also whether the Gateway is stable, whether the channel identity is reliable, whether the session can be isolated, how the background tasks are restored, whether the tool permissions are controllable, and whether the deployer can maintain it for a long time.

OpenClaw’s core product is a personally controllable Agent Gateway, not a new base model.

Data basis: OpenClaw official documents Overview, Agents, Capabilities, Gateway Security, retrieved as of 2026-08-10.

8.2 Core architecture: Channels—Gateway—Agent—Nodes

The basic link of OpenClaw can be summarized as Channels → Gateway → Agent. Channel plug-ins are responsible for receiving and sending messages. Gateway is the single source of truth for sessions, routes, and channel connections. Agents combine models and context to determine actions and invoke tools, Skills, or Plugins.

Gateway also connects CLI, Web Control UI, desktop and mobile Nodes. The Control UI provides chat, configuration, session, and node management; nodes expose specific device capabilities to the Gateway through pairing. The entire system is both a data plane and a control plane.

Report figure 3

Figure 8-1 OpenClaw uses Gateway to connect message channels, Agents, control interfaces and mobile nodes

Source: OpenClaw official document, Overview (retrieval date: 2026-08-10)

Layers Main responsibilities Key objects Governance focus
Entrance layer Receiving and returning messages Channel plug-ins, WebChat Sender and group allow lists
Control layer Sessions, routing, connections and state Gateway, Control UI Authentication, network exposure, logging and recovery
Agent layer Understand tasks and organize calls Agent, session, workspace Context, isolation and model configuration
Capability layer Execution actions and reuse processes Tools, Skills, Plugins Minimum permissions, sources and versions
Device layer Providing remote device capabilities Desktop and mobile Nodes Pairing, tokens, and execution approvals

The advantage of this structure is that channels and capabilities can be expanded independently, but the disadvantage is that the Gateway becomes a high-value single point. Configuration files, channel tokens, model keys, plugins, and logs are all centralized around it, and deployment requires backup, update, monitoring, and recovery solutions.

Understanding the control plane status of Gateway is the starting point for understanding OpenClaw’s capabilities and risks.

8.3 Channels, sessions and multi-agent routing

Multi-channel solves the problem of where users reach the Agent. Multi-session and multi-agent routing solve the problem of which trust boundary different inputs enter. Work accounts, personal accounts, home groups, and public communities should not share the same context, memory, and tool permissions by default.

OpenClaw can organize isolation sessions by agent, workspace, sender and other dimensions. A reasonable approach is to have separate Agents and working directories for different uses, and to set up allow lists and matching processes for private messages, groups, and channels. Facts that need to be shared across channels should be written explicitly rather than directly merging the entire history.

Multi-Agent routing can also separate research, home automation, engineering tasks, or operational notifications. However, routing labels are only selectors and cannot replace authentication; who can trigger high-authority tools is still determined by channel identity, Gateway permissions, and tool policies.

Multi-channels bring accessibility, and multi-session and multi-Agent can transform accessibility into controllability.

8.4 Tools, Skills, Plugins and Capability Extensions

OpenClaw divides extensions into different levels. Tools are structured actions that can be called by the model, such as files, terminals, web, browsers, messages, automation, and node operations; Skills provide on-demand loading work methods to Agent; Plugins can add tools, channels, model providers, Hooks, and other runtime code.

This layering helps to use the principle of minimal surface: one-time actions use existing Tools, stable processes are precipitated into Skills, and Plugins are only introduced when new runtime code or distribution is really needed. Not every need should be solved by installing a new extension.

Scaling is also a major supply chain risk. Skills may reference scripts and external dependencies, and Plugins run within the Gateway process. Teams should use source allow lists, pin precise versions, review unpacked content, isolate testing, and update regressions to avoid automatically treating community directories as trusted.

Expand the upper limit of ecological improvement capabilities and bring the security of the software supply chain into personal intelligence.

8.5 Memory, Workspace and Automation

Long-term operations require separation of the current session, stable workspace, and long-term facts. The session saves the task process, the workspace provides files, instructions, and tool environments, and the memory should only save information that is valuable and confirmed across sessions. Loading the entire history forever wastes context and amplifies false memories.

Cron, webhooks and background events enable OpenClaw to generate scheduled briefings, reminders, patrols or message forwarding. The key to automation is not whether it can be triggered, but whether the trigger source is trustworthy, whether the task is idempotent, whether failure is notified, whether retries are limited, and whether the results can be read back.

For long-term tasks, the minimum state required for the next run should be saved, stopping conditions and manual takeover points should be clear. Tasks involving external sending, file modification, or equipment control should be retained for approval or review before action.

The stronger the long-term state and background operation, the more observable, undoable and auditable it needs to be.

8.6 Control UI, CLI and mobile nodes

Control UI is the management portal in the browser for chat, configuration, sessions, and nodes; CLI is responsible for installation, onboarding, diagnostics, security auditing, and automation; desktop or mobile Nodes provide device-side capabilities through pairing. The three share the Gateway state, but are oriented to different operators and risks.

Nodes can expand scenarios such as camera, voice, Canvas or system execution, which also means that Gateway can remotely call real devices. Node pairing, token rotation, offline queues, command approval, and device removal must form a unified process.

Report figure 4

Figure 8-2: Control UI/mobile interactive interface shown in OpenClaw official document

Source: OpenClaw official document, Overview (retrieval date: 2026-08-10)

The control interface should not be directly exposed to the unprotected public network. Prefer remote access using a private network or controlled tunnel, and verify reverse proxy, authentication, and WebSocket configurations. The management entrance and the ordinary message entrance should use different permissions.

Nodes are not ordinary clients, but remote capability boundaries that Gateway can call.

8.7 Usage path: from single-channel read-only pilot to permanent operation

The current official fast path includes installing OpenClaw, running onboarding and starting the Gateway service, and then interacting through the dashboard or a messaging channel. Commands and platform requirements change rapidly, and the actual deployment should be based on the official documents and release notes at that time.

A more prudent approach to adoption is divided into four steps. The first step is to use a separate system account, a separate directory, and a channel to only connect low-risk models with read-only tools; the second step is to establish sender allow lists, session isolation, and logs; the third step is to enable a small number of vetted Skills, memories, or cron; and the fourth step is to evaluate write operations, nodes, and more channels.

Each step must be completed with real tasks to record quality, manual intervention, continuous operation, fault recovery and safety incidents. Verify backups, stop services, revoke tokens, and restore configurations before scaling rather than waiting until the Gateway goes out of control and then designing emergency procedures.

OpenClaw should be enabled in stages by permissions and operating radius, rather than connecting all personal environments at once.

8.8 Security model, applicable scenarios and boundaries

The official OpenClaw security documentation explicitly adopts the personal assistant trust model: each Gateway corresponds to a trusted operator boundary. It is not an adversarial multi-tenant security boundary where multiple mutually distrustful users share the same Agent and host permissions.

If you have mixed trusts or different organizations, you should split the Gateway, credentials, and OS users or hosts first. Channels use private messages and group permission lists, tools follow least privileges, perform setup approvals, plug-ins have fixed sources and versions, and the network remains minimally exposed.

Official inspection methods such as openclaw security audit, –deep, –fix and –json are provided to discover open group policies, tool explosion radius, execution approval drift, network exposure and browser control risks. Audits are diagnostic tools and are not a substitute for an organization’s own threat model.

OpenClaw is suitable for personal assistants, cross-channel task portals, controlled home or work automation, and remote triggering of engineering agents; it is not suitable for direct use as a public high-privilege robot without isolation and dedicated governance.

OpenClaw’s value comes from persistent connectivity, and its main risk comes from persistent connectivity.

9. Hermes Agent in-depth analysis: learnable open personal agent

Hermes Agent emphasizes the accumulation of experience through persistent memory, Context Files and automatically generated or improved Skills, so that an open, multi-model Agent can form stronger personalization and programmatic reuse in long-term use.

Compared with OpenClaw’s Gateway-centric route, Hermes emphasizes learning loops, open tools, and multiple execution backends. It also covers message channels and ongoing tasks, but “self-improvement” does not mean that there is no need for supervision; the more memories, skills, and tools can change subsequent behavior, the more reviews, versions, and safety boundaries are needed.

9.1 Product positioning: open personal agent that can accumulate experience

Hermes Agent is open sourced by Nous Research and is officially described as a self-improving AI agent with a built-in learning loop: Create Skills from experience, improve during use, and write information worth retaining into cross-session memory. It’s not a coding copilot that only relies on an IDE, nor is it a chat shell centered around a single API.

It is important to understand this positioning accurately. The so-called improvements mainly occur at the context selection, memory, procedural Skills and tool orchestration layers. It does not mean that the model weights will be automatically trained locally, nor does it guarantee that every automatic write will improve the quality.

Report figure 5

Figure 9-1 CLI interface layout in Hermes Agent official documentation: status banner, conversation area and fixed input area

Source: Hermes Agent official documentation, CLI Interface (retrieval date: 2026-08-10)

As of August 10, 2026, the official product page and GitHub release label the current version as v0.20.0. This release continues to expand voice, quote, A2A, webhook, and desktop capabilities, and illustrates that the product surface is still changing at a rapid pace.

The core value of Hermes is to turn personal experience into reusable assets; the core risk is that wrong experiences may also be amplified in the long term.

Data basis: Hermes Agent official documentation, Nous Research product page and GitHub v0.20.0 release, retrieved as of 2026-08-10.

9.2 Running state: CLI, desktop, message gateway and remote environment

Hermes offers a CLI, desktop application, and messaging gateway accessible from platforms such as Telegram, Discord, Slack, WhatsApp, Signal, Email, and more. It can run on a PC, VPS, GPU cluster or remote execution backend and connect to multiple model providers.

Different interfaces are not independent products, but entrances to the same Agent state. Configuration, context, memory, skills, tools, and scheduled tasks all work together to determine behavior. Maintaining continuity across interfaces is valuable, but it is also necessary to avoid sharing borderless states of personal, work, and team identities.

Layer Main Responsibilities Represented Objects Main Risks
Interaction layer Unified multi-entry session CLI, Desktop, message gateway, Voice Identity obfuscation and context threading
Knowledge layer Saving facts, background and procedures Memory, Context Files, SOUL.md, Skills Accumulation of errors and leakage of secrets
Action layer Calling tools and external systems Tools, MCP, Browser, Code unauthorized access, side effects and supply chain
Collaboration layer Delegation and continuous operation Subagents, Cron, Webhooks, A2A Unattended and consolidated responsibilities
Execution layer Isolated running environment Local, Docker, SSH, Singularity, Modal Environment drift and boundary configuration

Open models and execution environments facilitate experimentation, cost control, and customization, but can also introduce model differences, dependency drift, and run reproduction issues. The team pilot should fix the version, model, tool set and backend, and then compare the task effects.

The openness of Hermes expands the scope of deployment and makes environment management a part of use.

9.3 Memory, Context Files and SOUL.md

Hermes separates long-term facts, project context, personalities and historical processes into different assets. Memory holds user, project, or preference information that remains valuable across sessions; Context Files provide a stable context for a specific working directory; SOUL.md describes the default personality and expression; and History Search is used to review past sessions when needed.

This layering avoids loading the entire history for each conversation. Stable rules are placed in reviewable files, factual memories are retrieved on demand, and temporary task processes remain in session. What really matters is not how much you can save, but whether you can retrieve the right facts at the right time.

Report figure 6

Figure 9-2 File division and capacity boundaries of Hermes Agent’s built-in persistent memory

Source: Hermes Agent official document, Persistent Memory (retrieval date: 2026-08-10)

Memory writes must allow viewing, correction, and deletion. Secrets, short-term state, unverified inferences, and data that may belong to another project should not enter long-term memory; team scenarios also need to preserve source, time, and owner.

The quality of memory depends on selection, verification and error correction, not the quantity saved.

9.4 Skills and built-in learning loops

Skills is Hermes’ procedural memory layer. Agents can generate Skills from successful experiences, or they can improve existing Skills during use, solidifying tool sequences, inspection steps, scripts, templates, and failure handling into methods that can be reused in the future.

Programmatic reuse can significantly reduce repeated exploration, but it can also turn accidental successes, dangerous commands, or outdated dependencies into long-term behavior. A high-quality skill should have clear trigger conditions, inputs, outputs, permissions, verification, owners, versions, and rollbacks.

Automatically created skills should first enter candidate or review status, be tested with representative tasks in an isolated environment, and then be promoted to default capabilities. If the memory or skill is corrected, a regression task should be used to verify that the error has truly disappeared.

Only when the learning cycle is combined with evaluation and version management can it become reliable reuse.

9.5 Tools, MCP, browsers and multi-modal capabilities

Hermes official documentation currently lists more than 60 built-in tools and covers tasks such as terminal, file, web search, browser, code execution, image and voice. Toolsets can be enabled on a per-scenario basis to avoid indiscriminately exposing all capabilities to the model.

MCP allows Hermes to connect to external tools and data sources. Each MCP server should use dedicated identities, narrow parameters, and minimal permissions; text from external systems is still untrusted input and cannot be treated as system commands just because the entry tool returns.

v0.20.0 enhances live voice, provenance citations, A2A v1.0, signed outbound webhooks and desktop artifacts. These capabilities expand interaction and collaboration, but still require individual verification of stability, data flow, and permissions when adopted by organizations.

Tool breadth determines what can be done, permissions and validation determine whether it should be done.

9.6 Subagents, message channels and scheduled tasks

Subagents from Hermes can undertake research, testing and data processing in independent sessions, terminals or scripts, reducing main context noise. The main agent is responsible for splitting targets, providing materials, setting tool boundaries, and validating returned results.

A messaging gateway lets users initiate tasks and receive results remotely from their daily platform, and natural language scheduling schedules reports, backups, and briefings. Delegation, messaging and Cron combine to form continuous work, but also connect identity, delivery and error recovery.

Unattended tasks should use a narrow toolset, limit the maximum run time and number of retries, and set clear notifications. When multiple Subagents operate on a shared directory, independent workspaces or clear read/write scopes should be used, and the final merge responsibility must be borne by the main task.

Delegation and scheduling improve throughput, but cannot replace task boundaries, evidence, and responsible persons.

9.7 Sandbox, Approval and Security Boundaries

Hermes supports local, Docker, SSH, Singularity, Modal and other execution backends. Different backends determine how file systems, processes, networks, GPUs, and secrets are exposed; backend selection should be based on task risk and reproducibility requirements, not just launch convenience.

Command approval, authorization, DM pairing and container isolation control different levels of risks respectively. The sandbox restricts the environment, allowing approval to retain human decision-making, channel authorization restricts who can initiate tasks, and secret management restricts what credentials can be obtained during execution.

For high-impact tasks, it is recommended to use dedicated accounts and isolated backends, default to read-only or restrict writing to the root directory, tighten outbound networking, and log tool calls and manual approvals. Scheduled tasks should also verify stop and resume to prevent background tasks from continuously retrying after failure.

The sandbox provides environmental boundaries and approvals provide decision boundaries, and both must be designed simultaneously.

9.8 Usage path, migration and selection suggestions

With Hermes, you can start with the CLI and read-only tools: fixed models, project directories and Context Files, establish a quality baseline with a set of repetitive tasks; then enable auditable memory, then test individual Skills, MCPs or Subagents; and finally connect to message channels, Cron and high-privilege execution.

The official migration path is provided to import settings, memories, skills, allowed lists, message configurations and some keys from OpenClaw, and supports dry-run. Migration should not mechanically copy all assets. Secrets, expired memories, and unvetted Skills should be excluded before permissions are revalidated.

If the core requirements are mature multi-channel gateways, session routing and device nodes, priority can be given to evaluating OpenClaw; if the core requirements are open tools, multi-execution backends, memory and skill learning loops, priority can be given to evaluating Hermes. Both require the deployer to undertake updates, scaling reviews, and security operations.

Hermes is suitable for users who are willing to manage long-term memory and open tools, but is not suitable for treating “self-improvement” as unsupervised.

10. Claude Code in-depth analysis

Claude Code embeds model capabilities into code libraries, terminals, IDEs, desktops, and browsers to form a continuous engineering closed loop of requirement understanding, code modification, real testing, difference review, and delivery.

Its value comes not only from generated code, but also from the reusable engineering system composed of CLAUDE.md, Skills, MCP, Hooks, Subagents, Agent Teams and plug-ins.

10.1 Product positioning and four types of user interfaces

Claude Code officially describes it as an agentic coding tool that can read code libraries, edit files, run commands, and integrate development tools. It covers terminals, IDEs, desktop applications and browsers; different interfaces share underlying engineering capabilities, but have different focuses on local files, cloud environments, parallel tasks and visual review.

Understanding Claude Code as a “code completion tool” would underestimate its value. Completion focuses on the next piece of code near the current file, while the engineering agent focuses on the complete life cycle of a target in the code base: understanding the requirements, locating the implementation, modifying multiple files, running real tools, continuing to fix based on failures, reviewing differences and preparing for delivery.

The “Claude Code Complete Tutorial” provided by the user shows the specific operation path in the Chinese environment, including context management, CLAUDE.md, Auto Memory, Skills, MCP, Subagents, Hooks and plug-ins. The report explains these paths in the official product architecture to avoid mistakenly writing an author’s personal thresholds or convenient practices into hard product rules.

As of the search date, Claude Code officially describes it as an agentic coding tool that can read code libraries, edit files, run commands, and integrate with development tools. It can be used in terminals, IDEs, desktops, and browsers. When choosing an interface, you should first consider where the code and dependencies are, whether local services are required, whether the task will run for a long time, and how the results will be reviewed.

The terminal is suitable for complete command line loops, the IDE is suitable for collaboration around the current file and symbols, the desktop is suitable for managing multiple projects and sessions, and the web is suitable for remote and background tasks. The differences between interfaces are not simple preferences, but differences in permissions, files, networks, and ongoing operating environments.

Choosing the Claude Code interface is essentially selecting the execution environment and control surface of the task.

Data basis: Claude Code Docs: Overview; user provided “Claude Code Complete Tutorial”

10.2 Engineering closed loop from problem to verifiable change

The most valuable thing about Claude Code that can form a team consensus is not a certain command, but a set of standard closed loops. The following takes “Fixing a cross-file login status bug” as an example.

  1. Clarify the phenomenon and scope: Provide error logs, reproduction steps, affected versions, and unchangeable behaviors.

Report figure 7

Figure 10-1 Claude Code’s agent closed loop: collect context, perform actions, verify results, and make corrections in a loop

Source: Claude Code official document, How Claude Code works (retrieval date: 2026-08-10)

  1. Explore the code base: locate entrances, status flows, related tests and historical implementations, and do not rush to edit.

  2. Form a plan: describe root cause assumptions, expected modification files, compatibility risks and verification methods.

  3. Implement minimal changes: Keep changes focused and avoid refactoring irrelevant code.

  4. Run verification: Run targeted tests first, then run broader checks of affected modules.

  5. Check the diff: Make sure there are no secrets, debug code, extraneous formatting changes, and missing files.

  6. Prepare for delivery: Summarize root causes, modifications, validations, remaining risks, create commit or PR draft.

The key responsibility of people in a closed loop is to identify scope and trade-offs. The agent can provide multiple implementation solutions, but interface compatibility, migration rhythm, performance budget and product behavior often require business or architectural judgment. High-quality collaboration does not mean having people write every line of code by hand, but rather letting people place decisions at high-leverage nodes.

The team should fix the closed loop as a common operating language: first clarify the phenomenon, scope and immutable behavior, then locate the code and tests, form root cause hypotheses and plans, implement minimal modifications, run targeted and extended verification, check diff, and finally summarize the basis, evidence and remaining risks.

Without real validation, Claude Code may still generate code that looks reasonable but is incompatible. Test failures, missing dependencies, and environment differences should be presented directly; at the end of the task, not only the results should be given, but also the verifications that have not been run and the trade-offs that require human judgment should be listed.

Stages Agent Actions Human Control Points Verifiable Evidence
Understand Read repository, rules, issues Confirm target scope Plan/reference files
Modify Edit code and configuration High-impact decisions diff
Verify Run tests and checks Determine exceptions Test logs
Review Explain changes and risks Approve merge Review records
Handover Organizing commits/PRs Deciding to publish Commit and rollback instructions

The delivery unit of Claude Code should be “changes with proof of verification”, not code snippets.

10.3 How to issue high-quality engineering tasks

Engineering task input should include goals, phenomena, boundaries, constraints, and completion criteria. Don’t just write “Fix login bug”, you can write: “Reproduce the problem that the page still displays logged in after logging out; locate the root cause and make minimal repairs; do not change the login API; supplement regression testing; run auth module test and lint; finally give a diff summary and unresolved risks.”

Context can be composed of a variety of materials: local files, images, terminal errors, log fragments, Issue descriptions, and multi-line requirements. When providing materials, explain their status, such as “logs are evidence of the production environment”, “screenshots are used to reproduce visual problems”, “design documents are only for reference, existing APIs must not be modified”.

Practical suggestions | First ask Claude Code to “read-only explore and give a plan”, and then allow writing after confirming the range. For large tasks, write the completion criteria of each milestone into the same session to avoid the results only staying in code generation.

High-quality tasks should describe how the problem is reproduced, the scope of the impact, existing logs, interfaces that cannot be changed, directories that are allowed to be modified, test commands and final delivery. Requires read-only exploration and planning for large tasks first, which can significantly reduce the agent’s extensive revision of erroneous assumptions.

The status of pictures, logs, issues, and design documents must be clearly stated to prevent the system from treating the reference solution as a requirement that must be implemented. Separate approval points should be set when it comes to new dependencies, database migrations, public APIs, and production configurations.

Level Example writing
Goal Fix the problem that the import process crashes under an empty header
Scope Only modify the importer and related tests; do not change the public API
Constraints Comply with CLAUDE.md; do not access production data
Verification Reproduction failure; unit testing; complete testing; description of compatibility
Stop Ask first if you need to change the data model or have insufficient permissions

The closer the input is to the project brief, the closer the output is to merging changes.

10.4 Context windows, compression and session continuation

The current session context is Claude Code’s working memory and contains targets, open or read files, tool results, logs, and conversation history. Context is not infinite, and excessive log and search output can dilute the information that really matters. You can understand the composition through interfaces such as /context, and compress the history through staged summary or /compact.

Compression is not about simply “deleting old messages” but about refining key facts, decisions and progress before continuing. In practice, it should be compressed at natural milestones: the root cause has been confirmed, the solution has been decided, and the first phase of verification is completed. In the tutorial, the author may actively compress at a certain occupancy ratio. This can be regarded as a personal habit, but it should not be written as a unified threshold for the product.

When the task is completely redirected, the current context should be cleared to avoid interference with old goals; when the task needs to be continued, the historical session should be restored. The stage summary should save at least: current goals, modified files, verification results, unfinished items, rejected solutions and next steps.

Long logs, repeated searches, and irrelevant files increase contextual pressure. Natural milestones include root cause identification, solution decision, phase verification completion, and task transition. Forming summaries at these locations is more reliable than waiting until the context is close to its limits and then passively compressing it.

The continuation summary should save the goals, modified files, key decisions, test results, incomplete and next steps. The specific occupancy ratio in the tutorial can be regarded as a personal habit, but should not be used as a unified threshold for the product; the compression timing should be determined based on the task structure and information quality.

The goal of compression is to preserve task state, not simply reduce word count.

10.5 CLAUDE.md, Rules and Persistent Project Directives

CLAUDE.md is best suited for holding engineering facts that are stable across tasks, such as build and test commands, directory responsibilities, architectural constraints, dependency policies, interfaces that prohibit modification, and delivery requirements. Temporary requirements, one-time debugging processes, and easily expired states should not be accumulated in the long term.

Large code bases can maintain rules hierarchically by directory: the root directory describes global constraints, and subdirectories supplement local conventions. More specific rules should serve to clarify boundaries and not allow the agent to guess priorities through duplication and conflict. The team needs to regularly clean up expired rules.

Project instructions should be kept as short and executable as possible. Instead of writing a slogan like “maintain high quality”, it is better to clarify the test commands, formatting tools, directories that allow modification and compatibility requirements. Rule changes should also be reviewed like code and verified with representative tasks.

CLAUDE.md is used to save project facts and work engagements that should be known for each session. The official document distinguishes between organizational policies, user instructions, project instructions, and local instructions. Project-level files are suitable for inclusion in version control, recording build and test commands, directory structures, architectural constraints, coding styles, and review checklists; local files are suitable for saving preferences that are related to individual machines but should not be shared.

A useful CLAUDE.md should be specific, concise, and conflict-free. Writing “Modify JavaScript and run npm test” is more executable than “Test carefully”; writing “API handlers are located in src/api/handlers/” is more helpful than “Keep the structure clear”. Files that are too long will occupy context and reduce compliance. Multi-step operations should be migrated to Skills. Specific directory rules can be configured using path ranges.

CLAUDE.md is the context, not the enforcer. If an action must be prohibited regardless of the model’s judgment, it should be intercepted through permission rules or PreToolUse Hook. The team needs to regularly clean up outdated instructions to avoid conflicting files in the root directory and subdirectories.

CLAUDE.md is suitable for core project facts, build commands, and rules that always apply; path-scoped Rules are suitable for specific languages, directories, or components; longer references and processes should be moved to Skills. The official extension guide recommends keeping CLAUDE.md focused to avoid everything going into context every time.

Teams need to treat directives as code assets: review changes, clean up obsolete content, resolve conflicts, and verify compliance with real tasks. Security hard constraints still require hooks, permissions, or CIs and should not just be declared in natural language.

CLAUDE.md is a summary of the project constitution, not a knowledge repository or enforcer.

Data basis: Claude Code Docs: Features Overview; Memory / CLAUDE.md

10.6 Auto Memory, conversation history and knowledge accumulation

Auto Memory is automatically recorded by Claude based on corrections, preferences, and work processes, and is suitable for saving build commands, debugging clues, and recurring experiences. It is complementary to CLAUDE.md: the former is a study note written by Claude, and the latter is a project agreement that is clearly maintained by humans. Both enter the context of each session.

The benefit of automatic memory is that it reduces repeated interpretations, but the risk is that erroneous experiences may be retained for a long time. Therefore, users should be able to view, edit, and delete memories; secrets should not be placed in memories; and auditable project directives or permission mechanisms should still be used for security requirements and team norms that must be followed.

Auto Memory is good for saving recurring build threads, preferences, and project experiences, but automatically written content may be out of date or wrong. Users need to be able to review and correct, secrets should not be allowed to slip into memory. For the team bottom line, reviewable rules still need to be written.

Knowledge precipitation should be selected: one-time debugging details remain in the session, recurring experiences enter the memory, stable rules enter CLAUDE.md, multi-step methods enter Skill, and mechanical inspections enter Hook. Layering can reduce contextual noise.

Putting experiences into the right tier is more important than simply increasing long-term memory.

10.7 Skills: Load knowledge and workflow on demand

Skills are suitable for hosting methods that occur repeatedly but do not necessarily occupy the main context each time, such as release checks, database migration reviews, failure recovery, and dependency upgrades. Description files define trigger conditions and steps, and scripts, templates, and reference materials are loaded as on-demand resources.

A high-quality skill should clearly describe applicable scenarios, inputs, outputs, preconditions, allowed tools, verification methods, and failure handling. A trigger description that is too broad will cause miscalls, and a trigger description that is too narrow will be difficult to reuse; both need to be calibrated through real tasks.

Skills should be tested in a clean environment before release, and the responsible person, version, dependencies, and rollback methods should be recorded. Teams also need to check scripts and external resources within them to prevent skill packs from becoming hidden entry points to bypass project rules or introduce supply chain risks.

Skills use SKILL.md to encapsulate instructions, resources and optional scripts. Claude can be automatically loaded according to the description, or can be called directly by the user via /skill-name. Unlike CLAUDE.md, the Skill body only enters context when it is actually used, making it suitable for longer checklists, release steps, review processes and domain knowledge.

A good Skill should explain when to use it, what input it requires, what steps it takes, what output it produces, how it is verified, and when it stops. Support files can include templates, samples, scripts, and reference materials. Personal skills are suitable for reuse across projects, and project skills are suitable for sharing with the repository. When mature, they can be loaded into plug-ins for distribution.

For example, the “review uncommitted changes” skill can first dynamically read git diff and then output risks from the five dimensions of functional correctness, testing, secrets, performance and compatibility. Teams can build review sets with real PRs and continuously iterate on trigger descriptions and checklists, rather than judging quality based on how they feel after one use.

Claude Code Skills can be used as reference knowledge or callable processes. By default, the complete content is only loaded during use. The official extension guide considers it the most flexible extension: it can be called by user command, selected by Claude based on description, and can be run in an isolated context.

The team should prioritize converting repeatedly copied processes and long references into Skills to avoid CLAUDE.md expansion. Skill descriptions must be able to distinguish adjacent scenarios, steps must include verification and stopping, and scripts must be reviewed.

Skills allow project knowledge to enter context on demand, and also allow repetitive work to have versions and evaluation objects.

Data basis: Claude Code Docs: Skills; Features Overview

10.8 MCP: Connect Issue, Monitoring, Database and Design Systems

MCP exposes external system capabilities as structured tools, but successful connection does not mean unlimited authorization. Each tool should have narrow parameters, clear side effects, stable error returns, and readable results that enable the agent to verify the true state.

Connections to issues, monitoring, and databases should use dedicated identities with minimal permissions, and write operations should be restricted by default or subject to approval. Text from external systems is still untrusted input and cannot be treated as system commands just because it is returned through MCP.

MCP allows Claude Code to connect issue tracking, monitoring, databases, design, messaging and custom APIs. When teams often copy Jira, Sentry, Figma or Slack content into conversations, MCP can turn “copy and paste” into an authorizable and callable tool interface.

After connecting the tool, tasks can be closed-looped across systems: read Jira Issues, view Sentry errors, modify code, run tests, create PRs on GitHub, and generate communication drafts to be manually confirmed. MCP also expands the attack surface because the server may return external untrusted content and may also have write capabilities.

Before using MCP, you should confirm the server source, transmission method, OAuth scope, available tools, output upper limit and audit method. Set tools such as database writing, message sending, and production operations to ask or prohibit each time; set range filtering for tools with large output to prevent the context from being overwhelmed by data.

MCP can reduce copy and paste, allowing Claude Code to directly read Issues, Sentry, databases, designs and messaging systems. A real closed loop may start with a bug ticket, read monitoring evidence, modify the code, run tests, and then generate PR and communication drafts.

Review server origin, OAuth scope, tool write capabilities, output size, and logs before connecting. The content returned by the external system is not trustworthy, and production writing and external sending should be subject to approval. Skills can supplement the domain knowledge of how to use MCP, but they cannot replace the permissions of the MCP layer.

MCP expands the context and radius of action and also brings external system risks into the engineering session.

10.9 Subagents and Agent Teams

Subagent is suitable for well-bounded exploration, testing, or review tasks. The main session should provide the goals, necessary materials, allowed tools, and desired outputs, while the sub-agent works in an isolated context and returns evidence, avoiding bringing all the process noise back to the main thread.

Agent Teams consists of multiple independent sessions sharing tasks and messages, which is suitable for complex work that can truly be done in parallel and requires mutual discussion. It’s still a collaboration method that needs to be carefully evaluated; if tasks cannot be clearly split, the communication, conflict, and merge costs may outweigh the speed gains.

Subagent is a professional agent that performs specific side tasks in an independent context. It’s suitable for jobs that generate large amounts of search results, logs, or file content, with only a summary returned to the main session. Each Subagent can be configured with specialized system prompts, tools, permissions, models and persistent memory.

Typical usage includes Explore to locate code, Test to supplement and run tests, and Security Reviewer to check risks. Only tasks with clear output boundaries are suitable for delegation; multiple Subagents editing strongly coupled files at the same time will increase conflicts. If multiple full sessions need to be parallel, coordinated, or long-running, consider background Agents or Agent Teams instead of cramming all the parallelism into a single session.

Cost control is equally important. Faster, cheaper models are available for exploration, and stronger models are used for critical architecture and final review. Subagents should be restricted to tools and directories and should not inherit by default more permissions than are required for the task.

Subagents run in an independent context and return summaries, suitable for exploration, testing and review; Agent Teams consists of multiple independent Claude Code sessions sharing tasks and communicating directly, suitable for competing hypotheses and complex collaboration. The official documentation also indicates that Agent Teams is experimental and is turned off by default. Actual deployment should verify the current limitations.

The main session retains global goals and merge responsibilities. Subroles should define tools, directories, and outputs to prevent multiple agents from modifying strongly coupled files at the same time. Parallel benefits need to be measured in terms of actual cycles, costs and rework.

Use Subagent to isolate the context first, and only consider Agent Team when negotiation between sessions is required.

Data basis: Claude Code Docs: Subagents; Agent Teams; Features Overview

10.10 Hooks: Deterministic Automation and Security Doors

Hooks are suitable for checks that must be performed reliably, such as command blocking, formatting, testing, logging, and notifications. They are triggered by life cycle events and do not rely on model ad hoc judgments, so they can serve as deterministic safety gates in the agent process.

Hook’s failure strategy needs to be clear: when a blocking check fails, subsequent actions should be stopped and the reason returned, while a prompt check should record the problem but allow continuation. Scripts must set timeouts, output limits, and diagnosable errors to avoid becoming stuck in the task.

Teams should test and review Hooks alongside normal project scripts. Hooks involving file modifications, network requests, or secrets require higher-privilege review, and the triggering timing should be ensured so that repeated executions do not produce side effects.

Hooks are commands, prompts, agents or HTTP actions that are automatically run at specific nodes in the Claude Code life cycle. They provide deterministic controls: automatic formatting after editing, running lint and tests before committing, preventing modification of protected files, re-injecting critical information after context compression, and sending notifications when tasks are completed.

Hooks are suitable for hard constraints and mechanical actions, but are not suitable for carrying complex natural language judgments. A Hook must handle timeouts, exit codes, and failure messages; the script itself needs to be included in version control and code review. Hooks from third-party plug-ins are equivalent to automatically executed code and should be reviewed before installation.

The official extension guide clearly distinguishes Hook from Skill: Hook is bound to be triggered when matching events, and is suitable for lint, blocking dangerous commands, logs and notifications; Skill is explained by Claude and is suitable for processes that require reasoning and knowledge. PreToolUse can turn “don’t read secrets” into technical blocks.

Hook output may enter the context, and the script may access files and networks. Output, timeout and failure modes must be controlled during design. Before installing third-party Hooks, it will be reviewed as automatically executing code.

The mechanical control that must be guaranteed is written as Hook, not just as prompt.

Data basis: Claude Code Docs: Hooks; Features Overview

10.11 Plugins and Marketplace: Team Distribution Layer

Plug-ins can package Skills, Agents, Hooks, MCPs, and other components into an installable, versionable package. Standalone .claude/configuration is suitable for personal or single-project experiments; plug-ins are more suitable when capabilities need to be reused across projects, shared by teams, version updated, or distributed through the Marketplace.

Before installing a plug-in, you should check what commands, Agents, Skills, Hooks, MCP/LSP servers, context costs, and update times it contains. The official Marketplace provides a curated directory, but any extension may bring instructions, scripts, dependencies and network access. “On the market” cannot be understood as being suitable for all environments of the organization.

The mature path is usually: first create a Skill or Hook in the project and use real tasks to verify it; then combine related capabilities into plug-ins; and finally establish versions, change records, responsible persons, rollback methods, and allowed installation scope.

Plugin packages multiple extensions into installable units, suitable for distribution across repositories, teams, and organizations. Namespaces can reduce skill name conflicts, and Marketplace provides discovery and update paths. The mature process usually first verifies a single Skill or Hook within the project, and then combines it into a plug-in.

The team should establish allowed sources, versions, owners, change records, permission descriptions, and rollbacks for the plugin. Market presence does not equate to risk assessment by the organization; in particular, automatic hooks, MCP servers, and installation dependencies should be checked.

Plug-ins are software products and require release engineering and supply chain governance.

10.12 Permissions, Security and Trusted Execution

Claude Code runs on a permissions basis by default. Reading is generally lower risk, editing, command execution, and external tools require more explicit authorization; sandboxing can limit the file system and network scope of Bash commands. The goal of security is not to make the agent never make mistakes, but to limit mistakes to recoverable and auditable areas.

Tip injection may come from issues, web pages, documents, code comments, emails, or MCP returns. You cannot rely solely on models to identify attacks. Treat external content as untrusted input, restrict credentials and networks, review high-impact commands, verify critical file changes, and use VMs or isolated environments to run third-party scripts when necessary.

Teams also have to deal with supply chain issues when using it: Skills, Plugins, Hooks, and MCP servers may execute code or access data. Establishing mechanisms for allowing sources, version locking, review, and updates is more reliable than simply training users to “click carefully.”

Claude Code can read code, execute commands and connect to external systems. The risk comes from the combination of untrusted content and high-privilege tools. Issues, web pages, code comments and MCP results may induce the system to overstep its authority and cannot rely solely on model self-identification.

Security baselines include read-before-write, minimal directories and commands, restricted networks, covert isolation, high-impact action confirmation, running third-party scripts in isolation, extended source review, and diff and test evidence. Permissions should match the task stage rather than authorizing the entire machine at once.

The closer the capabilities are to the real development environment, the more technical boundaries must be used to protect human intentions.

Data basis: Claude Code Docs: Security

10.13 The team adopts the route and asset system

To transform Claude Code from a personal productivity tool into a sustainable engineering capability, the team first needs to build code base baselines, task baselines, and extension baselines separately. The three types of baselines respectively answer “what the system should comply with”, “how to accept the delivery” and “which capabilities can be called repeatedly”.

The code base baseline should include CLAUDE.md, build and test commands, directory boundaries, dependency policies, and sensitive information rules; the task baseline should include representative tasks such as defect fixes, test supplements, document updates, and dependency upgrades, and retain success and failure samples.

Skills, Hooks, MCPs, Subagents, and plugins are part of the extended baseline. They need to have clear ownership, sources, versions, permissions, testing and rollback methods to avoid personal scripts evolving into the team’s critical path without review.

The Claude Code team pilot can start with a code base and two types of tasks: fixing small bugs, adding tests, or updating documentation. First create the project CLAUDE.md and basic verification commands, requiring all deliveries to contain diff summaries and test evidence. After two to four weeks, the high-frequency processes will be made into Skills, the necessary checks will be made into Hooks, and the external system will be connected through the controlled MCP.

  • Before starting: Confirm the repository status, task scope, allowed directory modifications, dependency installation rules and prohibited items.

  • When exploring: read first and then write, record root cause hypotheses, and do not regard the first solution as a conclusion.

  • When modifying: keep the diff to a minimum, do not modify irrelevant files, and do not hide failures.

  • When validating: run targeted tests, affected module checks, formatting and static analysis.

  • Upon delivery: Description of modifications, basis, verification, residual risks and content requiring human judgment.

  • When expanding: Third-party Skills, Plugins, Hooks, and MCP first review the sources, scripts, permissions, and update mechanisms.

In the first stage, select one or two repositories and small tasks, improve CLAUDE.md, build tests and delivery formats; in the second stage, make repetitive processes into Skills and necessary checks into Hooks; in the third stage, connect controlled MCP and professional Subagents; in the fourth stage, plug-ins and parallel teams will be promoted.

The asset catalog should record rules, Skills, Hooks, MCP, plug-ins, responsible persons, versions and evaluation results. Extensions without an accountable person will become obsolete and eventually become a hidden risk.

Claude Code relies on reusable engineering assets to scale, rather than everyone figuring it out on their own.

10.14 Case: Cross-file login defect repair

Before starting the case, a baseline should be established: reproduce the problem of still displaying the login status after exiting without modifying the code, and save the failed steps, console output and related test results. Only if the baseline is stable will there be comparable evidence for subsequent repairs.

The exploration phase can check cache invalidation logic, routing guards, and authentication status synchronization in parallel, but the modification phase should return to a single main line, giving priority to solutions with the smallest impact and that can be covered by automated tests. Parallel exploration does not mean parallel writing to the same set of files.

Verification needs to start with directly relevant unit tests and then extend to scenarios such as cross-tab pages, refreshes, network interruptions, and mobile terminals. If the test exposes problems with the data model or public interface, automatic modifications should be suspended, the evidence should be compiled, and the architectural choices should be left to the maintainers to decide.

The deliverable should not only include code diffs, but also include reproduction methods, root cause determination, modification scope, executed tests, risks that are still not covered, and recommended rollback paths. The reviewer should be able to understand the chain of evidence without replaying the entire session.

If the fix relies on new browser behavior, third-party authentication services, or unconfirmed product rules, Claude Code should clearly mark these as external assumptions. The system can continue to prepare scenarios and tests, but unconfirmed assumptions should not be written as established facts.

The task requires reproducing the problem that the page still displays the login status after logging out, without changing the authentication API, supplementing the regression test, running the auth module test and lint, and giving a diff summary. The first round of read-only exploration locates the status cache, routing guards and related tests to form two root cause hypotheses; modifications will be made after confirming the compatibility requirements.

During implementation, the main session modifies the cache invalidation logic, tests Subagent to supplement exit and cross-tab use cases, and PostToolUse Hook runs formatting and local lint. The test failure revealed that the analog clock was not restored, and the system corrected the test fixture and re-verified. The final delivery lists the root cause, three modifications, test commands, uncovered mobile risks and rollback methods.

The case shows that the most valuable thing is not to generate the correct patch once, but that the agent can converge through real failures and focus human judgment on interface behavior and risk trade-offs.

The engineering closed loop wraps the uncertainty of the model in an observable, correctable, and reviewable process.

11. Codex in-depth analysis

Codex organizes engineering work through CLI, IDE, desktop applications, work trees and cloud tasks, enabling local real-time collaboration, isolated parallel execution and background long tasks to be connected in the same system.

Understanding Codex requires looking at project rules, memory, plans, work trees, sub-agents, extension mechanisms, sandboxes and approvals at the same time, rather than just looking at it as a single terminal tool.

11.1 Product Positioning: Organizing Engineering Work Between Projects, Tools, and the Cloud

Codex is OpenAI’s engineering agent for software development. It can understand code bases, edit files, run local tools, review changes, and handle long tasks in desktop applications, CLIs, IDEs, and cloud environments. The current product experience is integrating with ChatGPT desktop, web, and Work capabilities, but Codex remains centered around code libraries, development tools, and verifiable changes.

The “Codex Complete Solution” provided by users emphasizes the “front-end/back-end” relationship between Local and Worktree, context and three types of persistent information, large-scale project plans, Skills/CLI/plug-ins/MCP, and automated tasks. This report retains these easy-to-understand Chinese operating frameworks, while using official documents to distinguish environment boundaries, instructions and memories, sandboxes and approvals.

Report figure 8

Figure 11-1 The official product release page of Codex application

Source: OpenAI, Introducing the Codex app (Retrieval date: 2026-08-10)

Codex understands code bases, edits files, runs tools, reviews changes and handles long tasks on-premises and in the cloud. Desktop applications place more emphasis on projects, multiple chats, Worktrees, Handoffs, and background work; CLI and IDE are close to the existing development cycle; Cloud provides remote isolation environments and integration portals.

The “Codex Complete Solution” provided by users uses “front-end Local, back-end Worktree, and remote Cloud” to explain environmental relationships, which is suitable for operational understanding; the report also calibrates current mechanisms such as AGENTS.md, Subagents, Worktrees, sandboxes, and approvals according to official documents.

The core of Codex is to organize engineering goals, project rules, execution environment and verification evidence into the same task.

Data basis: OpenAI Codex official document; users provide “Codex Complete Solution”

11.2 Local, Worktree and Cloud: How to choose between the three types of environments

In desktop applications, Codex tasks can run in Local, Worktree or Cloud environments. Local directly operates the current project directory, which is suitable for rapid alternation between humans and agents, tasks that require local debugging or rely on the current machine status; Worktree creates an isolated Git working copy on the same computer, which is suitable for multiple tasks in parallel without interfering with the main workspace; Cloud runs in a configured remote environment, suitable for long background tasks and multiple independent attempts.

The tutorial uses “front desk and back desk” to explain Local and Worktree are very intuitive: Local is the front desk that people are operating, and Worktree is the background that does not interrupt the current work. But Worktree is not in the cloud; both Local and Worktree are on the local machine. Cloud is an independent remote environment.

Local is suitable for tasks that depend on the current machine state, rapid human-agent iteration, and local debugging; Worktree is suitable for parallel tasks in the same repository without directly interfering with the main workspace; Cloud is suitable for independently configured, long-running, remotely delegated work. Local and Worktree run on the local machine, while Cloud provides remote execution.

Environment selection checks for dependencies, secrets, networks, ignored files, services, and validation tools. Data and permissions cannot be ignored just because a task is running in a standalone environment, nor can you assume that locally available state will automatically appear in Worktree or Cloud.

Form Suitable for the task Environmental characteristics Collaboration methods
CLI Quick modification of current repository Local terminal Instant chat
IDE Delegate while coding Editor context Partial review
Desktop application Parallel tasks and work trees Isolation checkout Task management and handover
Cloud tasks Long-term, background, parallelizable Isolated cloud environment Asynchronous recycling results

Choose the right environment first, then choose a model and how to work.

11.3 CLI, IDE, desktop and cloud control plane

Codex CLI is suitable for focused loops in the terminal: launch in a repository directory, explore the code, plan changes, edit files, run local tools, and review commands and diffs in the same session. Non-interactive methods such as codex exec can embed scripts and CI, but clear constraints must be set for failure, output format, and permissions.

IDE extensions are suitable for local collaboration around currently open files, selections, and symbols to reduce switching costs; desktop applications are more suitable for managing multiple tasks across projects, reviewing results, and arranging Worktree and Scheduled tasks; Cloud provides an isolation environment for long tasks, which can be initiated from the Web, GitHub, Linear, or Slack. After completion, the summary and diff are reviewed and then merged.

Multiple interfaces are not duplicate products, but different control surfaces for the same engineering effort. A common path is: discover the problem and clarify the local context in the IDE, delegate the implementation in Worktree on the desktop, do local reproduction or fine-tuning in the CLI, and finally review diffs and PRs on the desktop or GitHub.

CLI is suitable for command line and scripted project loops, IDE is suitable for current files and symbols, desktop is suitable for cross-project management and parallel tasks, and Cloud is suitable for background execution and external triggering. A task can be handed over between different control planes, but the goals, environment, and verification status should remain consistent.

The common path is to clarify local issues in the IDE, put the implementation into Worktree on the desktop, reproduce and refine it locally on the CLI, and finally review the diff on the desktop or GitHub. Interface switching should serve the evidence and environment and should not cause context rupture.

Multiple control surfaces are not duplicate functions, but entrances to engineering tasks at different stages.

11.4 Codex’s standard engineering closed loop

Codex should also have “verifiable changes” rather than “generated code” as the delivery goal. The following is a recommended closed loop.

  1. Write the goal, scope, non-modifiable items, verification commands and stopping conditions at the beginning of the task.

  2. Check AGENTS.md, Git status, project structure and existing tests to form read-only exploration results.

  3. For complex tasks, enter the plan first, clarify milestones, dependencies and acceptance, and then start writing.

  4. Select Local, Worktree or Cloud to ensure that the execution environment is consistent with the required tools and data.

  5. Implement minimal changes, run targeted verifications in a timely manner, and make corrections based on real output.

  6. Check diff, testing, static analysis, generated files and dependency changes to avoid irrelevant modifications.

  7. Develop reviewable deliverables: summary, validation evidence, risks, outstanding items, and consolidation recommendations.

If the task changes its goal midway, the plan should be explicitly reset or a new thread should be started; if it is just continuing the same problem, stay on the same thread to take advantage of the existing context. The key to engineering collaboration is not continuous chat, but consistency in task status, environment, and verification evidence.

Before starting work in Codex, project rules and Git status should be read. Complex tasks should be planned first, and then implemented after selecting Local, Worktree or Cloud. Run real tests and tools during the process, revise based on output; provide diff, validation, outstanding and risk upon delivery.

If the goal changes completely during the task, a new task should be started or the plan should be reset; the continuation of the same problem should remain in the same task and use the existing context. Handoff changes the running position and should not change the completion criteria.

Stages Agent Actions Human Control Points Verifiable Evidence
Understand Read repository, rules, issues Confirm target scope Plan/reference files
Modify Edit code and configuration High-impact decisions diff
Verify Run tests and checks Determine exceptions Test logs
Review Explain changes and risks Approve merge Review records
Handover Organizing commits/PRs Deciding to publish Commit and rollback instructions

The consistency of task status, execution environment and verification evidence is the core of the Codex closed loop.

11.5 AGENTS.md: Command chain of global and project rules

Codex discovers project directives along the directory hierarchy: global configuration provides common constraints, the project root directory defines repository rules, and deeper directories can supplement local requirements; more specific directives have higher priority in the event of conflicts. AGENTS.unauthorized access.md can be used to unauthorized access explicitly.

The current official instructions also give a default command chain size limit, so AGENTS.md should not become an infinitely growing knowledge repository. Build commands, directory boundaries, validation requirements, and security rules are suitable for writing; dynamic progress, long-form background, and one-time task material should be kept in the task context or project documentation.

The team should include AGENTS.md in code review: adding rules should explain the problem to be solved, deleting rules should confirm that there are no dependencies, and directory-level rules should be verified by the real tasks of the corresponding module. The rules themselves also require versions, owners, and failure cleanup mechanisms.

Codex reads AGENTS.md before starting work. The global scope is located in the Codex home directory, which is suitable for general personal preferences; the project scope is discovered layer by layer from the project root directory to the current working directory, and the files closer to the current directory are more specific. AGENTS.unauthorized access.md can overwrite basic files at the same level and is used for special directories or temporary rules.

The project-level AGENTS.md should document the repository structure, build and test commands, dependency management, coding style, prohibitions, review criteria, and delivery format. It’s best suited for rules that must load stably, be reviewed by the team, and versioned with the repository. For code review, Code Review Rules can be defined in the file closest to the relevant code.

AGENTS.md should not be crammed into a long operating manual. Repetitive processes are suitable for Skills, external tools are suitable for MCP or plug-ins, mechanical enforcement is suitable for Hooks or permission rules, and project settings are suitable for config.toml. Putting different types of information on the right surface can reduce contextual costs and conflicts.

The official documentation states that Codex reads AGENTS.md before starting work and builds a chain of instructions from the global scope to the project root and then to the current directory. Files closer to the current directory are more specific, AGENTS.unauthorized access.md can replace the base file at the same level. There is a configuration upper limit for the combination size, and content that is too long should be split.

Project files should document build tests, directory structure, dependency rules, prohibitions, and delivery standards. The team should avoid conflicts between the root directory and subdirectories, use unauthorized access for special temporary requirements and clean up after completion.

AGENTS.md turns team engineering engagements into a stable starting point for every task.

Data basis: OpenAI official document: Custom instructions with AGENTS.md

11.6 Local Memories: Division of Soft Memories and Hard Rules

Local Memories is an optional local memory layer and is turned off by default. When enabled, Codex can extract useful context from eligible historical conversations and update them in the background after the session is idle instead of writing immediately after each session ends. The main files are saved in the memories directory under Codex home.

Each session can control whether existing memories are used and whether the current session becomes input for future memories. Automatic memories will attempt to filter secrets, but manual review is still required before sharing Codex home or exporting memories. Memory files are generated and should not be used as the only source of hard rules for a team.

The most important distinction is “hard rules/soft memories”: AGENTS.md is a working convention that is explicitly maintained, and Local Memories are references extracted from history. Rules such as tests that must be run, prohibiting file deletion, etc. should be left in AGENTS.md, permissions, or Hooks, rather than just relying on memory.

Local Memories are suitable for extracting reference context from historical tasks, but should not be the only source of hard rules for the team. Tasks can choose whether to use memories and become future memory inputs; secrets and personal information need to be checked before sharing or exporting.

Must-run tests, prohibited actions, and architectural bottom lines are written into AGENTS.md, Rules, or Hooks; experience, preferences, and history clues can go into Memories. Regularly review outdated and conflicting content to prevent the long-term impact of incorrect experiences.

Hard rules are human-maintained and reviewable, and soft recall helps reduce repetitive explanations.

11.7 Plan, Goal and Long Tasks

The number one risk with complex projects is not slow execution, but the wrong direction. The Plan phase should confirm users, scope, dependencies, architectural constraints, milestones and completion criteria through questions and answers. A plan is not a decorative task list, but the basis for subsequent judgments about “what to do next and when to complete it.”

For work that requires many steps, the official documentation recommends giving clear results, constraints, and definitions of completion, and leaving related work in the same chat. Desktop applications can use Goal mode to track ongoing goals; long tasks on the Web can write results and review criteria directly into the prompt.

Long tasks require milestones rather than infinite loops. Each milestone should produce verifiable artifacts such as architectural plans, runnable prototypes, test coverage, migration scripts, and rollback instructions. When faced with conflicting evidence, insufficient authority, or critical decisions, pause and ask for judgment.

For complex tasks, first confirm the scope, dependencies, architecture, milestones and completion standards through Plan. Plans should be updated with evidence rather than generated once and then used again. Long-term goals require stage products, budgets, and stopping conditions to avoid infinite advancement.

The Goal or long task mechanism in the desktop environment is suitable for continuous tracking, but the critical status must still be written to the recoverable summary. When encountering insufficient authority, conflicting evidence, and business trade-offs, you should request manual input instead of expanding the scope independently.

The reliability of long tasks comes from milestones and status, not from longer single runs.

11.8 Worktrees and Handoff: local parallel file isolation

Worktree in the desktop app creates independent checkouts for tasks and shares Git metadata with the main repository. Tasks can read and modify files in parallel without directly occupying the main workspace, but users still need to understand branch, commit, and merge relationships.

The work tree is usually in detached HEAD, and when completed, the task should be moved back to the local workspace via Handoff or explicitly created a branch. Since the same branch cannot be checked out in both working trees at the same time, the target branch and uncommitted changes need to be checked before handover.

Configuration that is ignored by Git but required for task running can be copied to the new worktree via the .worktreeinclude mechanism. The mechanism should not replicate secrets or machine-specific state; environment files, dependency caches, and artifacts require separate security policies.

Worktree uses Git worktree to create independent checkouts for each task, so that multiple Codex sessions can work on the same project in parallel without directly modifying the main workspace. They share Git metadata but have independent copies of files, suitable for implementing different functions, comparing solutions and running background tasks.

Codex-managed Worktrees usually start from the selected branch HEAD and can apply local uncommitted changes to the new Worktree. Files that are ignored but required for operation can be selectively copied via .worktreeinclude. Don’t copy all .env and secrets indiscriminately; only include the paths that the task really needs.

Common pitfalls of Worktree include the inability to check out the same branch in multiple worktrees at the same time, dependencies and caches occupying disks, failure to run due to missing files, and failure to transfer results back to Local after completion. Handoff is used to move sessions between Local and Worktree, which is safer than manually preempting the same branch.

The official documentation points out that Worktree in the desktop application allows multiple independent chats to run in parallel on the same Git project without interfering with each other; it has independent file copies and shares Git metadata. Handoff is used to safely move tasks and code between Local and associated Worktree.

Files that are ignored but necessary for operation can be selectively copied via .worktreeinclude, secrets cannot be copied indiscriminately. The same branch cannot be checked out in multiple worktrees at the same time. After the results are completed, a branch must be created, transferred to Local, or verified in the original worktree.

Worktree solves the problem of parallel modification isolation, and Handoff solves the safe handover between the frontend and the backend.

Data basis: OpenAI official document: Worktrees

11.9 Subagents: Parallel roles of exploration, testing and review

Codex Subagents are suitable for side tasks that can be independently accepted, such as code base exploration, independent testing, security review, and data retrieval. The main agent maintains global goals and merges responsibilities, and the sub-agent returns results after working in an independent context.

The parallel strategy should follow “minimum dependencies, clear delivery, and independent verification.” For example, one sub-agent only outputs the call chain map, another supplements the test, the third reviews the safety, and the main agent finally decides on changes. Multiple sub-agents directly editing the same core file will increase conflicts and cognitive costs.

The sub-agent inherits the current sandbox policy, and tool permissions are still limited by tasks. Teams should document concurrency counts, model costs, failure rates, and merged rework, and not treat “more Agents” as an automatic source of efficiency.

Codex Subagents are suitable for side tasks with clear output such as code base exploration, test completion, security review and data retrieval. The main agent is responsible for global goals and merging, and the sub-agents return evidence and summaries.

When configuring roles, the task scope and tools should be limited to prevent multiple sub-agents from modifying the same core file. The official mechanism and currently available interfaces may change with versions. Actual concurrency and configuration should be subject to the documentation and the current environment.

The value of Subagent is to isolate high-volume side tasks, not to spread the main task responsibilities.

Data basis: OpenAI official document: Subagents

11.10 Skills, Plugins, MCP and Hooks

The extension mechanism of Codex can be distinguished by responsibilities: Skills describe reusable methods, Plugins are responsible for packaging and distribution, MCP connects to external systems, and Hooks perform deterministic control at life cycle nodes. Mixing different responsibilities into one giant script reduces auditability.

The order in which extensions are introduced should start with the smallest surface. One-time requirements are left in the task description first, stable project rules are entered into AGENTS.md, and repeated processes are deposited into Skills; MCP and Plugin are added only when distribution by external systems or organizations is really needed.

Every extension should have a source, owner, version, permissions, testing and rollback records. When upgrading, check not only whether functionality is available, but also whether tool parameters, network access, credential scopes, and default behavior have changed.

The principle of minimal surface helps to keep the system clear: one-time requirements are placed in prompt or thread context; repository rules are placed in AGENTS.md; repeated processes are placed in Skills; when unified installation and external connections are required, Plugin/MCP is placed; mandatory life cycle actions are placed in Hooks. Mixed requirements can be split without forcing one file to take on all responsibilities.

Skills follow progressive loading and read main instructions, references and scripts as needed; plug-ins are suitable for sharing across projects and teams; MCP allows Codex to access third-party documents and tools; Hooks perform mechanical control before and after tool calls, commands or file editing. Any extension may expand permissions and requires review of source code, dependencies, configuration and data scope before installation.

One-time requirements are left in the prompt, repository rules are written into AGENTS.md, repeated processes are made into Skills, Plugin is used for cross-project combination and distribution, external tools are connected through MCP, and mechanical controls that must be triggered use Hooks. Different layers can be combined, but responsibilities should be kept clear.

Plug-ins and MCP will expand the boundaries between tools and data, and Hooks may automatically execute code. Organizations need extended manifests, provenance reviews, version management, permission clarification, and rollbacks.

Putting requirements into the smallest, clearest scaling surface reduces context and governance complexity.

11.11 Use Codex to build RAG and project knowledge base

In knowledge-intensive projects, Codex is more suitable to be positioned as the “project agent layer”: it reads requirements and repositories, disassembles data ingestion, retrieval, generation, evaluation and delivery tasks, calls tools to implement code and verifies the results with tests; the RAG runtime that truly provides services to users should still be borne by deterministic components that are deployable, observable and auditable. The relationship between the two is not to “let Codex replace the knowledge base”, but to let Codex organize and continuously improve the knowledge base project.

Recommended main line: Requirements Prompt → Codex dismantling and planning → Inventory of data and code → Implement ingestion and retrieval → Access generation → Evaluation and security reinforcement → Delivery, and deposit stable rules into AGENTS.md, Skill or Plugin. Each step must have inputs, products, verification methods, and stop conditions.

11.11.1 RAG’s six-layer engineering architecture

RAG (Retrieval-Augmented Generation) is not “direct question and answer after uploading the file”, but a complete link from data governance to evidence-based answers. The following table gives the minimum floor-standing structure.

Level Key tasks Typical products Main verification
1 data source Access PDF, Markdown, Notion/Confluence export, database, work order and code repository; identify timeliness and permissions. Source directory, collection list, ACL and update time fields Accessibility, permission correctness, incremental update
2 Cleaning Remove headers, footers and duplicate content, restore title levels, tables and code blocks, and unify coding and formatting. Cleaning documents, parsing reports, failure queues Sampling accuracy, missing rate, repetition rate
3 Chunks Split by chapters and semantic boundaries, retaining title, path, time, author, authority and source URL. Chunk structure and metadata specifications Complete boundaries, locateable references, and no excessive shredding
4 Index Choose a managed vector store, or a self-managed index such as pgvector, Qdrant, Chroma, etc. Indexing tasks, vectors and keyword fields Status completion, coverage, update and delete consistent
5 Search Query rewriting, metadata filtering, Top-k, hybrid search and rerank; do permission filtering first. Retrieval API, sorting strategy, cache Recall@k, source accuracy, latency
6 Generation Provide evidence, citations, confidence rules, and rejection conditions to the model; avoid evidence extrapolation. Answer API, reference objects, rejection templates Evidence-basedness, citation accuracy rate, rejection rate and manual review

In terms of selection, OpenAI managed file_search can complete file storage, semantics and keyword retrieval with less code, and is suitable for prototypes and rapid delivery; self-managed pgvector, Qdrant or Chroma are more convenient for customizing blocking, sorting, permissions and deployment boundaries, but they need to bear the burden of index life cycle, backup, monitoring and capacity management. The selection criteria should be data compliance, customization requirements, operation and maintenance capabilities, and cost, rather than simply pursuing the number of components.

11.11.2 Write Prompt into executable project requirements

Don’t just write “Make me a RAG.” Prompts should be written as small PRDs so that Codex can break down tasks, identify boundaries, and design acceptance accordingly. The following templates can be used directly as project startup prompts.

Code List 11-1 RAG Project Requirements Prompt

Goal:
Build a RAG question-answering service for internal engineering documents.

Background:
Documents live under docs/ and a Notion export directory. Users will ask about deployment, troubleshooting, and API specifications.

Scope:
- Support document ingestion, semantic chunking, vectorization, retrieval, and answering
- Every answer must cite a source title and URL; explicitly refuse when evidence is insufficient

Non-goals:
- Multi-tenancy is out of scope for this iteration; retain user-permission interfaces and metadata fields only

Technical constraints:
- Use FastAPI for the backend and pgvector for the vector store
- Wrap model calls in app/llm.py; explain the need before introducing a heavyweight framework

Acceptance criteria:
- pytest passes; add at least three RAG evaluation cases
- Return traceable citations when documents are retrieved; never fabricate an unsupported answer

Execution:
Read the repository first and propose verifiable subtasks, risks, implementation order, and a test plan.
Wait for confirmation before modifying code. On completion, summarize changes, test results, and remaining risks.

The recommended repository layout separates data ingestion, retrieval, answering, evaluation, and tool access to avoid cramming all logic into one script. AGENTS.md documents long-term engineering constraints, .codex/config.toml connects project tools, and .codex/hooks/ handles deterministic checks.

Code List 11-2 Minimum maintainable RAG project directory

rag-project/
  app/ingest.py          # Parse, clean, chunk, and ingest documents
  app/retrieval.py       # Filter, retrieve, and rerank
  app/answer.py          # Assemble evidence, citations, and refusals
  app/api.py             # Service API
  app/schemas.py         # Data structures such as Chunk and Citation
  evals/cases.jsonl      # Questions, expected sources, and scoring rules
  tests/test_retrieval.py
  tests/test_grounding.py
  tools/internal-kb-mcp/server.ts
  .codex/config.toml
  .codex/hooks/
  AGENTS.md

11.11.3 Use OpenAI file_search to quickly build a managed knowledge base

The minimum link of the hosting solution is: create a vector store, upload the file, add the file to the storage, wait for the index status to change to completed, and then retrieve it through the file_search tool of the Responses API. The production environment also needs to persist file and storage IDs, record index status and failed retries, and establish a complete life cycle for deletion, version updates, permission filtering, and reference display. Keys should come from environment variables or a key management system and should not be written to code or reports.

Code Listing 11-3: Minimal Python example using vector store and file_search

from openai import OpenAI

client = OpenAI()
store = client.vector_stores.create(name="engineering-kb")

with open("docs/runbook.pdf", "rb") as f:
    uploaded = client.files.create(file=f, purpose="assistants")

client.vector_stores.files.create(
    vector_store_id=store.id, file_id=uploaded.id
)
# Poll the file status and confirm it is completed before querying.
response = client.responses.create(
    model="<MODEL_ID>",
    input="What should I check first when deployment fails? Cite the source.",
    tools=[{
        "type": "file_search",
        "vector_store_ids": [store.id],
        "max_num_results": 6,
    }],
    include=["file_search_call.results"],
)
print(response.output_text)

If the knowledge has department, project or confidentiality level boundaries, the ACL should be saved in the index metadata, and server-side authorization and metadata filtering should be performed before retrieval occurs; you cannot rely on prompts to ask the model to “do not read unauthorized content.” The number of search results can be controlled by max_num_results. When evaluating, you can use include to return the search results and locate the recall and answer questions.

Source: OpenAI, “File search”, https://developers.openai.com/api/docs/guides/tools-file-search/ (verification date: 2026-08-19).

11.11.4 Let Codex be implemented in stages and end with evaluation

A solid implementation sequence is: the first step is to read-only inventory of data, permissions and existing code; the second step is to complete ingestion and repeatable indexing; the third step is to establish a keyword or vector search baseline; the fourth step is to add answers, citations and rejections; the fifth step is to use a fixed question set for retrieval and generation evaluation; the sixth step is to perform performance, security, monitoring and deployment reinforcement. Each stage requires Codex to run minimal verification before moving on to the next stage.

Acceptance should not just be based on the answer “looks like”. The retrieval layer records at least Recall@k, hit source, permission filtering and delay; the generation layer checks whether the answer is supported by evidence, whether the reference can locate the original text, and whether to reject the answer if there is no basis; the engineering layer checks whether the index can be rebuilt, the document can be updated and deleted, failure can be retried, and the log does not leak sensitive information. Write representative failure cases into evals/cases.jsonl so that subsequent modifications will not degrade repeatedly.

11.12 MCP Server: Integrate knowledge and tools into workflow

The value of MCP (Model Context Protocol) is to package knowledge and actions that are not available locally in Codex into a tool with clear boundaries, stable input and output, and auditability. The RAG service is still responsible for retrieval, permissions, and data governance; the MCP Server only exposes the narrow interface required to complete the task. The relationship can be summarized as: MCP provides capabilities, AGENTS.md or Skill stipulates when and in what order to use capabilities, and Hooks and approval mechanisms are responsible for hard constraints.

11.12.1 Define the tool contract first, then write the server

Tools should “do one thing at a time”, and the name and description should be such that the model can be selected correctly; reading and writing actions are separated, and writing tools require confirmation by default. Permission verification must be performed on the server side. Annotations such as readOnlyHint and destructiveHint only help the client understand the risks and cannot replace authentication.

Tools Main Inputs Outputs Permissions and Approvals
search_docs query, filters, top_k snippet, title, URL, score and document ID read-only; do ACL filtering before querying
get_doc doc_id Text or controlled summary, metadata Read-only; verify document permissions again
list_sources Optional source_type Available corpora and update time Read-only; hide unauthorized corpora
create_eval_case question, expected_sources Evaluation case ID and save location Write; default prompt/manual confirmation

11.12.2 A runnable skeleton: TypeScript MCP Server

The following example uses the official MCP SDK, connects to Codex through standard input and output, and registers the read-only search_docs tool. searchIndex is the project’s own search adapter where identification, ACL filtering, timeouts, audit logging and backend error handling should be done. The returned structure provides both structuredContent and text content for easy model consumption and programmatic processing.

Code List 11-4 Minimal implementation of internal-kb MCP Server

import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
import { z } from "zod";

const server = new McpServer(
  { name: "internal-kb", version: "1.0.0" },
  { instructions: "Search before answering project questions; cite title and URL." }
);

server.registerTool("search_docs", {
  title: "Search internal documentation",
  description: "Use before answering project knowledge questions.",
  inputSchema: {
    query: z.string().min(3),
    source: z.string().optional(),
    top_k: z.number().int().min(1).max(20).default(6),
  },
  annotations: { readOnlyHint: true, destructiveHint: false, openWorldHint: false },
}, async ({ query, source, top_k }) => {
  const chunks = await searchIndex({ query, source, top_k });
  return {
    structuredContent: { chunks },
    content: [{ type: "text", text: JSON.stringify(chunks) }],
  };
});

await server.connect(new StdioServerTransport());

The actual server should also register get_doc, list_sources, and create_eval_case, and define the input length, pagination, timeout, error code, and audit fields for each tool. Remote services can be exposed using Streamable HTTP /mcp; use MCP Inspector or unit tests to verify normal input, illegal input, permission denials, and backend timeouts before going live.

11.12.3 Configure MCP in the project and use AGENTS.md to solidify the workflow

Codex’s MCP configuration can be placed in user-level ~/.codex/config.toml, and trusted projects can also use project-level .codex/config.toml. The following example restricts the visible tools and automatically approves read-only searches and keeps the default query for write-based create_eval_case. Tokens are only read from environment variables. Project-level configuration is shared with the repository, so it should only be enabled in trusted projects and avoid submitting real keys.

Code List 11-5 Project level .codex/config.toml

[mcp_servers.internal_kb]
command = "node"
args = ["./tools/internal-kb-mcp/server.js"]
env_vars = ["KB_API_TOKEN"]
enabled_tools = ["search_docs", "get_doc", "list_sources", "create_eval_case"]
default_tools_approval_mode = "prompt"
startup_timeout_sec = 20
tool_timeout_sec = 30

[mcp_servers.internal_kb.env]
KB_API_URL = "https://kb.example.com"

[mcp_servers.internal_kb.tools.search_docs]
approval_mode = "approve"

If Codex is not started from the repository root directory, you should change server.js to a verified stable absolute path or use a wrapper script to parse the project root directory. After the configuration is completed, run codex mcp list to check the discovery status, and then test search, full text retrieval, low-relevance results, unauthorized documents, timeout, and write approval respectively.

Code Listing 11-6: RAG tool rules written into AGENTS.md

## RAG workflow
- Call internal_kb.search_docs before answering questions about project knowledge.
- Cite the source title and URL for every factual claim, and retain doc_id for traceability.
- If evidence is below the threshold, sources conflict, or the ACL denies access, do not guess; explain the gap.
- Call get_doc only when full text is needed; avoid reading large amounts of content without a purpose.
- create_eval_case writes to the repository and may be called only after user confirmation.
- After changing retrieval strategy, run tests and evals, then report Recall@k and failure cases.

Source: OpenAI, “Model Context Protocol” and “Build an MCP server”, https://developers.openai.com/codex/mcp/; https://developers.openai.com/plugins/build/mcp-server/ (verification date: 2026-08-19).

11.13 Hooks: Security interception and automatic inspection

Hooks are deterministic commands that run at key points in the Codex life cycle and are suitable for executing “must happen” rules: screening keys when prompted to submit, blocking dangerous actions before calling Bash, apply_patch or MCP tools, checking for failure and leak signals after the tool ends, and requiring additional testing and summary when Codex is ready to stop. They turn natural language constraints into testable programmatic guardrails.

11.13.1 Which checkpoint should the event be placed at?

Events Trigger timing Typical uses Actions that can be taken
UserPromptSubmit After user prompt is submitted, before Codex processing Detect API key, production password; supplement fixed project context Block prompt or add context
PreToolUse Before the execution of Bash, apply_patch, MCP and other tools Intercept recursive deletions, destructive database commands, and modify sensitive files allow, deny or modify input
PermissionRequest Codex when requesting approval Map project risk rating to automatically allow, deny, or ask normally allow, deny, ask
PostToolUse After a tool has completed and returned results Identify test failures, exception stacks, leaked secrets, or missing artifacts Feedback and prevent further use of results; side effects cannot be undone
Stop Codex is ready to end the task Confirm that testing, lint, review and change summary are completed Allow to end, or ask to continue the round

11.13.2 Configure three key Hooks

Hook configuration is written to config.toml the same as MCP. matcher uses regular matching tool names; Windows can provide command_windows separately. Next, point the prompt screening, pre-tool strategy, and post-tool review to the in-project script. The Windows paths in the examples are placeholders and must be replaced with the verified absolute path to the repository when used.

Code List 11-7 Hooks configuration in config.toml

[[hooks.UserPromptSubmit]]
[[hooks.UserPromptSubmit.hooks]]
type = "command"
command = 'python3 "$(git rev-parse --show-toplevel)/.codex/hooks/security_policy.py"'
command_windows = 'py -3 C:\\path\\to\\repo\\.codex\\hooks\\security_policy.py'
timeout = 10

[[hooks.PreToolUse]]
matcher = "^Bash$|^apply_patch$|^mcp__internal_kb__.*$"
[[hooks.PreToolUse.hooks]]
type = "command"
command = 'python3 "$(git rev-parse --show-toplevel)/.codex/hooks/security_policy.py"'
command_windows = 'py -3 C:\\path\\to\\repo\\.codex\\hooks\\security_policy.py'
timeout = 10
statusMessage = "Running safety policy"

[[hooks.PostToolUse]]
matcher = "^Bash$|^mcp__internal_kb__.*$"
[[hooks.PostToolUse.hooks]]
type = "command"
command = 'python3 "$(git rev-parse --show-toplevel)/.codex/hooks/post_tool_review.py"'
command_windows = 'py -3 C:\\path\\to\\repo\\.codex\\hooks\\post_tool_review.py'
timeout = 20

11.13.3 Implement security policy using JSON input and output

Codex passes JSON to the Hook via standard input. PreToolUse reads tool_name and tool_input; for Bash and apply_patch, the command or patch text is usually located in tool_input.command. The following script handles both user prompts and pre-tool checks, and gives blocking results that are recognized by Codex. Real projects should classify rules, record hit audits, and set controlled exceptions for allowed operation and maintenance operations, rather than relying on keywords to expand indefinitely.

Code List 11-8 .codex/hooks/security_policy.py

import json
import re
import sys

data = json.load(sys.stdin)
event = data.get("hook_event_name", "")

SECRET = re.compile(
    r"(?i)(api[_-]?key|access[_-]?token|secret|password)\s*[:=]\s*['\"]?[A-Za-z0-9_./+-]{12,}"
)
DANGEROUS = [
    re.compile(r"(?i)\brm\s+-rf\b"),
    re.compile(r"(?i)\bRemove-Item\b.*\b-Recurse\b"),
    re.compile(r"(?i)\b(DROP\s+DATABASE|TRUNCATE\s+TABLE)\b"),
    re.compile(r"(?i)(^|[ /\\])\.env($|[ ./'\"])"),
]

if event == "UserPromptSubmit":
    prompt = data.get("prompt", "")
    if SECRET.search(prompt):
        print(json.dumps({
            "decision": "block",
            "reason": "The prompt may contain a secret; redact it before continuing.",
        }, ensure_ascii=False))
        raise SystemExit(0)

if event == "PreToolUse":
    tool_input = data.get("tool_input") or {}
    payload = str(tool_input.get("command", tool_input))
    if any(rule.search(payload) for rule in DANGEROUS):
        print(json.dumps({
            "hookSpecificOutput": {
                "hookEventName": "PreToolUse",
                "permissionDecision": "deny",
                "permissionDecisionReason": "Blocked by the destructive-operation policy.",
            }
        }, ensure_ascii=False))
        raise SystemExit(0)

print("{}")

PostToolUse should parse tool_response instead of second-guessing command intent. If you find pytest FAILED, Traceback, secret scanning alarms or missing expected files, you can output decision=block and reason, feedback the failure to Codex and ask for repair; however, the action has already occurred, and PostToolUse cannot undo the side effects. Stop Hook can also return decision=block when there is no recent successful test record, requiring the test to be run again and the results reported. Test status should be derived from CI, timestamps, or machine-readable records and cannot be inferred from model summaries alone.

Code Listing 11-9 Core check of post_tool_review.py

import json, re, sys

data = json.load(sys.stdin)
response = json.dumps(data.get("tool_response", ""), ensure_ascii=False)
failed = re.search(r"(?i)(pytest.*FAILED|Traceback|secret detected)", response)

if failed:
    print(json.dumps({
        "decision": "block",
        "reason": "Tool output contains a failure or secret-leak signal; inspect and fix it.",
    }, ensure_ascii=False))
else:
    print("{}")

11.13.4 Boundary and online checking of Hooks

Hooks are strong engineered guardrails, but not complete security perimeters. Part of the call path may not go through the local function tool Hook; PostToolUse occurs later than the side effect. High-risk projects must use sandbox, least privileges, network or domain name restrictions, MCP server authentication, manual approval, branch protection, and CI at the same time. The Hook script itself should also enter version control, code review, and automated testing, and security rules should be modified with the same caution as production policies.

At least verify before going online: prompts containing test keys can be blocked and not echoed; recursive deletions, database destructive statements and sensitive file modifications can be rejected before execution; read-only search_docs runs normally and is subject to ACL constraints; test failures can trigger post-feedback; Stop rules will not loop infinitely; Hook timeout or exception behavior complies with the team’s failure opening and closing policy; logs can be associated with sessions, tools and decisions but do not record secrets.

Source: OpenAI, “Hooks”, https://developers.openai.com/codex/hooks/ (verification date: 2026-08-19).

11.14 Cloud, external integration and reproducible environment

Codex Cloud runs tasks in an isolated environment, suitable for allowing multiple long jobs to continue in parallel. Before official use, dependencies, tools, environment variables, and secrets must be configured for the repository to ensure that the task environment is reproducible. Once the results are complete, the summary and diff should be reviewed, subsequent revisions requested if necessary, and a PR created.

Cloud tasks can be initiated from portals such as Web, GitHub, Linear, or Slack. Integration improves the efficiency of tasks entering the system, but it also brings identity and context issues: who has the authority to trigger tasks, which repositories are allowed to access, whether external messages are trustworthy, where results are returned, and who is responsible for merging all require organizational rules.

Files, credentials, and networks are not the same in the cloud as on-premises. Don’t assume that locally runnable commands must exist in the cloud, and don’t copy secrets directly from your personal machine. Environment configuration, minimum scope credentials, and domain name allowlists should be used.

Cloud tasks require explicit dependencies, setup scripts, environment variables, secrets, and network rules. After completion, review the summary and diff before merging. External integration improves the efficiency of task entry, but it must also be clear who can trigger, which repositories are accessed, where the results are returned, and who is responsible for merging.

The cloud and personal machine status are different. Don’t assume that local services, uncommitted files, and personal credentials exist; environment configuration should be reproducible, secrets should use the smallest scope, and networking should be limited to domain names required for the task.

The value of Cloud comes from isolation and reproducibility, not from moving the local environment to the remote location.

11.15 Scheduled Tasks and Continuous Work

Continuous tasks should clearly describe the trigger conditions, input range, operating environment, timeout, maximum retry, notification object and stop method. Running in the background does not reduce responsibility, but requires more stable logging, status recording, and exception escalation.

Scheduled tasks should prioritize the use of minimal privileges and a reproducible environment. If a task relies on local uncommitted files, interactive credentials, or external actions that cannot be rolled back, it is not suitable for direct unattended running and should be split into two stages: preparation and approval.

Scheduled Tasks can be created and managed from the web or desktop application. Independent Scheduled tasks start from the saved prompt each time and report in the Scheduled interface; tasks embedded in existing chats can continue to use the context of the chat, suitable for polling long operations, continuous research or PR follow-up. CLI and IDE do not provide Scheduled management interface, but you can test prompts, skills or scripts in it first.

Project-level Scheduled tasks can run in Local or standalone Worktrees. Local will directly modify the main workspace, and Worktree can isolate background changes from unfinished work. When local files are involved, the computer needs to be turned on, the desktop application is running, and the project path is available; Web tasks can use uploading data and connection tools, but cannot directly operate folders on the computer.

Scheduled tasks are unattended, so you should use the narrowest access possible, test manually first, and then observe the first few runs. The task prompt should clearly describe what to do each time, what situations are worth reporting, what to do if there are no changes, and when to stop or request input. Frequent running will amplify costs, false positives, and Worktree usage.

Scheduled tasks are suitable for log summary, PR follow-up, dependency monitoring and periodic reporting. Before formal scheduling, manually test and write down the output, failure threshold, notification responsibility and stop conditions when there are changes and no changes. Project-level tasks should preferentially use independent Worktrees to avoid interfering with local unfinished work.

Frequent scheduling amplifies costs, false alarms, and workspace occupancy. Background tasks are riskier with default permissions and non-interactive policies, so use narrow access, auditable output, and the first few human observations.

Continuous work must have an observation strategy, a failure strategy, and an accountable person.

11.16 Sandbox, Approval, Rules and Network

Codex configures sandbox scope and approval policy separately. The sandbox determines what the system can read, write, or execute, and the approval policy determines which out-of-bounds or high-impact actions must be queried; the two cannot replace each other.

Read-only mode is suitable for inspection and planning, workspace write is suitable for most undone local engineering tasks, and full access should only be used when the risks are understood and the environment is additionally protected. Approvals can be confirmed incrementally from untrusted actions, on demand or in a controlled environment with less interruption.

Networks and credentials need to be governed separately. Even if the workspace is allowed to be written, it does not mean that any domain name should be opened or all user credentials should be inherited. Dependent downloads, external APIs, and code hosting connections should use domain restrictions, dedicated identities, and audit records.

Codex controls “what can be accessed” and “when to ask” separately. Common sandbox modes include read-only, workspace-write, and danger-full-access; approval policies include untrusted, on-request, and never. workspace-write allows editing and executing regular commands in the workspace, which is a low-friction local work baseline; danger-full-access removes boundaries and is only suitable for situations where there is a clear need and the risk can be taken.

Auto-approval or auto-review does not change the sandbox boundaries, it only approves the reviewer of the request. If a process only requires exceptions for a specific command prefix, Rules should be used to allow, ask, or disallow, rather than extending all file and network permissions. Specific writable roots can be added when multiple directories are required.

Network access should be turned off by default or restricted to domain names necessary for the task. Background Scheduled tasks use the default sandbox and may adopt non-interactive approval policies, which poses a higher risk. Organizations can limit the allowed sandbox and approval combinations through management policies such as requirements.toml to prevent personal configurations from bypassing the bottom line.

Security Configuration|Don’t understand “never approval” as a general option for “higher efficiency”. Unattended tasks should be prioritized with workspace-write, minimal networking, and auditable output; only expand permissions if they are isolable, rollable, and explicitly authorized.

OpenAI official documentation separates sandboxing from approval: read-only, workspace-write, and danger-full-access define access boundaries; untrusted, on-request, and never determine when to stop; reviewer determines whether qualified requests are processed by users or automatic review. Automatic review does not change the scope of the sandbox.

Low-risk local automation usually uses workspace-write and on-request as the baseline, uses specific writable roots across directories, uses Rules for command exceptions, and limits the network to necessary domain names. The combination of danger-full-access and never removes major boundaries and should only be used in explicitly authorized and isolated environments.

Dimensions Common options Design issues
Sandbox Read Only/Workspace Write/Full Access What the system can touch
Approvals Untrusted/On Demand/Never When Must Ask People
Network Closed/Domain Restricted/Open External Data and Supply Chain Risks
Credentials Not provided/injected/inherited by tool Is it least privileged and auditable
Review User/Auto Review Who makes decisions on upgrade requests

“Never ask” is not a safe mode; borders and censors must be configured separately.

Data basis: OpenAI official documents: Sandbox; Agent approvals & security; Rules

11.17 Team landing route

Codex’s team implementation is suitable for layering around projects and execution environments. The project layer is responsible for AGENTS.md, verification commands and code review rules; the environment layer is responsible for the selection of Local, Worktree and Cloud, network and credential policies, and how task results are returned to the main workspace.

Local is suitable for short tasks that require instant judgment and local status, Worktree is suitable for tasks that require multiple modifications in parallel and files must be isolated, and Cloud is suitable for long-running tasks that can be independently verified and can asynchronously recycle results. Environment selection should be part of the task template.

Team operations should also record the success rate, manual takeover time, failure reasons, and rollback costs for each type of environment. Expanding the scope of background tasks and automated scheduling is only appropriate once there is stable evidence of parallelism benefits, verification quality, and governance costs.

Codex implementation should start from the code base baseline rather than installing a large number of plug-ins first. In the first stage, select a repository, create AGENTS.md, confirm the build and test commands, and use Local or CLI to process small tasks; in the second stage, Worktree parallelism and planning mode are introduced; in the third stage, high-frequency processes are made into Skills and Hooks; in the fourth stage, MCP, Cloud and Scheduled tasks are connected.

Organizations need both engineering and governance metrics: task success rate, test pass rate, PR rework rate, average manual intervention, number of privilege escalations, prompt-injection or secret-exposure incidents, automation false-positive rate, and cost. Expanding automation is appropriate only when results are stable, failures are visible, and changes can be rolled back.

  • repository baseline: AGENTS.md, build commands, testing, formatting, and code review rules are complete.

  • Task baseline: goals, scope, environment, acceptance, and stopping conditions are clearly written.

  • Isolation baseline: Parallel tasks use Worktree or Cloud and do not directly preempt the main workspace.

  • Validation baseline: Each delivery includes diff, testing and unfinished risks.

  • Extended baseline: Skills, Plugins, MCPs and Hooks have sources, responsible persons, versions and rollbacks.

  • Automated baseline: manual testing first, manual observation for the first few times, background tasks using minimal permissions.

The first stage improves AGENTS.md, builds testing and delivery formats; the second stage handles small tasks in Local/CLI and introduces Worktree; the third stage turns high-frequency processes into Skills and Hooks; the fourth stage connects controlled MCP and Cloud; and the fifth stage arranges Scheduled tasks and a higher degree of autonomy.

Indicators should cover task success, test pass rates, PR rework, manual intervention, privilege escalation, extension risks, and cost. Team assets should have explicit owners, versions, and review records.

Codex implementation should start from the repository and verification baseline, not from installing more extensions.

11.18 Case: Complete dependency upgrade and regression verification in parallel

The key to this case is not how many tasks to start at the same time, but to first form a constraint set that depends on the upgrade: the target version, compatibility range, prohibited modifications, test matrix, network conditions and rollback criteria should all be clear. Parallelism without constraints will only produce conflicting modifications more quickly.

The exploration task can analyze release notes, affected modules and existing test gaps respectively; the implementation task should modify the lock file and adaptation code in an independent Worktree; the review task should check permissions, security bulletins, generated files and indirect dependency changes. The main task is responsible for merging evidence, rather than repeating the entire process of subtasks.

Verification should be promoted from narrow to broad: first run dependency-related single tests, then perform module integration tests, static checks and builds, and finally cover the key end-to-end paths. If the cloud environment is different from the local environment, differences in running images, system dependencies, network access, and failures should be recorded separately.

When delivering, it is necessary to distinguish between “the code has been updated” and “the upgrade has been accepted.” The former is justified by diffs and build results, the latter also requires evidence of regressions, performance or volume changes, known risks, rollback methods, and maintainer confirmation.

In this approach, the value of Codex is demonstrated by organizing parallel exploration, isolating modifications, and aggregating evidence, while the final decision remains controlled by clear acceptance gates. Parallel capabilities only translate into engineering throughput when combined with reproducible environments and auditable deliverables.

Task splitting must also comply with dependency directions. Research on release notes and security advisories can be carried out independently, but code modifications must wait until the scope of impact is initially clear; end-to-end regressions usually rely on the build to pass. Writing these sequence relationships into task descriptions can prevent subtasks from generating invalid results when prerequisites are missing.

Each parallel task should return a structured summary including key files read, assumptions made, modifications produced, commands run, verification results, and open issues. The main task only accepts conclusions with evidence and arranges for review of conflicting results.

During the merge phase, it is necessary to specifically check whether multiple Worktrees have modified the same lock file, generated file or public configuration. Even if textual conflicts are automatically resolved, semantic version selection and build order may still overwrite each other, so a regeneration and full verification must be performed after the merge.

If the upgrade fails, it should be handled as a diagnosability rather than continuously letting the model try different versions. First distinguish between download or network failures, parser conflicts, compilation interface changes, runtime behavior changes and expiration of the test itself, and then select recovery actions for the corresponding types.

For high-risk dependencies, security bulletins and license changes should be entered into the review log. Codex can help with retrieval and organization, but whether a version meets organizational policies still depends on controlled data sources, software bill of materials, and security team rules, and cannot rely solely on natural language summaries.

Cost estimates should also cover inference, cloud execution, manual review, and failed reruns. If the waiting time saved by parallel tasks is less than the cost of coordination and review, you should return to a single-task closed loop; parallelism is a scheduling strategy and is not the default answer for all engineering tasks.

In the end, stable practices can be settled into dependency upgrade Skills, AGENTS.md rules and CI checks, but task-level judgments should be retained. Automation takes care of repeating steps, and maintainers take care of accepting compatibility trade-offs and release times.

The acceptance matrix should cover both operating systems, runtime versions, and critical functional paths. If the project cannot afford the complete combination, the minimum set can be determined based on production distribution and failure impact, and it should be clear which combinations have not yet been verified; tests that have not been run cannot be recorded as passed.

The rollback plan must also be truly practiced. It is not enough to just keep the old version number. You must also confirm whether the lock file, cache, database migration and generated products can be restored, and prepare for forward repair if necessary. If the rollback will cause data incompatibility, the upgrade must adopt a more strict phased release.

Manual review should focus on the most difficult to prove parts of the model: whether the public interface semantics have changed, whether the default configuration has changed, whether indirect dependencies have introduced new permissions, and whether error handling still meets business expectations. Format and static rules are left to deterministic tools as much as possible.

After the task is completed, the team should add the failure type and manual takeover point to the evaluation set. For the next upgrade, you can run these historical use cases first to determine whether the new model, rule, or execution environment actually reduces the risk, rather than just comparing the speed of task completion.

When the process stabilizes, Codex can take on more preparation, parallel verification, and report compilation work, but release approval should still be decoupled from code generation. Who has production change authority, who confirms business compatibility, and who is responsible for incident response must be made clear in the organizational system.

The task requires upgrading a core dependency, keeping the public API unchanged, fixing type errors, running full tests and providing rollback instructions. The main task first reads AGENTS.md and lock files to form a risk list; one Worktree attempts a minimum version upgrade, and the other only studies upstream changes and tests Subagent to analyze failure distribution.

The main agent compares the results and selects the minimum upgrade path, restricts the network to the packet source and maintains workspace-write. Approval on demand when dependent installation requires external access; after passing the test, Handoff to Local, do final verification in existing development services, review lock files and generated files.

Deliveries include version changes, compatibility modifications, test evidence, platforms not yet covered, and rollback commands. The case shows that Worktree isolation is suitable for comparison solutions, Subagent is suitable for knowledge and testing side tasks, and the final merger still requires unified decision-making.

Codex’s parallelism benefits come from environment isolation and clean handoffs, rather than launching more models simultaneously.

12. Product comparison, selection and combination use

Product selection is not a comparison of the number of functions, but a matter of matching tasks, environment, team ecology and governance conditions. The four products represent different operation entrances, continuity and control methods.

Real task evaluation under a unified dimension can distinguish demonstration advantages and stable delivery capabilities, and can also identify combined use and migration strategies.

12.1 Selection principles: matching of tasks, environment, ecology and governance

When choosing a product, you should start by answering what the task is, where it will run, what tools are needed, and who is responsible for approval and maintenance. OpenClaw is suitable for personal agents who want self-hosting, rich channels, and always online; Hermes is suitable for users who value multiple models, long-term memory, skill accumulation, and experimentation; Claude Code is suitable for teams that want to establish engineering closed loops in multiple development interfaces and reuse processes through rich expansion systems; Codex is suitable for engineering scenarios that require local, Worktree and Cloud collaboration, complex project parallelism, and clear sandbox governance.

Product value depends on task and organizational conditions. Resident personal assistants value channels, memory, and host control; engineering teams value codebase understanding, testing, diffs, environment isolation, and PR processes; research teams value browsing, referencing, long tasks, and multi-format delivery.

The task set and acceptance should be fixed before selection to avoid comparing different products with different tasks. Also calculate the total cost of accounts, models, infrastructure, extended maintenance, permission review, and manual review.

The absolute strongest without deviating from tasks and governance conditions.

12.2 Unified comparison of four products

  • Individuals who want to call their own host tools at any time from Telegram/WhatsApp and other channels: Prioritize OpenClaw and consider identity, network and host isolation as prerequisites.

  • Researchers or advanced users who want multiple models, self-deployment, long-term memory, and self-accumulation of skills: Check out Hermes, but invest in more versions, security, and skill reviews.

  • The team mainly uses the Anthropic ecosystem and hopes to condense the engineering process into CLAUDE.md, Skills, Subagents, Hooks and Plugins: Claude Code to make it more convenient.

  • The team needs Local/Worktree/Cloud unified organization, parallel projects, Scheduled tasks and clear sandbox approval: Codex has more advantages.

  • If the task is highly certain and risky, don’t abandon a mature workflow for the sake of “agentization”; let the agent handle only the open steps.

OpenClaw highlights multi-channel self-hosted Gateway, Hermes highlights multi-model and procedural learning, Claude Code highlights the engineering closed loop and rich extensions around Claude, and Codex highlights Local/Worktree/Cloud and multi-control plane organization. Their functionality continues to change, and the tables are used to establish current structural understanding and are not intended to serve as long-term unchanging rankings.

Dimensions OpenClaw Hermes Claude Code Codex
Core positioning Resident personal gateway Open self-improvement framework coding agent engineering agent platform
Typical entrance Message channel Terminal/Message Terminal/IDE/Desktop CLI/IDE/Desktop/Cloud
Long term Strong Strong Project/session Local+Backend
Verification basics Task customization Task customization Test/diff Test/diff/isolate tasks
Main Governance Channel and Gateway Permissions Tools and Memories Permissions/Hooks/Rules Sandbox/Approval/Work-Tree

The unified dimension allows product comparison to shift from function stacking to system design.

12.3 Key differences between Claude Code and Codex

The common foundation between the two is far greater than the superficial differences: they both read code libraries, edit files, run commands, integrate with Git and testing, and support persistent instructions, Skills, MCP, Subagents, Hooks and plug-ins. The choice should not only depend on model preferences, but also on the team’s existing accounts, IDE/terminal habits, cloud environment, permission management, and expanded ecosystem.

Claude Code uses CLAUDE.md and Auto Memory to form a “human-written rules + Claude learning” structure. The official document has a very rich description of Skills, plug-in Marketplace and multi-Agent capabilities; Codex uses AGENTS.md and Local Memories to distinguish “hard rules + soft memories”. Worktrees and Local/Cloud environments have become important control surfaces for concurrent engineering, and Scheduled tasks and sandbox/approval configurations are also more prominent.

The safest selection method is to conduct an A/B pilot with the same set of real tasks: a cross-file bug, a repository exploration, a test completion task, a PR review, and a background reporting task. Compare quality of completion, verification evidence, human intervention, permission configuration, and team reusability rather than just build speed or throwaway coding style.

Both can read the code base, edit files, run commands, use Skills, MCP, Hooks and sub-agents. The difference is more reflected in the environmental organization and ecology: Claude Code takes CLAUDE.md, Rules and Anthropic extension system as its core; Codex takes AGENTS.md, Local/Worktree/Cloud, Handoff and OpenAI/ChatGPT control plane as its core.

The selection should not only compare the code quality of one task, but also the stability, context cost, permission prompts, parallel conflicts, extended maintenance and team review habits of multiple runs of the same repository.

Observation Points Claude Code Codex Selection Issues
Configuration entrance CLAUDE.md, Settings AGENTS.md, configuration Where to place team rules
Extension mechanism Skills, MCP, Hooks, Plugins Skills, MCP, Hooks, Plugins Whether deterministic control is required
Parallel collaboration Subagents, Agent Teams Subagents, desktop multitasking, cloud tasks Isolation and coordination costs
Running environment Mainly local, multiple entries Local + working tree + cloud Whether background operation is required
Security model Permission model and tool control Separation of sandbox and approval Who approves risks

Claude Code and Codex have a close common foundation, with the key differences being environmental organization and ecological governance.

12.4 Decision tree: Select product route from task entry

If the main entrance is messaging channels and 24/7 online, evaluate OpenClaw first; if you want multiple models, Profiles, and self-generated procedural knowledge, evaluate Hermes; if the team focuses on Claude ecology and terminal/IDE engineering, evaluate Claude Code; if you need desktop projects, multiple Worktrees, Cloud, and ChatGPT/Codex collaboration, evaluate Codex.

Decision trees only narrow down the scope. Ultimately, representative task A/B pilots are still needed to verify account and data policies, available models, platform support, and organizational managed configurations.

Primary needs Priority inspection Next questions
Multiple message channels, resident personal portal OpenClaw Self-hosting and channel governance capabilities?
Open framework, long-term memory and customization Hermes Can it undertake operation and maintenance?
Deep local code base collaboration Claude Code/Codex Team ecology and security requirements?
Parallel background tasks, isolation environment Codex Do you need cloud tasks and work trees?
Complex multi-agent collaboration experiment Claude Code/Codex Are there clear split and coordination benefits?

First filter by entrance and environment, and then make decisions based on real tasks and management requirements.

12.5 Unified measured design: How to compare without being misled by demonstrations

Actual testing should include at least four types of tasks: locating unfamiliar code bases, small-scale bug fixes, test completion, source research or document updates. Each task provides the same goals, materials, boundaries, and acceptance, documenting the environment, model, permissions, and extensions.

Metrics include complete success rate, test passes, irrelevant changes, correct references, human intervention, runtime, cost, privilege escalation, and failure visibility. Repeat at least multiple rounds and use it by different people to avoid mistaking a single lucky result for an ability.

The review needs to distinguish the impact of the model, product runtime, tools, project descriptions and user actions. Otherwise, even if the winner is compared, there is no way to know which layer to improve.

Steps Requirements Output
Topic selection 20-50 real, reproducible tasks Task set
Blind test Unify environment, permissions and model budget Original running record
Acceptance Pre-defined automatic and manual criteria Score sheets
Security Injection, unauthorized access, sensitive data testing Red team results
Review Improve by failure type rather than average score Decision report

Unified tasks and complete evidence are the reliable basis for product selection.

12.6 Combination usage and migration strategy

Organizations can combine products: OpenClaw or Hermes serves as the messaging and scheduling portal, Claude Code or Codex handles code tasks; research agents generate Issues, engineering agents are implemented, and independent review agents are verified. Identity, data transfer, permissions and responsibilities must be clarified before combination.

Transferable assets include task specifications, acceptance criteria, project rules, Skills, MCP interfaces and evaluation sets. The specific configuration formats are different, but the content layer can remain unified. When migrating, migrate rules and tests first, and then migrate automation to avoid directly copying the permissions and implicit dependencies of the old environment.

Making knowledge and verification assets into product-independent layers can reduce lock-in and improve composability.

13. Organizational implementation: from pilot to large-scale operation

The entry of AI agents into organizational processes requires simultaneous preparation of tasks, data, tools, verification, identity, governance and human capabilities. The goal of a pilot is to generate evidence and assets, not just to complete a demonstration.

From task inventory and controlled pilots to capability solidification and large-scale operations, organizations should gradually accumulate rules, skills, tools, evaluation sets and responsibility systems.

13.1 Readiness: Processes, Data, Tools, Validation and Governance

Readiness is not measured by the number of seats purchased. It is necessary to check whether the task has been clearly delivered, whether the data can be obtained legally, whether the tool is stable, whether the verification is automated, whether permissions can be minimized, and whether there is a responsible person for failure. Processes that lack verification should be constructed and accepted first, and processes that lack interfaces should first organize data and tools.

Ready dimension Not ready signal Ready signal
Task Objectives are vague and cannot be accepted Input and output and boundaries are clear
Data Confusing sources and unclear permissions Clear classification, version, and access policies
Tools Interface is unstable, no readback Parameters are clear, errors are observable
Governance Unclear who is responsible Clear approval, auditing, and rollback
Personnel Only able to chat and ask questions Able to write task descriptions and accept them

Agent readiness starts with process and engineering readiness.

13.2 Pilot combination: one high-frequency task, one high-value task, and one governance task

High-frequency tasks are used to observe reuse and cost, such as weekly reports or test completion; high-value tasks are used to observe cross-step capabilities, such as defect fixes or research reports; governance tasks are used to verify prompt injection, permission denial, rollback, and auditing. Combining the three categories is more comprehensive than choosing just one great demo.

The pilot is limited to a small number of teams and repositories, using real but recoverable data. All tasks use unified instructions and acceptance records, register permissions and extensions before running, and record manual intervention and failures after running.

Pilots need to both prove value and proactively verify failure and governance.

13.3 90 Day Roadmap

Days 1-15 sort out tasks and risks and establish evaluation sets; days 16-30 complete project rules, environment and verification baselines; days 31-50 run read-only and controlled write pilots; days 51-65 skill high-frequency processes; days 66-80 supplement expanded reviews, audits and incident responses; days 81-90 make decisions to expand, adjust or stop based on data.

The roadmap must set stage exit conditions. If the success rate, verification coverage, or permission management does not meet the threshold, the current phase should be extended instead of forcing the backend automation to be launched according to the calendar.

Stages Key tasks Exit conditions
0-30 days: Discovery Task inventory, baseline, risk classification, tool screening Select 3-5 pilots
31-60 days: pilot task template, sandbox, evaluation, training, weekly review stable success rate and failure visible
61-90 days: solidification skills, access process, monitoring, responsibility system can be copied and passed the governance review

Upgrading the degree of autonomy based on evidence is the main line of the 90-day pilot.

13.4 Roles and Responsibilities: Business, Engineering, Security and Platform are jointly responsible

The business owner defines value and ultimate responsibility, domain experts provide rules and exceptions, the engineering team builds tools and verification, the platform team manages identity, environment and observability, security legal defines boundaries and incident response, and users are responsible for operating within the scope of authorization and providing feedback.

Any background tasks and high-privilege extensions should have clear responsibilities and replacements. Product manufacturers, models and agents cannot become responsible entities, and final authorization and external results still belong to the organization.

Agent operations span processes, software and governance and cannot be left to a single team.

13.5 Organizational knowledge assets: rules, skills, tools, and assessment sets

The asset catalog should contain project instructions, task templates, Skills, Hooks, MCPs, plug-ins, environment settings, assessment sets, and security policies. Each item records the purpose, scope, responsible person, version, dependencies, permissions, evaluation results and retirement date.

High-quality assets come from operational feedback. Rules are updated for repeated errors, Skills are generated for stable processes, Hooks are generated for mechanical checks, tool interfaces are formed across system requirements, and typical success and failure samples are entered into the evaluation set.

The core of scale is not more prompts, but a maintainable Agent asset system.

13.5.1 From operation trajectory to four types of capability carriers

Agent runs will continuously generate trajectories, tool results, user corrections, and evaluation signals. Experience can only form system capabilities after it changes subsequent behavior and is verified. According to the nature of expression, updates can fall into four types of carriers: facts, experiences, and exceptions are written into knowledge; verbalizable judgment principles are written into Prompt or Skill; deterministic processes and hard constraints are written into programs, tools, Hooks, or workflows; only perceptions and strategies that are difficult to express explicitly are considered to be entered into model parameters through supervised fine-tuning, distillation, or reinforcement learning.

The four types of carriers are not a one-way ladder from low to high. External knowledge is easiest to update and audit, and programs are most suitable for strong verification and reuse. Parameter internalization can reduce the burden of inference, but the update cost and rollback are the most difficult. Organizations should give priority to carriers that can be traced, partially modified, and automatically verified. Only capabilities that are stable and repetitive and difficult to carry by external rules will enter post-training.

13.5.2 Online execution and offline evolution must be separated

The stable version Agent in production is responsible for processing tasks and recording evidence, and should not directly rewrite its core rules after an unverified feedback. The offline evolution cycle is responsible for aggregating trajectories, finding common root causes, generating candidate updates, running target regression and security evaluation, and then promoting to a new stable version through versioning, grayscale, monitoring and rollback.

The roots of trust—permission policies, audits, validators, and rollback mechanisms—cannot be lifted by ordinary evolution processes on their own. Candidate knowledge must be marked with sources and applicable boundaries, candidate Prompts or Skills must be tested for sensitivity and conflict, candidate programs must undergo code review and CI, and model updates must check for degradation of old capabilities. The goal of continuous evolution is not to allow the Agent to modify itself infinitely, but to transform real experience into a controlled software release cycle.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

13.6 Indicators and Operational Rhythm

Look at task volume, success, manual intervention and exceptions weekly; look at quality, rework, cost, privilege escalation and extended health monthly; review asset usage, expiration rules, supply chain and scenario benefits quarterly. Metrics should be stratified by task type and risk to avoid averages masking high-risk failures.

Operations meetings should spot-check actual trajectories and deliveries, not just dashboards. Categorize the root causes of failures and identify whether improvements fall on task specifications, models, tools, environments, rules, or organizational processes.

Agent needs to be continuously operated like a software service, rather than no longer maintained after being online.

13.7 People Capabilities and Change Management

The focus of training should not stop at “how to write prompts” but rather teach employees to define delivery, provide context, set boundaries, review evidence, identify uncertainty, and handle permission requests. The knowledge of domain experts determines whether the Agent can make the right choice.

Establish shared cases, office hours, internal support, and safe experimentation spaces to make success stories an asset. Managers should allow small-scale failures and require transparent reviews to prevent employees from hiding Agent use because they are worried about accountability.

Agent amplifies domain capabilities and also amplifies the importance of task definition and judgment capabilities.

13.8 Scale model: platformization, federal governance and continuous optimization

  1. Establish terminology consensus: Agent is a system, not a model, nor does it mean complete autonomy.

  2. Choose two to three real tasks that are verifiable and rollable for piloting, and avoid just watching demonstrations.

  3. Turn the task statement, verification evidence and stopping conditions into unified work specifications.

  4. Consolidate stable experience into project instructions, Skills, and Hooks instead of relying on personal prompts.

  5. Establish governance baselines for extension sources, sandboxes, approvals, networks, credentials, and background tasks.

Final judgment | The most important ability of an agent is not “how much it can do on its own”, but whether it can continue to produce verifiable results in uncertain tasks and reliably return control to humans at high-risk nodes.

The central platform provides identities, models, environments, logs, reviews, asset catalogs, and managed configurations; business teams have scenarios, rules, and acceptance; security legal affairs provide bottom lines and exception reviews. This federated model avoids duplication of construction by each team and retains domain adaptation.

Scaling does not mean unifying into a super agent. A more reliable direction is to have multiple task systems with clear boundaries, sharing infrastructure and governance. The platform continuously optimizes models, tools and assets through metrics and feedback.

Unifying infrastructure and decentralizing scene ownership is a robust structure for organizational-level agents.

14. Trends, Conclusions and Action Proposals

Agent competition is shifting from single model capabilities to complete system capabilities, and interaction methods are also shifting from short sessions to continuous tasks and digital colleagues.

Multimodality, tool protocols, security governance and organizational knowledge assets will jointly determine the speed of development in the next stage, and the final evaluation criterion will still be whether it can continue to deliver verifiable results.

14.1 Competition shifts from model capabilities to complete system capabilities

The key change in the era of agents is that models gain tools, memory, runtime and governance. The model determines the upper limit of understanding and reasoning, the tool determines what can be done, the memory determines whether the direction can be maintained across steps and sessions, the runtime determines whether the plan can be implemented, and the security mechanism determines how far the system is allowed to enter.

OpenClaw and Hermes show the runtime path of personal agents, and Claude Code and Codex show the paths of engineering agents. All four are converging on memory, skills, plug-ins, delegation, background tasks and permission management, indicating that future differentiation will come more from system integration, reliability and ecology, not just the underlying model.

Models are still an important factor in the upper limit of agents, but the real difference increasingly comes from tool quality, context loading, environment reproduction, feedback loops, extended ecology, parallel organization, and authority governance. Models iterate quickly, and system assets and organizational processes determine whether capabilities can be continuously converted into work results.

The leading Agent products of the future will be more like reliable operating systems than more fancy chat interfaces.

14.1.1 The model will absorb Harness, but will not destroy Harness

Model advancement will gradually internalize capabilities such as format compliance, basic tool selection, and error recovery, reducing some explicit orchestration; at the same time, Harness will move to new frontiers, assuming dynamic business knowledge, identity permissions, long-term status, asynchronous events, real environment verification, and organizational responsibilities. The two form a co-evolution: the running system generates trajectories and evaluations, promoting model and external asset updates; stronger models enable Harness to organize more open tasks.

Therefore, long-term construction should not bet on a certain set of temporary prompts, nor should it be assumed that changing models will automatically solve system problems. Unique data, tool interfaces, evaluation sets, user trust, channels and recoverable business processes should be precipitated as assets outside the model. No matter how the underlying model changes, “what you see, what you can do, and how to verify” are still the three most stable main lines of the Agent project.

Data basis: Relevant chapters of Li Bojie’s “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”.

14.2 Interactions shift from conversations to ongoing tasks with digital colleagues

Instead of just asking questions in one window, users can start tasks, view status, approve key actions, and receive delivery across projects, messages, IDEs, and cloud environments. Agents increasingly have persistent goals and restorable states, but digital colleagues still require job boundaries, work disciplines, and supervision.

What continues to change is the way collaboration is done, while increasing accountability and governance requirements.

14.3 Skills, Plugins and tool protocols become the capability distribution layer

Model capabilities will spread rapidly, and organizational differentiation will come more from own skills, tool interfaces, evaluation sets, and project rules. Plugins and marketplaces reduce distribution costs, but also introduce supply chain, naming conflicts, context costs, and permission expansion.

In the Agent era, organizational knowledge will exist more in the form of executable and measurable assets.

14.4 Multimodality and Computer Use expand working objects

Agents can work across web pages, desktops, documents, forms, presentations, images and voice, and more processes without APIs can be automated. However, interface operations are more fragile than APIs and are easily affected by layout changes, prompt injection, and identity status. Visual verification, action confirmation, and rollback must be strengthened.

After the action radius is expanded, verification and isolation must be upgraded simultaneously.

14.5 Security and governance will become product capabilities

When multiple products can call on tools and work in parallel, organizations will pay more attention to who can define boundaries, how to automate low-risk steps, when to escalate approvals, how to limit expansion, and how to view traces and recover. Rather than hindering adoption, governance is the foundation for reducing approval fatigue and supporting greater autonomy.

True scalable autonomy is built on enforceable boundaries and traceable evidence.

14.6 Answer three questions: system, task and method

What is an agent? It is a system that selects steps around goals within permission boundaries, invokes tools, maintains state, and corrects based on feedback. What can an agent do? It is suitable for complex, cross-tool tasks that require intermediate judgment and verifiable results, especially research, software engineering, data and business collaboration.

How to use the agent? Start with real but recoverable small tasks, use task descriptions to clarify goals and boundaries, write verification into completion standards, run with minimum permissions, accumulate rules, skills and tests, and then gradually enter parallelism, background and organizational scale.

The four products show two routes and common convergence: OpenClaw and Hermes emphasize resident, channel and long-term learning, Claude Code and Codex emphasize engineering closed loop and environmental organization; they all ultimately answer status, reuse, action and governance.

Main line conclusion: from model to system, from answer to task, from demonstration to verifiable operation.

Appendix A: Agent task specification template

This template converts natural language requests into delegated tasks. When using, fill in the goals and acceptance first, and then decide on the tools and degree of autonomy; do not open permissions first and then look for use cases.

Field What to write Example
Goals Problems to be solved Complete special report
Deliverables Files, formats, audiences 80+ page Word report
Scope Inclusions and Exclusions Four Products, Focus on CC/Codex
Constraints Time, tools, sources, style Official information is preferred
Validation How to judge completion Number of pages, table of contents, rendering checks
Permissions Allow/Require confirmation/Prohibit Read-only search; write local files
Failure handling When to retry or upgrade Marking when sources conflict
  1. Background and goals | Why to do it; what state to change; what is the relationship with upstream/downstream tasks.

  2. Deliverables|File, format, quantity, audience, location, deadline and version requirements.

  3. Scope | Systems that must be included, can be included, explicitly excluded, and cannot be touched.

  4. Inputs and Sources | Available data, trusted sources, version dates, and citation requirements.

  5. Tools and Permissions | Tools and actions that are allowed to be used automatically, require approval, or are completely prohibited.

  6. Acceptance criteria | Correctness, completeness, format, performance, security and manual review criteria.

  7. Failure and escalation|Maximum retries, timeouts, conflicts, insufficient permissions and conditions requiring human decision-making.

  8. Handover|Completion summary, evidence, unfinished items, risks, rollbacks and follow-up responsible persons.

Appendix B: Engineering Agent Task Acceptance Checklist

The acceptance of engineering agents should not only look at the final answer or code differences, but also check whether the process evidence is sufficient to reproduce. The following checklist can be used for task creation, review and handover. The team can be tailored according to risk level, but the responsible person and rollback conditions should not be omitted.

When using it, first confirm the task scope, environment and permissions, then check the changes and verification, and finally check the security and handover. If an item cannot be confirmed, it should be clearly recorded as an unverified fact rather than using model judgments as a substitute for evidence.

For repetitive tasks, the stable checks in the list can be solidified into scripts, hooks, or continuous integration access control; projects that require business judgment should still retain manual signatures or approvals.

Task and Scope

  • □ The goals, scope and do’s and don’ts have been clearly written down

  • □ repository rules and dependency constraints have been loaded

  • □ Baseline problems can be reproduced

  • □ High-impact design decisions confirmed

Change quality

  • □ diff is directly related to the task

  • □ No extraneous formatting or extensive rewriting

  • □ Error handling and boundary conditions covered

  • □ Public interface, data structure and compatibility impact have been explained

Verify

  • □ Targeted test passed

  • □ Relevant complete tests passed

  • □ Static check, type check or build pass

  • □ Failure log is not hidden

  • □ Conducted real readback or interface rendering when necessary

Security

  • □ No keys and sensitive data are introduced

  • □ Newly added dependency sources, licenses and versions have been checked

  • □ Command, network and file permissions are consistent with the scope of the task

  • □ External input does not directly become a high-privilege command

Transfer

  • □ Complete summary and document list accurately

  • □ Test commands and results are reproducible

  • □ Residual risks, limitations and follow-up items are clearly defined

  • □ Submission/PR instructions for easy review

  • □ There is a feasible rollback path

Appendix C: Agent Security and Governance Checklist

Object Inspection Questions Suggested Evidence/Controls
Targets Are there range drifts or hidden targets? Task description, stopping conditions
Input Can untrusted content affect system commands? Content isolation, source tags
Data Is personal, trade secret or regulated data processed? Classification, desensitization, residence
Identity Whose identity is used to execute? Dedicated identities, short-lived credentials
Permissions Minimized to what is required for the task? Whitelist, read-only priority
Tools Are parameters, errors, and side effects clear? Contract, test, readback
Network What domain names and downloads can be accessed? Domain name restrictions, malicious file checks
Memory Can content be viewed, corrected, expired, and deleted? Version, source, life cycle
Extension Where do MCP, Skills, and Plugins come from? Signed, reviewed, locked version
Approval Which actions must be decided by humans? Risk classification, two-person control
Audit Can every step and every authorization be restored? Logs, evidence, association ID
Recovery How to stop, rollback and notify after failure? Circuit breaker, backup, emergency procedures

Appendix D: Agent Evaluation Scale and Pilot Record

The four records below are examples of filling in, one for each product. They are only used to illustrate the recording method and do not represent the actual evaluation conclusion of any product.

Dimensions 1 point 2 points 3 points 4 points 5 points
Task successful Not delivered Partially delivered Basically completed Completely passed Stable one pass
Correctness Major errors Many errors Correctable Minor flaws Sufficient evidence
Efficiency Significantly slower No gain Slight gain Significant savings Reproducible at scale
Robustness No recovery in case of failure Frequent takeover required Can be restored at prompts Most automatic recovery Stable exception handling
Security unauthorized access/Leakage Inadequate Controls Basic Compliance Complete Controls Proactively Minimize Risks
Auditability Unexplainable Insufficient evidence Readable process Complete evidence Easy to reproduce and audit
Task ID Task Type System/Version Success Man Minutes Failure Type Evidence Link
OC-01 Multi-Channel Read Only OpenClaw Success 8 None Logs, Sources
HE-01 Memory Retrieval Hermes Success 10 None Memory Snapshot
CC-01 Patches and Tests Claude Code Success 20 None diff, test
CX-01 Worktree Parallel Codex Success 16 None Tasks, diff

Appendix E: Glossary of core terms

Terminology Meaning in this report
Agent A constrained system that selects steps around a goal, uses tools, maintains state, and corrects based on feedback.
Agentic The autonomous choice and action characteristics of an intelligent form.
Tool A structured interface for an agent to read or change the external environment.
Tool calling A mechanism for model selection tools and generating structured parameters.
Runtime / Runtime The system that hosts execution, state, scheduling, isolation, and recovery.
Context / Context The information window of the current task that can be read directly by the model.
Memory State, facts, and experiences saved across steps or sessions.
Skill / Skill On-demand loading, reusable and testable task methods and resource packages.
MCP An open protocol and ecosystem for connecting models and external tools/data.
Hook / Hook A rule or procedure that executes deterministically on specific lifecycle events.
Plugin Extension unit that packages skills, connectors, and configurations for distribution.
Subagent / Subagent A specialized executor with an independent context that is delegated by the main agent.
Agent team Multiple independent agent sessions collaborate by sharing tasks and messages.
Orchestration Mechanisms for decomposing, dispatching, coordinating, aggregating, and handling failures.
Sandbox / Sandbox Execution boundaries that restrict file, network, process, or system access.
Approval Controls that request explicit human authorization before high-risk actions.
Least privilege / Least privilege Grant only the minimum privileges required to complete the current task.
Worktree / Working tree Isolated checkout that shares Git metadata but has a separate working directory.
Prompt injection / Prompt injection External content attempts to change system objectives or induce unauthorized attacks.
Evals / Evaluations Measure quality, efficiency, safety and robustness with repeatable tasks and metrics.
Human-in-the-loop Validation, approval or judgment at the human control point.
Observability / Observability Understand the running status of the system through logs, traces and indicators.
Rollback / Rollback Restore erroneous actions to a known safe state.
Handoff Handover task status, evidence, risks and next steps to humans or other agents.
Definition of Done Pre-agreed completion and acceptance conditions.

Appendix F: References and Further Reading

The following information provides calibration concepts, product capabilities and practical recommendations. Product capabilities change rapidly, so you should double-check official documentation, change logs, pricing, platform scope, and security policies before implementation.

  1. Li Bojie. “In-depth Understanding of AI Agent: Design Principles and Engineering Practice”. Chinese version, 2026. https://github.com/bojieli/ai-agent-book

  2. OpenAI. A practical guide to building agents. https://openai.com/business/guides-and-resources/a-practical-guide-to-building-ai-agents/

  3. OpenAI Developers. Codex documentation. https://developers.openai.com/codex/

  4. OpenAI. AGENTS.md. https://developers.openai.com/codex/guides/agents-md/

  5. OpenAI. Git worktrees. https://developers.openai.com/codex/app/worktrees/

  6. OpenAI. Sandboxing and approvals. https://developers.openai.com/codex/security/

  7. Anthropic. Claude Code overview. https://code.claude.com/docs/en/overview

  8. Anthropic. Claude Code features overview. https://code.claude.com/docs/en/features-overview

  9. Anthropic. Claude Code security. https://code.claude.com/docs/en/security

  10. Anthropic. Building effective agents. https://www.anthropic.com/research/building-effective-agents

  11. OpenClaw. Documentation overview. https://docs.openclaw.ai/

  12. OpenClaw. Tools, Skills and Plugins overview. https://docs.openclaw.ai/tools/

  13. OpenClaw. Gateway security and trust model. https://docs.openclaw.ai/gateway/security/

  14. Hermes Agent. Official documentation. https://hermes-agent.nousresearch.com/docs/

  15. Nous Research. Hermes Agent product page. https://nousresearch.net/hermes-agent/

  16. NousResearch/hermes-agent. Releases. https://github.com/NousResearch/hermes-agent/releases

  17. User provided: “Claude Code Complete Tutorial”. https://my.feishu.cn/wiki/Takxwov60iO5OOkOmpEcpOGynac

  18. User provided: “Codex Complete Solution”. https://my.feishu.cn/wiki/OCY5wzbGhiLDr8kMulkcLLuSnQd

  19. Microsoft Research. AutoGen and multi-agent research materials. https://www.microsoft.com/en-us/research/project/autogen/

  20. NIST. AI Risk Management Framework. https://www.nist.gov/itl/ai-risk-management-framework

  21. OpenAI. File search. https://developers.openai.com/api/docs/guides/tools-file-search/

  22. OpenAI. Model Context Protocol. https://developers.openai.com/codex/mcp/

  23. OpenAI. Hooks. https://developers.openai.com/codex/hooks/

  24. OpenAI. Build an MCP server. https://developers.openai.com/plugins/build/mcp-server/

Translation note: This article uses machine translation. If you notice any errors or ambiguities, please refer to the original Chinese text.