Abysstree渊林
Back to notes返回笔记

Article文章 / 2026-08-28

Understanding AI Agents in Depth:
From Principles to Engineering Practice and Case Studies
深入理解AI Agent:从原理到工程实践及案例分析

An in-depth guide to AI agent principles, context, memory, tools, harness engineering, evaluation, multi-agent systems, and representative engineering case studies.从 Agent 基本范式、Context、Memory、Tools 与 Harness Engineering 出发,系统讨论评估、多 Agent 协作及 OpenClaw、Hermes、Codex、Claude Code 的工程实践。

摘要

随着大语言模型(Large Language Model, LLM)能力持续提升,人工智能系统正在从以问答为中心的 Chatbot 逐步演化为能够持续感知环境、调用工具、维护状态并完成复杂任务的 AI Agent。与传统对话系统相比,Agent 的核心变化并不只是“模型会不会调用工具”,而是模型被置于一个具有上下文、记忆、工具、权限、反馈与恢复机制的运行环境中,并通过持续的观察—决策—行动循环完成任务。因此,理解 Agent 的关键,不应停留在 Prompt Engineering 或单一模型能力层面,而应从系统工程角度讨论模型与 Context、Tools、Memory、Evaluation 及 Harness 之间的关系。

本文基于李博杰《深入理解 AI Agent:设计原理与工程实践》的核心框架,并按照系统汇报 PPT 的内容顺序,对 AI Agent 的基本范式、上下文与记忆、工具与 Coding Agent、交互与 Harness Engineering、评估与持续进化、多 Agent 协作等内容进行系统梳理。在此基础上,进一步结合 OpenClaw、Hermes Agent、OpenAI Codex 与 Anthropic Claude Code 四类当前具有代表性的 Agent 系统,分析不同产品在长期在线、持续学习、并行工程执行和开发者控制等方面所体现出的 Harness 差异。本文认为,随着基础模型能力逐步趋同,Agent 产品之间的竞争正在从单纯的模型能力竞争转向 Context、Memory、Tool、Permission、Verification、Recovery 与 Orchestration 等系统能力的竞争,即从“模型竞争”逐步走向“Harness 竞争”。

关键词: AI Agent;大语言模型;Context Engineering;RAG;MCP;Harness Engineering;Coding Agent;Multi-Agent;OpenClaw;Hermes;Codex;Claude Code


1. AI Agent 的基本范式:从生成回答到闭环行动

传统 Chatbot 的任务通常可以被描述为“给定输入,生成一个尽可能高质量的回答”。这种系统的核心评价对象是单轮或多轮文本生成质量,而 AI Agent 的目标则明显更复杂。Agent 不仅需要理解用户意图,还必须在一个动态环境中持续获取信息、维护任务状态、选择下一步动作,并根据动作结果调整后续决策。由此,系统从“输入—输出”结构转变为“观察—推理—行动—再观察”的闭环。

从最基础的系统结构看,Agent 可以被抽象为:

Agent = LLM + Context + Tools

其中,LLM 是决策核心,负责理解、推理与规划;Context 决定模型当前能够看到什么,包括用户请求、系统指令、历史轨迹、工具结果、记忆与外部知识等;Tools 则决定模型能够对外部世界做什么,例如检索网页、执行代码、修改文件、发送消息或操作 GUI。三者并不是彼此独立的模块,而是在每一轮 Agent Loop 中共同决定行为结果。

这一循环最典型的表现形式是 ReAct,即 Reasoning + Acting。与一次性完成全部推理不同,ReAct 强调推理与行动交替进行:Agent 首先观察当前环境,做出一步决策,执行动作,然后把工具返回或环境变化重新写回 Context,再决定下一步。真实任务中的不确定性因此能够被后续观察吸收。例如在网页检索任务中,Agent 可能先搜索一个关键词,发现结果不够精确后重新组织查询,再根据新结果打开目标页面。这种闭环能力是 Agent 与传统脚本或静态对话系统之间的重要区别。

但自主性并不是越高越好。Workflow 与 Autonomous Agent 实际上构成一条连续光谱。对于固定、可审计、高风险流程,确定性的 Workflow 可能比高度自主 Agent 更可靠;只有当任务路径难以预先穷举、环境反馈频繁变化、模型需要动态规划时,更高程度的自主性才体现出优势。因此,Agent 工程的目标并不是“尽量把更多决策交给模型”,而是根据任务复杂度合理设计模型的决策边界。

从这一点也可以进一步看出:Agent 出错时,并不意味着一定要训练一个更强的模型。很多错误来自上下文缺失、状态丢失、工具设计不合理、权限配置不足或验证机制缺失。相比直接改变模型参数,优先修改 Context、Skill、Tool 或程序约束,通常更容易归因、验证和回滚。这一思想贯穿后续所有 Agent 工程设计。


2. Context、Memory 与 RAG:Agent 如何形成可持续的“观察空间”

如果说 LLM 是 Agent 的“大脑”,那么 Context 更接近 Agent 当前的“感知空间”和“工作记忆”。一次真实的 Agent 推理并不只包含用户的当前问题,还可能同时包括 System Prompt、历史对话、Tool Definitions、Tool Call、Tool Result、长期 Memory、RAG 检索结果、Skills、任务状态乃至子 Agent 返回信息。因此,Context Engineering 关注的并不是一句 Prompt 怎样措辞,而是如何在有限上下文窗口中,选择并组织当前决策真正需要的信息。

从系统角度看,Context 可以被类比为 Agent 的操作系统。任务当前执行到哪一步,类似进程状态;Tool Definitions 类似系统调用接口;Tool Results 是外部环境返回;Memory 是跨 Session 的持久状态;Skills 则相当于按需加载的能力模块。这种视角说明,Context 不应被理解为“更长的聊天记录”,而应被理解为 Agent Runtime 的核心状态管理机制。

Context 的物理组织甚至会直接影响性能成本。以 KV Cache 和 Prompt Cache 为例,Transformer 在处理重复前缀时可以复用已计算的 Key/Value 表示,从而降低延迟与算力消耗。因此,生产系统通常倾向于让稳定内容保持稳定前缀,而将变化频繁的任务状态、工具输出和临时证据放在后部。由此可见,Context Engineering 既决定模型行为,也关系到推理成本和系统吞吐。

随着 Agent 能力增多,另一个问题是上下文无法容纳所有工具、规则和知识。Skills 所体现的 Progressive Disclosure(渐进式披露)由此变得重要。一个 Skill 可以包含某类任务的说明、规则、脚本、工具和验证方式,但系统并不需要把所有 Skill 的完整内容永久放进 System Prompt。更合理的做法是先向模型提供能力目录,只有任务真正需要某项能力时再加载其详细内容。这既减少 Token 消耗,也降低模型面对过多候选能力时的选择噪声。

长任务还需要 Context Compression。与简单“让模型总结历史”不同,成熟系统会区分信息生命周期:大型日志、网页全文和一次性工具输出属于短命信息,可以裁剪或外置;阶段性决策和已尝试路径需要保留结构化摘要;真正长期有效的用户偏好、稳定结论和工作方法则应沉淀到 Memory 或 Skill。压缩的目标不是单纯缩短文本,而是在降低冗余的同时保留未来决策所需的关键状态和因果信息。

Memory 与 Knowledge Base 也是 Agent 系统中容易混淆的两个概念。Memory 主要描述“这个用户、这个 Agent 或这段长期任务过去发生过什么”,例如用户偏好、历史决策、长期任务状态和过去经验;Knowledge Base 则主要提供外部知识,例如企业文档、论文、产品数据库或网页资料。二者最终都可能进入 Context,但生命周期和治理方式并不相同:Memory 更关注身份、更新、冲突与遗忘,Knowledge Base 更关注文档切分、检索、召回、时效性与证据来源。

真正困难的 Memory Engineering 也不是“把内容存下来”,而是持续整理。一个成熟的记忆生命周期需要从证据中提取候选记忆,对其进行核验与冲突检测,然后以最小修改方式合并到已有记忆中,并保留可审查与回滚能力。例如旧记忆是“用户喜欢早上开会”,而新证据明确表示“以后不要安排早会”。如果系统只是把两条信息同时追加,未来模型会面对相互冲突的事实;成熟系统则应识别更新关系并修改原有状态。

与 Memory 相比,RAG(Retrieval-Augmented Generation,检索增强生成)解决的是外部知识如何在任务发生时进入 Context。其基本过程可以概括为 Retrieve、Augment 与 Generate:先检索与当前问题相关的证据,再将证据加入当前上下文,最后让模型基于这些材料生成结果。RAG 的价值在于,模型不必把所有知识永久写入参数,就可以使用最新信息、企业私有资料和可引用证据。

生产级 RAG 通常也不是单一向量检索。Dense Retrieval 通过 Embedding 在向量空间中寻找语义相近内容,Sparse Retrieval 或 BM25 则更擅长处理关键词、编号、专有名词和精确短语。实际系统常将两类结果融合,再使用 Re-ranker 对候选内容做更精细的相关性排序。由此可见,RAG 的关键并不只是“接入一个向量数据库”,而在于检索质量与证据治理。如果召回内容本身错误、过期或缺失,最终生成结果依然可能失败。


3. Tools、MCP 与 Coding Agent:从语言生成到真实执行

只有 Context,Agent 仍然只是“看得更清楚”;只有引入 Tools,模型才能真正改变外部环境。Tool Calling 的本质,是让模型从自然语言建议转变为结构化行动。模型不再只是说“我建议搜索天气”,而是明确输出工具名称以及符合 Schema 的参数,由系统执行后再把 Tool Result 写回 Context。由此,语言模型与确定性软件接口被连接起来。

一个可靠工具需要具备清晰的名称与描述、明确的参数类型、合理的权限边界、可理解的错误语义以及尽量可验证的返回结果。如果工具说明模糊、参数复杂或权限无限开放,即使模型很强,也容易产生错误选择或危险调用。因此 Tool Design 本身就是 Agent Harness 的一部分。

MCP(Model Context Protocol,模型上下文协议)进一步解决了工具和资源怎样标准化接入的问题。它的价值类似于为 Agent 提供统一“插口”:外部服务可以按照相同协议暴露工具、资源或上下文,不同 Agent 客户端可以更容易复用这些能力。MCP 并不会让模型本身更聪明,也不直接解决“应该调用哪个工具”或“调用结果是否可信”,它主要降低的是不同工具与 Agent 之间的工程适配成本。

当工具数量从几十个扩展到几百甚至上千个时,又会出现新的 Context 问题。把全部工具 Schema 一次性暴露给模型,会增加 Token 消耗并扩大错误选择空间,因此生产系统往往引入 Tool Discovery:先通过类别、索引或搜索找到少量候选工具,再将这些候选的完整定义动态加载进上下文。这与 Skills 的渐进式披露本质上属于同一种系统设计思想。

在各种 Agent 类型中,Coding Agent 尤其值得关注,因为代码并不只是一种普通工具,而是一种“能够创造新工具的元工具”。Coding Agent 可以读取仓库、搜索相关代码、修改文件、运行测试、读取错误并再次修订,从而形成高度可验证的闭环。软件工程几十年来已经建立了编译器、类型系统、单元测试、CI、lint、Runtime Error、Git diff 和 Pull Request Review 等大量反馈机制,这些机制天然适合 Agent 使用。

这也是 Coding Agent 相对成熟的重要原因。它并不依赖“一次写对”,而是依赖环境不断告诉它“刚才做得对不对”。当 Agent 可以在 Sandbox 中安全执行自己生成的脚本,并将经过验证的程序封装成新的 Tool 或 Skill 时,甚至可以实现一定程度的 Self-bootstrapping:遇到新的任务类型时,自行搜索现有能力或编写脚本,再把成功方法沉淀下来。由此,很多通用 Agent 最终都逐渐表现出“Coding Agent + Sandbox + Tools”的系统形态。


4. 从 Interaction 到 Harness Engineering:生产级 Agent 的真正核心

当 Agent 从聊天窗口进入真实环境后,它不再只是同步响应用户输入,而逐渐成为一个事件驱动系统。任务可以由用户消息、Email、Webhook、Cron 定时器、系统告警甚至其他 Agent 触发;任务也可能被暂停、恢复、并行执行或在后台持续运行。此时,状态管理、事件去重、并发控制与恢复机制的重要性迅速上升,Agent 工程开始与传统分布式系统和 Workflow Engine 产生明显交叉。

多模态交互进一步放大了这种系统复杂度。实时语音 Agent 往往需要经过 VAD(Voice Activity Detection)、ASR(Automatic Speech Recognition)、LLM 与 TTS(Text-to-Speech)等多个环节。真实体验的瓶颈往往不是单一模型效果,而是端到端延迟,因此流式处理、并行、用户打断和快慢思考分层比单纯提高模型精度更重要。

Computer Use 则把 Agent 的 Observation Space 和 Action Space 扩展到 GUI。模型可以通过截图、DOM 或其他结构化界面信息感知页面,再执行点击、输入、滚动和快捷键等动作。然而,“能够点击”远不等于“能够稳定、安全地完成操作”。页面布局变化、弹窗、登录状态、权限确认和不可逆操作都会制造新的失败模式。因此,GUI Agent 特别能说明:真正的产品壁垒往往不是模型是否具备某项能力,而是系统能否控制、验证和恢复这种能力。

由此,Agent 工程的认识逐渐从 Prompt Engineering 发展到 Context Engineering,再进一步演化为 Harness Engineering。可以用一个包含关系概括:

Prompt ⊂ Context ⊂ Harness

Prompt Engineering 关注如何给模型指令;Context Engineering 关注模型当前能看到什么;Harness Engineering 则关注模型周围整个运行系统如何工作。Harness 通常包括 Context、Memory、Tools、Cache、Permission、Sandbox、Validation、Error Recovery、State Management、Parallelism、Observability 和 Safety。

因此,生产级 Agent 更适合用下面的公式理解:

Agent = Model × Harness

这里的“乘法”强调的是短板效应。模型很强但 Harness 很弱,系统可能“聪明但失控”;Harness 很完善但模型缺乏理解和推理能力,系统则“稳定但做不成复杂任务”。同一个基础模型放进不同 Harness 中,最终体验可能完全不同,这也是现代 Agent 产品差异越来越明显的根本原因之一。

可靠 Harness 至少需要覆盖三个阶段。第一是行动前的 Constraint,例如最小权限、工具白名单、Fail-closed、Sandbox 和高风险操作确认;第二是行动后的 Verification,例如 Schema 校验、自动测试、Validator、Policy Checker、Hook 或独立 Reviewer;第三是失败后的 Recovery,例如 Retry、Backoff、Circuit Breaker、Model Fallback、Checkpoint、State Rollback 和 Human Takeover。安全与可靠性因此不是最后附加的“保护层”,而是整个 Agent 生命周期中的系统属性。


5. Evaluation、持续进化与 Multi-Agent:Agent 如何真正变强

如果一个 Agent 系统无法被稳定评估,就无法判断改动究竟让它变好还是变坏。与传统模型评测相比,Agent Evaluation 需要同时考虑结果、过程和系统三层。Result-level 关注任务是否最终完成;Trajectory-level 关注整个执行轨迹是否合理以及首个错误发生在哪里;System-level 则进一步关注成本、延迟、鲁棒性和安全性。

Pass@k 是 Agent 评估中常见指标,它表示允许模型独立尝试 k 次,只要其中一次成功,就说明该任务在某种意义上“具备可解能力”。但生产环境真正关心的是一次成功和连续成功。一个单步成功率看似很高的 Agent,在长链任务中可能由于误差累积而快速降低整体成功率。因此,单轮能力上限与业务可靠性必须区分。

LLM-as-a-Judge 是当前常见的自动评估方式,即使用另一个 LLM 根据预先定义的 Rubric 对结果或轨迹评分。但比最终分数更重要的是 Failure Attribution,即失败归因:第一处错误到底发生在 Context、RAG、Tool、Reasoning、Verification 还是 Recovery。只有定位错误机制,工程团队才能知道应该修改哪一层,而不是凭感觉“换一个更强模型”。

成熟 Agent 开发应形成类似科学实验的闭环:从 Benchmark 或线上日志中观察失败,提出机制假设,通过 Ablation、A/B Test 或 Feature Flag 验证改动,再将历史关键失败加入 Regression Set。换言之,Agent Engineering 不应该依赖“感觉它更聪明了”,而应依赖可重复、可证伪的实验。

当错误确实来自模型本身时,才需要进一步考虑训练。Mid-training 更适合解决底座模型知识或能力分布不足;SFT(Supervised Fine-Tuning)适合解决模型“会做但行为协议不稳定”的问题;RL(Reinforcement Learning)则更适合在多个可行策略之间,通过奖励信号提高优秀行为出现概率。并不是所有 Agent 问题都值得上 RL,很多问题通过修改 Context、Skill、Tool、Hook 或程序规则反而更容易控制。

这也引出持续进化问题。Context Learning 并不等于 Persistent Learning。如果 Agent 今天完成了一万次任务,但经验没有写回任何长期载体,那么明天的新 Session 仍可能重复旧错误。经验可以被写入 Knowledge、Instruction / Skill、Program 或 Model Parameters。工程上通常应该优先修改更外层、可审查和可回滚的机制。例如如果 Agent 经常忘记在部署前运行测试,加入一个强制 Hook 往往比重新训练模型更合理。

Multi-Agent 则进一步扩展了系统的并行性和专业化能力,但它也不是“Agent 越多越强”。第二个 Agent 真正有价值的前提,是它带来了新的信息、工具、权限、专业能力或真实并行性。如果多个 Agent 使用相同模型、相同 Context 和相似 Prompt,它们的错误往往高度相关,多数投票并不一定带来真正独立的判断。因此,Multi-Agent 的核心价值应被理解为异质能力与职责分工,而不是数量本身。


6. 热门 Agent 的工程实践:OpenClaw、Hermes、Codex 与 Claude Code

在前述理论框架下,OpenClaw、Hermes Agent、Codex 和 Claude Code 可以被视为四种不同的 Harness 实现路线。它们经常被统一归类为“热门 Agent”,但从系统定位看并不完全同质。OpenClaw 更强调 Agent 的长期存在与跨渠道接入,Hermes 更强调长期 Memory 与 Skill 的学习闭环,Codex 更强调多 Agent 并行工程执行与任务编排,Claude Code 则更强调开发者对 Harness 的可编程控制。

6.1 OpenClaw:Channel-first 的常驻个人 Agent

OpenClaw 的核心可以被理解为一个 self-hosted Gateway。Telegram、WhatsApp、Slack、Discord、WebChat 等不同渠道首先连接到 Gateway,再由 Gateway 管理 Session、Routing、Memory、Tools、Skills、Cron、Webhook 等长期状态,并将需要推理的部分交给模型。相比典型 Coding Agent,OpenClaw 更关注“Agent 是否一直在那里”,因此更接近 Personal Agent Infrastructure。

这一特点在长期任务中尤其明显。OpenClaw 官方 Showcase 收录过一个社区案例:Agent 通过 Email 与多个汽车经销商持续议价,社区作者报告最终节省了 4200 美元。这个数字属于用户自述,不应被理解为独立 Benchmark;更值得关注的是任务结构本身。Agent 需要长期读取多个邮件线程,维护不同报价和条件,根据新反馈调整策略,并在关键决策点把控制权交回用户。与一次性 Chatbot 相比,这种任务真正依赖的是跨时间状态、异步事件和持续存在。

因此,OpenClaw 最适合用 Channel-first 来概括。它扩展的不是单次推理能力,而是 Agent 的“存在空间”:Agent 可以持续存在于多个设备、消息平台和自动化工作流之间。

6.2 Hermes Agent:Learning-first 的持续学习 Agent

Nous Research 将 Hermes Agent 定位为 self-improving agent。这里的“自我改进”目前更适合从 Harness 层理解,即通过 Persistent Memory 与 Skills 把过去经验持续写回系统,而不一定意味着模型参数在运行中不断在线训练。

Hermes 可以把事实、偏好和历史经验保存到长期 Memory,把“某类任务应该怎样完成”的操作过程沉淀为 Skill。一次任务结束后,纠错结果可以更新 Memory,稳定工作方法可以创建或修改 Skill,后续任务再复用这些能力。配合 Cron、Subagents、Bot Mode、MCP 和长期运行环境,Hermes 形成了明显的 Learning Loop。

Hermes 官方 User Stories 中,Nous Research 的 Teknium 描述过每天并行运行 12 个 Hermes 实例,用于 Hermes 自身开发、后端基础设施调查以及 RL Environment、Benchmark 和 Dataset 等工作。这里真正重要的并不是“12”这个数字,而是多个长期 Agent 实例承担不同角色,同时持续保留自己的经验和状态。Hermes 因此更接近一种 Learning-first 的 Persistent Agent Harness。

6.3 Codex:Orchestration-first 的工程执行平台

Codex 最初最容易被理解为 Coding Agent,但到 2026 年,其产品形态已经明显向多 Agent 工程执行和任务编排扩展。当前 Codex 可以通过 ChatGPT、IDE、CLI 与 Cloud Environment 等入口协同工作,并通过 Worktree 与云端沙箱让多个 Agent 同时处理 Feature、Bugfix、Refactor 或 Research 等不同任务。

Git Worktree 在这里尤其重要,因为它允许同一个 Repository 同时存在多个相互独立的工作目录。Agent A 可以处理一个 Feature,Agent B 同时修复 Bug,而不会直接污染彼此 Git 状态。由此,软件开发中的基本协作单位逐渐从“一个开发者和一个 AI Pair”转变为“一个开发者监督多个并行 Agent 工作线程”。

OpenAI 在 Harness Engineering 案例中披露过一个 Agent-first 工程实验:从空 Git Repository 开始,在约五个月内形成约 100 万行代码和约 1500 个 Pull Request,最初由 3 名工程师驱动 Codex,之后扩展至 7 人。团队还给出内部估计,认为整个工程耗时约为手工编码的十分之一。由于这些数字来自 OpenAI 自身实验,不应直接外推为普遍生产力 Benchmark。

这个案例更重要的结论是工程角色的改变。开发者越来越多地负责设计 Agent-friendly Repository、任务说明、测试、CI、AGENTS.md、Skills、Observability 和自动 Review,而 Agent 负责具体实现。OpenAI 将这一关系概括为:Humans steer. Agents execute. 这也是 Codex 被概括为 Orchestration-first 的原因:其核心不仅是写代码,而是如何组织多个 Agent 稳定推进工程任务。

6.4 Claude Code:Harness-first 的开发者 Agent

Claude Code 的路线与 Codex有所不同。它同样具备强大的 Coding 能力,但 Anthropic 更强调开发者如何精细控制 Agent。CLAUDE.md、Rules、Skills、Subagents、Hooks、MCP 与 Plugins 等机制,共同构成了一个高度可编程的 Developer Harness。

其中 CLAUDE.md 是非常典型的长期项目级 Context。开发者可以在其中记录项目架构、编码规范、测试命令、禁止事项和团队约定,使 Agent 每次进入项目时都能够获得稳定背景。Hooks 则进一步把某些软约束变成确定性的程序机制。例如,“提交前必须运行测试”如果只写进 Prompt,模型仍可能忘记;如果通过 Hook 在提交前自动执行测试,就不再依赖模型是否记得这一条规则。

Anthropic Data Infrastructure 团队披露过一个 Kubernetes 故障排查案例:集群停止调度 Pod 后,Claude Code 结合 Dashboard 截图、Google Cloud 界面、文档与命令逐步排查,最终定位到 Pod IP 地址耗尽,并给出创建新 IP Pool、接入集群的修复步骤。这个案例说明 Claude Code 已经不只是代码编辑器中的补全工具,而是能够把截图、网页、Shell 和云端系统统一放入同一条 Agent Trajectory 中。其真正难点依然是 Harness:哪些操作可以自动执行,哪些需要确认,结果如何验证,出现错误后怎样停止与恢复。

因此,Claude Code 最适合用 Harness-first 概括。其价值在于将大量 Agent 控制点直接暴露给开发者,使模型行为可以被规则、Hooks、Subagents 与外部工具共同约束。


7. 四种 Agent 的横向比较与工程选型

从产品形态看,OpenClaw、Hermes、Codex 与 Claude Code 都具备 Model、Context 与 Tools,但它们围绕任务生命周期做出了不同权衡。

维度 OpenClaw Hermes Agent Codex Claude Code
核心定位 常驻个人 Agent Gateway 持续学习型通用 Agent 多 Agent 工程执行平台 可编程开发者 Harness
主要路线 Channel-first Learning-first Orchestration-first Harness-first
主要入口 消息平台 / Web / CLI Desktop / CLI / Bots / 消息平台 ChatGPT / IDE / CLI / Cloud Terminal / IDE / Desktop / Web
长期 Memory 核心能力 已逐渐融入长期工作流 项目 Context + Memory 机制
Skills 支持 核心学习载体 支持 支持
后台与自动化 Cron / Webhook / Automation Cron / Routine Automations / Background Work Background / 外部编排
Multi-Agent Routing / Subagents Subagents / Bot Mode 核心优势 Subagents
核心优势 长期在线与多渠道 经验沉淀与持续学习 并行工程与任务编排 高度可控、可编程
典型场景 Personal Assistant Persistent / Research Agent 大型工程工作流 Developer-controlled Agent

如果目标是构建 24/7 在线、跨设备、跨聊天平台运行的个人数字助理,OpenClaw 的 Gateway 和长期 Session 更匹配;如果重点是 Memory、Skills 和长期学习闭环,Hermes 更具代表性;如果目标是大型软件工程、多任务并行和多个 Agent 之间的工作调度,Codex 更适合作为 Orchestration 平台;如果开发者希望精确控制 Agent 的 Context、规则、Hooks、Subagents 与外部工具,Claude Code 则更符合需求。

因此,工程选型不应首先问“哪个 Agent 最强”,而应先问任务的核心生命周期是什么。四种产品共同说明,同一个基础模型在不同 Harness 中,可以形成完全不同的产品能力和交互方式。


8. 结论:从模型竞争走向 Agent Systems Engineering

AI Agent 的本质并不是给大语言模型增加若干工具,而是构建一个能够持续感知、行动、验证、修正并积累经验的完整系统。从基本结构看,可以用 Agent = LLM + Context + Tools 描述其能力来源;从工程实现看,随着系统复杂度提升,更合适的认识框架是 Prompt ⊂ Context ⊂ Harness,并最终收敛到 Agent = Model × Harness

Context 决定 Agent 看见什么,Memory 和 RAG 决定信息如何跨时间和外部知识进入系统,Tools 和 MCP 决定 Agent 怎样把语言决策转化为真实动作,Coding Agent 与 Computer Use 扩展了其执行空间,而 Permission、Validation、Recovery 与 Evaluation 则决定这些能力是否真正可用于生产。持续进化和 Multi-Agent 并不是独立附加功能,而是在前述系统能力成熟之后,对时间尺度和并行尺度的进一步扩展。

OpenClaw、Hermes、Codex 和 Claude Code 分别从长期存在、持续学习、并行劳动和开发者控制四个方向展示了现代 Agent Harness 的不同形态。它们共同揭示出一个趋势:随着基础模型能力不断提高,产品之间越来越大的差异将来自模型之外的系统设计。未来值得竞争的,不只是“哪个模型更聪明”,还包括“系统让模型看到什么、允许它做什么、怎样验证它做对了、做错以后怎样恢复、经验怎样写回,以及多个 Agent 如何协作”。

因此,AI Agent 的下一阶段更适合被理解为 Agent Systems Engineering。如果说大语言模型时代的早期问题是“机器能不能通过语言表现出复杂推理能力”,那么 Agent 工程真正面对的问题是:

机器怎样在真实环境中,长期、稳定、可控地完成工作。


附录 A:高频术语与缩写

本附录用于快速查阅。正文中的关键缩写已在首次出现时给出解释,附录不改变正文的 8 章结构。

术语 / 缩写 全称与含义
AI Artificial Intelligence,人工智能
Agent 能够感知环境、维护状态、进行决策并执行动作的智能体系统
LLM Large Language Model,大语言模型
ReAct Reasoning + Acting,推理与行动交替进行的 Agent 范式
Observation Agent 从用户、工具或环境获得的新观察信息
Context 当前一次模型推理可见的全部信息,包括 Prompt、历史、工具结果、Memory、RAG 证据等
System Prompt 系统提示词,用于规定模型角色、原则、约束和高层行为
Token 模型处理文本时使用的基本离散单位
KV Cache Key-Value Cache,Transformer Attention 中 Key/Value 的缓存
Prompt Cache 对重复提示前缀进行复用的产品级缓存机制
Skill 可按需加载、可复用的 Agent 能力包,可包含说明、规则、脚本、工具和验证方式
Memory 跨会话或跨任务持续保存的用户状态、偏好、事实与经验
Knowledge Base 面向外部知识的文档、数据库或其他信息集合
RAG Retrieval-Augmented Generation,检索增强生成
Embedding 将文本、图像等内容编码为向量表示
Dense Retrieval 基于向量语义相似度的稠密检索
Sparse Retrieval 基于词项匹配的稀疏检索
BM25 经典的稀疏检索排序算法
Re-ranker 对初步召回结果进行更精细相关性重排序的模型
Tool Calling 工具调用;模型以结构化形式选择工具并生成参数
Schema 结构化字段与类型约束,用于规定工具参数或输出格式
API Application Programming Interface,应用程序编程接口
CLI Command-Line Interface,命令行接口
IDE Integrated Development Environment,集成开发环境
GUI Graphical User Interface,图形用户界面
DOM Document Object Model,文档对象模型
MCP Model Context Protocol,模型上下文协议
Sandbox 沙箱,与宿主机或生产系统隔离的执行环境
Webhook 外部系统主动向指定接口推送事件的回调机制
Cron 按时间规则触发任务的定时机制
VAD Voice Activity Detection,语音活动检测
ASR Automatic Speech Recognition,自动语音识别
TTS Text-to-Speech,文本转语音
Harness 围绕模型构建的 Context、Memory、Tools、权限、缓存、验证、恢复、状态与编排系统
Fail-closed 当系统无法确认操作是否安全时,默认拒绝而不是默认放行
Hook 在特定系统事件或工具调用前后自动触发的程序逻辑
Validator 验证器,用规则、程序或模型检查输出或动作是否符合要求
Pass@k 允许独立尝试 k 次,只要至少一次成功就视为具备完成该任务的能力
LLM-as-a-Judge 使用另一个大语言模型作为自动评审器
Rubric 预先定义的评分量表或评价准则
Benchmark 固定任务集合上的基准测试
Failure Attribution 失败归因,用于定位轨迹中首次出现关键错误的环节
Regression Set 回归测试集,用历史失败案例防止新版本重新引入旧问题
A/B Test 将不同版本分流比较实际效果的实验方法
Feature Flag 功能开关,用于独立启用或关闭某项机制
Mid-training 预训练之后、任务微调之前的中间训练阶段
SFT Supervised Fine-Tuning,监督微调
RL Reinforcement Learning,强化学习
Multi-Agent 多个 Agent 通过分工、并行、独立验证等方式协同完成任务
Subagent 被主 Agent 委派某类专门任务的子 Agent
Orchestration 编排,对多个任务、Agent、工具和执行环境进行协调管理
Gateway 网关或常驻中枢,负责连接渠道、会话、状态、工具与 Agent Runtime
VPS Virtual Private Server,虚拟专用服务器
Worktree Git 的多工作目录机制,可支持多个 Agent 对同一仓库并行工作
PR Pull Request,代码变更审查与合并请求
CI Continuous Integration,持续集成
AGENTS.md 面向 Coding Agent 的仓库级规则与工作说明文件
CLAUDE.md Claude Code 自动读取的项目级上下文与规则文件
Provider 模型或服务提供方

参考资料

  1. 李博杰,《深入理解 AI Agent:设计原理与工程实践 / AI Agents in Depth》。
  2. OpenClaw Documentation: https://docs.openclaw.ai/
  3. OpenClaw Showcase: https://docs.openclaw.ai/start/showcase
  4. Hermes Agent Documentation: https://hermes-agent.nousresearch.com/docs/
  5. Hermes Agent User Stories: https://hermes-agent.nousresearch.com/docs/user-stories
  6. OpenAI Codex: https://openai.com/codex/
  7. OpenAI, Introducing the Codex app.
  8. OpenAI, Harness engineering: leveraging Codex in an agent-first world.
  9. Claude Code Documentation: https://code.claude.com/docs
  10. Anthropic, Steering Claude Code: when to use CLAUDE.md, skills, hooks, and subagents.
  11. Anthropic internal Claude Code engineering case studies.

Abstract

As Large Language Models (LLMs) continue to improve, artificial intelligence systems are gradually evolving from question-answering chatbots into AI agents capable of continuously perceiving their environments, invoking tools, maintaining state, and completing complex tasks. Compared with traditional conversational systems, the key change introduced by agents is not merely that “the model can call tools,” but that the model is placed inside an operational environment containing context, memory, tools, permissions, feedback, and recovery mechanisms, and completes tasks through a continuous observation–decision–action loop. Therefore, understanding AI agents should not stop at Prompt Engineering or the capability of a single model; it should instead examine, from a systems-engineering perspective, the relationships among the model, Context, Tools, Memory, Evaluation, and the surrounding Harness.

This report is based on the core framework of Li Bojie’s AI Agents in Depth: Design Principles and Engineering Practice, and follows the content sequence of the system presentation. It systematically reviews the basic agent paradigm, context and memory, RAG, tools and Coding Agents, interaction and Harness Engineering, evaluation and continual improvement, and Multi-Agent collaboration. On this basis, it further examines four representative contemporary agent systems—OpenClaw, Hermes Agent, OpenAI Codex, and Anthropic Claude Code—and analyzes the differences in their Harness designs with respect to persistent availability, continual learning, parallel engineering execution, and developer control. This report argues that, as base-model capabilities gradually converge, competition among agent products is shifting from pure model-capability competition toward competition in system capabilities such as Context, Memory, Tools, Permissions, Verification, Recovery, and Orchestration—that is, from “model competition” toward “Harness competition.”

Keywords: AI Agent; Large Language Model; Context Engineering; RAG; MCP; Harness Engineering; Coding Agent; Multi-Agent; OpenClaw; Hermes; Codex; Claude Code


1. The Basic Paradigm of AI Agents: From Answer Generation to Closed-loop Action

The task of a traditional chatbot can usually be described as “given an input, generate a response of the highest possible quality.” The objective of an AI agent is clearly more complex. An agent must not only understand user intent, but also continuously acquire information in a dynamic environment, maintain task state, select the next action, and adjust subsequent decisions according to the result of that action. The system therefore changes from an “input–output” structure into a closed loop of “observation–reasoning–action–observation again.”

At the most basic system level, an agent can be abstracted as:

Agent = LLM + Context + Tools

Here, the LLM is the decision core, responsible for understanding, reasoning, and planning; Context determines what the model can currently see, including user requests, system instructions, historical trajectories, tool results, memory, and external knowledge; Tools determine what the model can do to the external world, such as retrieving web pages, executing code, editing files, sending messages, or operating a GUI. These three elements are not independent modules; together they determine the behavioral outcome of each Agent Loop.

The most typical manifestation of this loop is ReAct, namely Reasoning + Acting. Unlike approaches that try to complete all reasoning in one pass, ReAct emphasizes alternation between reasoning and action: the agent first observes the current environment, makes a one-step decision, executes an action, writes the tool return or environmental change back into Context, and then decides what to do next. Uncertainty in real tasks can therefore be absorbed into later observations. In a web-retrieval task, for example, an agent may first search for a keyword, discover that the results are insufficiently precise, reformulate the query, and then open a more relevant page. This closed-loop capability is an important distinction between agents and traditional scripts or static conversational systems.

However, more autonomy is not always better. Workflow and Autonomous Agent actually form a continuum. For fixed, auditable, or high-risk processes, a deterministic Workflow may be more reliable than a highly autonomous agent; greater autonomy becomes advantageous only when task paths are difficult to enumerate in advance, environmental feedback changes frequently, and the model must plan dynamically. Therefore, the objective of agent engineering is not to “hand as many decisions as possible to the model,” but to design the model’s decision boundary appropriately according to task complexity.

This point also leads to a further conclusion: when an agent fails, it does not necessarily mean that a stronger model must be trained. Many errors arise from missing context, lost state, poor tool design, insufficient permission configuration, or missing validation mechanisms. Compared with directly changing model parameters, modifying Context, Skills, Tools, or programmatic constraints is usually easier to attribute, verify, and roll back. This principle runs through the subsequent discussion of agent engineering.


2. Context, Memory, and RAG: How Agents Form a Sustainable “Observation Space”

If the LLM is the “brain” of an agent, then Context is closer to the agent’s current “perceptual space” and “working memory.” A real agent inference call may contain far more than the user’s current question. It may simultaneously include the System Prompt, conversation history, Tool Definitions, Tool Calls, Tool Results, long-term Memory, RAG retrieval results, Skills, task state, and even information returned by subagents. Context Engineering therefore does not focus on how a single Prompt should be phrased, but on how the information truly needed for the current decision should be selected and organized within a limited context window.

From a systems perspective, Context can be compared to the operating system of an agent. The current stage of task execution resembles process state; Tool Definitions resemble system-call interfaces; Tool Results are returns from the external environment; Memory is persistent state across Sessions; Skills are capability modules loaded on demand. This perspective shows that Context should not be understood as “a longer chat history,” but as a core state-management mechanism of the Agent Runtime.

The physical organization of Context can even directly affect performance cost. Consider KV Cache and Prompt Cache: when a Transformer processes a repeated prefix, it can reuse previously computed Key/Value representations, thereby reducing latency and compute cost. Production systems therefore tend to keep stable content as a stable prefix, while placing frequently changing task state, tool output, and temporary evidence later in the sequence. Context Engineering thus affects both model behavior and inference cost and system throughput.

As agent capabilities increase, another problem appears: the context window cannot contain every tool, rule, and item of knowledge. The Progressive Disclosure embodied by Skills therefore becomes important. A Skill can contain instructions, rules, scripts, tools, and verification methods for a particular type of task, but the system does not need to place the full content of every Skill permanently into the System Prompt. A more reasonable approach is to first provide the model with a capability catalog and load the detailed content of a Skill only when the task truly requires it. This reduces Token consumption and also lowers selection noise when the model faces too many candidate capabilities.

Long tasks also require Context Compression. Unlike the simplistic approach of “asking the model to summarize the history,” mature systems distinguish between information with different lifecycles. Large logs, complete web pages, and one-time tool outputs are short-lived information that can be trimmed or externalized; intermediate decisions and previously attempted paths should be preserved as structured summaries; genuinely long-term user preferences, stable conclusions, and work methods should be distilled into Memory or Skills. The goal of compression is not merely to shorten text, but to preserve the critical state and causal information required for future decisions while reducing redundancy.

Memory and Knowledge Base are also two concepts that are easily confused in agent systems. Memory primarily describes “what has happened in the past to this user, this agent, or this long-running task,” such as user preferences, historical decisions, persistent task state, and prior experience. A Knowledge Base mainly provides external knowledge, such as enterprise documents, academic papers, product databases, or web materials. Both may eventually enter Context, but their lifecycles and governance methods differ: Memory focuses more on identity, updating, conflict, and forgetting, whereas a Knowledge Base focuses more on document segmentation, retrieval, recall, freshness, and evidence provenance.

The truly difficult part of Memory Engineering is not “storing content,” but continuously organizing it. A mature memory lifecycle must extract candidate memories from evidence, verify them and detect conflicts, merge them into existing memory with minimal modification, and preserve the ability to audit and roll back changes. For example, if the old memory says “the user likes morning meetings,” while new evidence explicitly says “do not schedule morning meetings anymore,” then simply appending both statements will expose the model to conflicting facts in future. A mature system should instead identify the update relationship and modify the existing state.

Compared with Memory, RAG (Retrieval-Augmented Generation) addresses how external knowledge enters Context at task time. Its basic process can be summarized as Retrieve, Augment, and Generate: first retrieve evidence relevant to the current question, then insert that evidence into the current context, and finally let the model generate a result based on those materials. The value of RAG is that the model does not need to permanently encode all knowledge into its parameters in order to use up-to-date information, private enterprise material, or citable evidence.

Production-grade RAG is usually not based on a single vector-retrieval mechanism. Dense Retrieval uses Embeddings to find semantically similar content in vector space, while Sparse Retrieval or BM25 is often better at handling keywords, identifiers, proper nouns, and exact phrases. In practice, systems commonly combine both types of results and then use a Re-ranker to perform more precise relevance ordering over the candidate content. This shows that the key to RAG is not merely “connecting a vector database,” but retrieval quality and evidence governance. If the retrieved content is incorrect, stale, or incomplete, the final generated result may still fail.


3. Tools, MCP, and Coding Agents: From Language Generation to Real Execution

With Context alone, the agent merely “sees more clearly”; only with Tools can the model actually change the external environment. The essence of Tool Calling is to transform the model from producing natural-language suggestions into producing structured actions. The model no longer merely says “I recommend searching the weather,” but explicitly outputs a tool name and parameters that conform to a Schema. The system executes the action and then writes the Tool Result back into Context. In this way, the language model is connected to deterministic software interfaces.

A reliable tool requires a clear name and description, explicit parameter types, appropriate permission boundaries, understandable error semantics, and results that are as verifiable as possible. If tool descriptions are vague, parameters are overly complex, or permissions are unlimited, even a strong model may make incorrect selections or unsafe calls. Tool Design itself is therefore part of the Agent Harness.

MCP (Model Context Protocol) further addresses the problem of how tools and resources can be connected in a standardized way. Its value can be compared to providing a common “socket” for agents: external services can expose tools, resources, or context through the same protocol, allowing different agent clients to reuse these capabilities more easily. MCP does not make the model itself smarter, nor does it directly solve questions such as “which tool should be called” or “whether the result is trustworthy.” Its primary contribution is reducing engineering adaptation costs between different tools and agents.

When the number of tools scales from dozens to hundreds or even thousands, a new Context problem appears. Exposing every tool Schema to the model at once increases Token consumption and enlarges the space of incorrect choices, so production systems often introduce Tool Discovery: first identify a small number of candidate tools through categories, indexes, or search, and only then dynamically load the complete definitions of those candidates into the context. This is essentially the same system-design principle as the progressive disclosure used by Skills.

Among different types of agents, Coding Agents are especially important because code is not merely an ordinary tool; it is a “meta-tool capable of creating new tools.” A Coding Agent can read a repository, search for relevant code, edit files, run tests, read errors, and revise again, thereby forming a highly verifiable loop. Over decades, software engineering has accumulated compilers, type systems, unit tests, CI, lint, Runtime Errors, Git diffs, and Pull Request Reviews—mechanisms that naturally provide rich feedback for agents.

This is also a major reason Coding Agents have matured relatively quickly. They do not depend on “getting everything right in one attempt”; instead, they depend on the environment repeatedly telling them whether the last change worked. When an agent can safely execute its own scripts inside a Sandbox and package verified programs into new Tools or Skills, it can even achieve a degree of Self-bootstrapping: when encountering a new task type, it can search for existing capabilities or write scripts itself, then distill successful methods for later reuse. As a result, many general-purpose agents are gradually taking on a system form resembling “Coding Agent + Sandbox + Tools.”


4. From Interaction to Harness Engineering: The True Core of Production-grade Agents

When agents move from chat windows into real environments, they are no longer merely synchronously responding to user input; they increasingly become event-driven systems. Tasks can be triggered by user messages, Email, Webhooks, Cron timers, system alerts, or even other agents. Tasks may also be paused, resumed, executed in parallel, or continue running in the background. At this point, the importance of state management, event deduplication, concurrency control, and recovery mechanisms rises rapidly, and agent engineering begins to overlap substantially with traditional distributed systems and Workflow Engines.

Multimodal interaction further amplifies this system complexity. A real-time voice agent often needs to pass through VAD (Voice Activity Detection), ASR (Automatic Speech Recognition), the LLM, and TTS (Text-to-Speech). The bottleneck in actual user experience is often not the quality of any single model, but end-to-end latency. Therefore, streaming, parallel execution, user interruption, and layered fast/slow reasoning are often more important than simply improving model accuracy.

Computer Use expands the agent’s Observation Space and Action Space to the GUI. The model can perceive pages through screenshots, DOM, or other structured interface information, and then perform actions such as clicking, typing, scrolling, and using keyboard shortcuts. However, “being able to click” is far from the same thing as “being able to complete the operation stably and safely.” Changes in page layout, pop-ups, login state, permission confirmation, and irreversible actions all create new failure modes. GUI agents therefore make one point particularly clear: the real product barrier is often not whether the model has a capability, but whether the system can control, verify, and recover that capability.

Accordingly, the understanding of agent engineering has gradually evolved from Prompt Engineering to Context Engineering and then further to Harness Engineering. This evolution can be summarized as an inclusion relationship:

Prompt ⊂ Context ⊂ Harness

Prompt Engineering concerns how to instruct the model; Context Engineering concerns what the model can currently see; Harness Engineering concerns how the entire runtime system around the model operates. A Harness usually includes Context, Memory, Tools, Cache, Permissions, Sandbox, Validation, Error Recovery, State Management, Parallelism, Observability, and Safety.

Therefore, a production-grade agent is better understood through the following formula:

Agent = Model × Harness

The “multiplication” here emphasizes a weakest-link effect. A strong model inside a weak Harness may be “smart but out of control”; a highly polished Harness around a model without sufficient understanding and reasoning ability may be “stable but unable to solve complex tasks.” The same base model placed in different Harnesses may therefore produce very different user experiences, which is one fundamental reason modern agent products are increasingly differentiated.

A reliable Harness must cover at least three stages. The first is Constraint before action, including least privilege, tool allowlists, Fail-closed behavior, Sandbox isolation, and confirmation for high-risk operations. The second is Verification after action, including Schema validation, automated tests, Validators, Policy Checkers, Hooks, or independent Reviewers. The third is Recovery after failure, including Retry, Backoff, Circuit Breakers, Model Fallback, Checkpoints, State Rollback, and Human Takeover. Safety and reliability are therefore not an additional “protection layer” added at the end, but system properties spanning the entire agent lifecycle.


5. Evaluation, Continual Improvement, and Multi-Agent: How Agents Actually Become Better

If an agent system cannot be evaluated reliably, it is impossible to determine whether a change has actually improved or degraded it. Compared with traditional model evaluation, Agent Evaluation must consider three levels simultaneously: result, process, and system. Result-level evaluation asks whether the task was ultimately completed; Trajectory-level evaluation asks whether the entire execution trajectory was reasonable and where the first error occurred; System-level evaluation further considers cost, latency, robustness, and safety.

Pass@k is a common metric in agent evaluation. It indicates that, if the model is allowed k independent attempts and at least one succeeds, then the task is in some sense “within the system’s capability.” Production environments, however, care more about single-attempt success and repeated success. An agent with an apparently high per-step success rate may still suffer rapidly declining end-to-end success in long-chain tasks because errors accumulate. Therefore, upper-bound single-task capability and operational reliability must be distinguished.

LLM-as-a-Judge is a common automated evaluation method, in which another LLM scores a result or trajectory according to a predefined Rubric. More important than the final score, however, is Failure Attribution: did the first error occur in Context, RAG, Tool use, Reasoning, Verification, or Recovery? Only after locating the failure mechanism can an engineering team know which layer should be modified, rather than simply “switching to a stronger model” based on intuition.

Mature agent development should form a loop similar to scientific experimentation: observe failures from Benchmarks or production logs, propose mechanism-level hypotheses, verify changes through Ablation, A/B Tests, or Feature Flags, and then add critical historical failures to a Regression Set. In other words, Agent Engineering should not rely on “it feels smarter,” but on reproducible and falsifiable experiments.

Only when the error truly originates in the model itself should further training be considered. Mid-training is more suitable for cases where the base model’s knowledge or capability distribution is insufficient; SFT (Supervised Fine-Tuning) is appropriate when the model “knows how to do the task, but the behavioral protocol is unstable”; RL (Reinforcement Learning) is more suitable when multiple viable strategies exist and reward signals can increase the probability of better behavior. Not every agent problem deserves RL. Many issues are easier to control through changes to Context, Skills, Tools, Hooks, or programmatic rules.

This leads naturally to the problem of continual improvement. Context Learning is not the same as Persistent Learning. If an agent completes ten thousand tasks today but none of the experience is written back to a durable substrate, a new Session tomorrow may still repeat yesterday’s mistakes. Experience can be written into Knowledge, Instructions / Skills, Programs, or Model Parameters. From an engineering perspective, outer-layer mechanisms that are auditable and reversible should usually be modified first. For example, if an agent repeatedly forgets to run tests before deployment, adding a mandatory Hook is often more reasonable than retraining the model.

Multi-Agent further expands system parallelism and specialization, but it does not mean “the more agents, the better.” A second agent is genuinely valuable only when it brings new information, tools, permissions, expertise, or true parallelism. If multiple agents use the same model, the same Context, and similar Prompts, their errors are often highly correlated, and majority voting does not necessarily provide independent judgment. Therefore, the core value of Multi-Agent systems should be understood as heterogeneous capabilities and division of responsibility rather than quantity itself.


6. Engineering Practice of Popular Agents: OpenClaw, Hermes, Codex, and Claude Code

Within the theoretical framework above, OpenClaw, Hermes Agent, Codex, and Claude Code can be understood as four different Harness implementation strategies. They are often grouped together as “popular agents,” but they are not completely homogeneous in system positioning. OpenClaw emphasizes persistent presence and cross-channel access, Hermes emphasizes the learning loop formed by long-term Memory and Skills, Codex emphasizes Multi-Agent parallel engineering execution and task orchestration, and Claude Code emphasizes programmable developer control over the Harness.

6.1 OpenClaw: A Channel-first Persistent Personal Agent

The core of OpenClaw can be understood as a self-hosted Gateway. Different channels such as Telegram, WhatsApp, Slack, Discord, and WebChat first connect to the Gateway. The Gateway then manages long-term state such as Sessions, Routing, Memory, Tools, Skills, Cron, and Webhooks, and delegates the parts requiring reasoning to the model. Compared with typical Coding Agents, OpenClaw focuses more on whether “the agent is always there,” making it closer to Personal Agent Infrastructure.

This characteristic is especially visible in long-running tasks. The official OpenClaw Showcase includes a community case in which an agent negotiated continuously with multiple car dealers through Email, with the community author reporting a final saving of $4,200. This figure is a user-reported claim and should not be treated as an independent Benchmark; what matters more is the structure of the task itself. The agent must read multiple email threads over a long period, maintain different offers and conditions, adjust strategy according to new feedback, and return control to the user at critical decision points. Compared with a one-shot Chatbot, such tasks truly depend on cross-time state, asynchronous events, and persistent presence.

OpenClaw can therefore be summarized as Channel-first. What it expands is not merely single-step reasoning capability, but the agent’s “space of presence”: the agent can continuously exist across multiple devices, messaging platforms, and automation workflows.

6.2 Hermes Agent: A Learning-first Continual-learning Agent

Nous Research positions Hermes Agent as a self-improving agent. Here, “self-improvement” is currently more appropriately understood at the Harness layer: past experience is continuously written back into the system through Persistent Memory and Skills, rather than necessarily meaning that model parameters are continuously trained online during operation.

Hermes can store facts, preferences, and historical experience in long-term Memory, while distilling “how a certain type of task should be completed” into Skills. After a task is completed, corrections can update Memory, stable workflows can create or modify Skills, and later tasks can reuse these capabilities. Combined with Cron, Subagents, Bot Mode, MCP, and long-running environments, Hermes forms a clear Learning Loop.

In Hermes’s official User Stories, Teknium from Nous Research described running 12 Hermes instances in parallel every day for Hermes development, backend-infrastructure investigation, and work involving RL Environments, Benchmarks, and Datasets. What truly matters here is not the number “12,” but that multiple persistent agent instances take on different roles while continuously retaining their own experience and state. Hermes is therefore closer to a Learning-first Persistent Agent Harness.

6.3 Codex: An Orchestration-first Engineering Execution Platform

Codex was initially most easily understood as a Coding Agent, but by 2026 its product form had clearly expanded toward Multi-Agent engineering execution and task orchestration. Current Codex workflows can coordinate through ChatGPT, IDE, CLI, and Cloud Environments, while Worktrees and cloud sandboxes allow multiple agents to work simultaneously on Features, Bugfixes, Refactors, or Research tasks.

Git Worktree is especially important here because it allows the same Repository to have multiple independent working directories at the same time. Agent A can work on one Feature while Agent B fixes a Bug without directly contaminating each other’s Git state. As a result, the basic collaboration unit in software development gradually shifts from “one developer and one AI pair” to “one developer supervising multiple parallel agent workstreams.”

OpenAI disclosed an Agent-first engineering experiment in its Harness Engineering case study: starting from an empty Git Repository, the project grew to roughly one million lines of code and about 1,500 Pull Requests in approximately five months, initially driven by 3 engineers and later expanded to 7. The team also provided an internal estimate that the entire project took roughly one-tenth the time of manual coding. Because these figures come from OpenAI’s own experiment, they should not be directly generalized as a universal productivity Benchmark.

The more important conclusion from this case is the change in engineering roles. Developers increasingly focus on designing Agent-friendly Repositories, task specifications, tests, CI, AGENTS.md, Skills, Observability, and automated Review, while the agent performs implementation. OpenAI summarized this relationship as: Humans steer. Agents execute. This is also why Codex can be characterized as Orchestration-first: its core value is not merely writing code, but organizing multiple agents to advance engineering tasks reliably.

6.4 Claude Code: A Harness-first Developer Agent

Claude Code follows a somewhat different path from Codex. It also has strong Coding capabilities, but Anthropic places greater emphasis on how developers can control the agent precisely. Mechanisms such as CLAUDE.md, Rules, Skills, Subagents, Hooks, MCP, and Plugins together form a highly programmable Developer Harness.

CLAUDE.md is a representative form of persistent project-level Context. Developers can record project architecture, coding conventions, test commands, prohibited actions, and team agreements in it, so that the agent receives stable background information each time it enters the project. Hooks go further by turning some soft constraints into deterministic program mechanisms. For example, if “tests must be run before submission” appears only in a Prompt, the model may still forget it; if a Hook automatically runs tests before submission, the requirement no longer depends on whether the model remembers the rule.

Anthropic’s Data Infrastructure team disclosed a Kubernetes troubleshooting case: after the cluster stopped scheduling Pods, Claude Code combined Dashboard screenshots, the Google Cloud interface, documentation, and commands to investigate the issue step by step, eventually identifying exhausted Pod IP addresses and providing the steps for creating a new IP Pool and attaching it to the cluster. This case shows that Claude Code is no longer merely a completion tool inside a code editor, but can place screenshots, web interfaces, Shell commands, and cloud systems into a single Agent Trajectory. The real difficulty remains the Harness: which operations may execute automatically, which require confirmation, how results are verified, and how execution is stopped or recovered when something goes wrong.

Claude Code is therefore best summarized as Harness-first. Its value lies in exposing many Agent control points directly to developers, allowing model behavior to be jointly constrained by rules, Hooks, Subagents, and external tools.


7. Cross-comparison and Engineering Selection of the Four Agents

From a product perspective, OpenClaw, Hermes, Codex, and Claude Code all contain Models, Context, and Tools, but they make different trade-offs around the task lifecycle.

Dimension OpenClaw Hermes Agent Codex Claude Code
Core positioning persistent personal Agent Gateway continual-learning general-purpose Agent Multi-Agent engineering execution platform programmable developer Harness
Main strategy Channel-first Learning-first Orchestration-first Harness-first
Main interfaces messaging platforms / Web / CLI Desktop / CLI / Bots / messaging platforms ChatGPT / IDE / CLI / Cloud Terminal / IDE / Desktop / Web
Long-term Memory strong core capability increasingly integrated into long-running workflows project Context + Memory mechanisms
Skills supported core learning substrate supported supported
Background and automation Cron / Webhook / Automation Cron / Routine Automations / Background Work Background / external orchestration
Multi-Agent Routing / Subagents Subagents / Bot Mode core strength Subagents
Core advantage persistent presence and multi-channel access experience retention and continual learning parallel engineering and task orchestration high controllability and programmability
Typical scenarios Personal Assistant Persistent / Research Agent large engineering workflows Developer-controlled Agent

If the goal is to build a 24/7 digital assistant that works across devices and messaging platforms, OpenClaw’s Gateway and long-term Session architecture are a natural fit. If the emphasis is on Memory, Skills, and a continual-learning loop, Hermes is more representative. If the goal is large-scale software engineering, multi-task parallelism, and orchestration among multiple agents, Codex is better suited as an Orchestration platform. If developers want precise control over Agent Context, rules, Hooks, Subagents, and external tools, Claude Code is more appropriate.

Therefore, engineering selection should not begin by asking “Which Agent is the strongest?” but by asking what the core task lifecycle actually is. The four products jointly demonstrate that the same underlying model capability can produce very different product behaviors and interaction models when embedded in different Harnesses.


8. Conclusion: From Model Competition to Agent Systems Engineering

The essence of an AI Agent is not simply adding several tools to a Large Language Model, but constructing a complete system capable of continuously perceiving, acting, verifying, correcting, and accumulating experience. At the basic structural level, its capabilities can be described by Agent = LLM + Context + Tools. From an engineering perspective, as system complexity increases, a more appropriate framework becomes Prompt ⊂ Context ⊂ Harness, which ultimately converges on Agent = Model × Harness.

Context determines what the Agent sees; Memory and RAG determine how information enters the system across time and from external knowledge sources; Tools and MCP determine how the Agent converts language-level decisions into real actions; Coding Agents and Computer Use expand its execution space; Permissions, Validation, Recovery, and Evaluation determine whether those capabilities can truly be used in production. Continual improvement and Multi-Agent are not isolated add-on features, but further extensions of temporal scale and parallel scale after the preceding system capabilities become mature.

OpenClaw, Hermes, Codex, and Claude Code demonstrate different forms of modern Agent Harness from four directions: persistent presence, continual learning, parallel labor, and developer control. Together, they reveal a broader trend: as base-model capabilities continue to improve, increasingly large differences among products will come from system design outside the model. The future competition will concern not only “which model is smarter,” but also “what the system lets the model see, what it allows the model to do, how it verifies that the model acted correctly, how it recovers from mistakes, how experience is written back, and how multiple agents cooperate.”

Therefore, the next stage of AI Agents is better understood as Agent Systems Engineering. If the early question of the Large Language Model era was “Can machines demonstrate complex reasoning ability through language?”, then the practical problem faced by Agent Engineering is:

How can machines perform work in real environments over long periods of time, reliably and under control?


Appendix A: High-frequency Terms and Acronyms

This appendix is intended for quick reference. Key acronyms are also explained when they first appear in the main text. The appendix does not alter the eight-section structure of the main report.

Term / Acronym Full name and meaning
AI Artificial Intelligence
Agent an intelligent system capable of perceiving an environment, maintaining state, making decisions, and executing actions
LLM Large Language Model
ReAct Reasoning + Acting, an Agent paradigm that alternates reasoning and action
Observation new information obtained by the Agent from users, tools, or the environment
Context all information visible to the model during the current inference step, including Prompt, history, tool results, Memory, and RAG evidence
System Prompt system-level instructions defining the model’s role, principles, constraints, and high-level behavior
Token the basic discrete unit used by the model to process text
KV Cache Key-Value Cache, caching of Keys and Values in Transformer Attention
Prompt Cache a product-level caching mechanism for reusing repeated prompt prefixes
Skill an on-demand, reusable Agent capability package that may include instructions, rules, scripts, tools, and verification methods
Memory user state, preferences, facts, and experience persistently stored across Sessions or tasks
Knowledge Base a collection of documents, databases, or other sources used for external knowledge
RAG Retrieval-Augmented Generation
Embedding encoding text, images, or other content into vector representations
Dense Retrieval dense semantic retrieval based on vector similarity
Sparse Retrieval sparse retrieval based on lexical matching
BM25 a classic sparse-retrieval ranking algorithm
Re-ranker a model that performs more precise relevance re-ranking of initially retrieved candidates
Tool Calling structured tool invocation in which the model selects a tool and generates arguments
Schema structured field and type constraints used to define tool arguments or output formats
API Application Programming Interface
CLI Command-Line Interface
IDE Integrated Development Environment
GUI Graphical User Interface
DOM Document Object Model
MCP Model Context Protocol
Sandbox an isolated execution environment separated from the host or production system
Webhook a callback mechanism through which an external system actively pushes events to a specified endpoint
Cron a mechanism for triggering scheduled tasks according to time-based rules
VAD Voice Activity Detection
ASR Automatic Speech Recognition
TTS Text-to-Speech
Harness the system around the model that provides Context, Memory, Tools, Permissions, Caching, Verification, Recovery, State Management, and Orchestration
Fail-closed rejecting an operation by default when the system cannot confirm that it is safe
Hook program logic automatically triggered before or after a particular system event or tool invocation
Validator a validator that uses rules, programs, or models to check whether outputs or actions satisfy requirements
Pass@k a metric in which the task is considered solvable if at least one of k independent attempts succeeds
LLM-as-a-Judge using another Large Language Model as an automated evaluator
Rubric a predefined scoring rubric or evaluation criterion
Benchmark a standardized evaluation over a fixed task set
Failure Attribution identifying the first stage in a trajectory where a critical error occurs
Regression Set a regression-test set built from historical failures to prevent old problems from reappearing
A/B Test an experiment that compares different versions by splitting traffic or samples
Feature Flag a feature switch that independently enables or disables a mechanism
Mid-training an intermediate training stage between pretraining and task-specific fine-tuning
SFT Supervised Fine-Tuning
RL Reinforcement Learning
Multi-Agent multiple Agents collaborating through division of labor, parallelism, and independent verification
Subagent a child Agent delegated a specialized task by the main Agent
Orchestration coordination and management of multiple tasks, Agents, tools, and execution environments
Gateway a persistent hub connecting channels, Sessions, state, tools, and the Agent Runtime
VPS Virtual Private Server
Worktree a Git mechanism for multiple working directories, enabling multiple Agents to work on the same repository in parallel
PR Pull Request, a request for review and merging of code changes
CI Continuous Integration
AGENTS.md a repository-level rules and work-instruction file intended for Coding Agents
CLAUDE.md a project-level context and rules file automatically read by Claude Code
Provider a model or service provider

References

  1. Li Bojie, AI Agents in Depth: Design Principles and Engineering Practice / 《深入理解 AI Agent:设计原理与工程实践》.
  2. OpenClaw Documentation: https://docs.openclaw.ai/
  3. OpenClaw Showcase: https://docs.openclaw.ai/start/showcase
  4. Hermes Agent Documentation: https://hermes-agent.nousresearch.com/docs/
  5. Hermes Agent User Stories: https://hermes-agent.nousresearch.com/docs/user-stories
  6. OpenAI Codex: https://openai.com/codex/
  7. OpenAI, Introducing the Codex app.
  8. OpenAI, Harness engineering: leveraging Codex in an agent-first world.
  9. Claude Code Documentation: https://code.claude.com/docs
  10. Anthropic, Steering Claude Code: when to use CLAUDE.md, skills, hooks, and subagents.
  11. Anthropic internal Claude Code engineering case studies.

Presentation

Open in PowerPoint在 PowerPoint 中打开