Harness engineering for self-improvement

Harness engineering for self-improvement

利用 Harness 工程实现自我提升

Table of Contents 目录

Harness Design Patterns Pattern 1: Workflow Automation Pattern 2: File System as Persistent Memory Pattern 3: Sub-agent and Backend Jobs Case study: Coding Agent Harness Harness Layer vs Core Intelligence? Harness Optimization Context Engineering Workflow Design Self-Improving Harness Evolutionary Search Joint Optimization with Model Weights Future Challenges Citation Appendix: Some useful benchmarks References

Harness 设计模式 模式 1:工作流自动化 模式 2:将文件系统作为持久化内存 模式 3:子智能体与后端任务 案例研究:编码智能体 Harness Harness 层与核心智能的区别? Harness 优化 上下文工程 工作流设计 自我提升的 Harness 演化搜索 与模型权重的联合优化 未来挑战 引用 附录:一些有用的基准测试 参考文献

The concept of recursive self-improvement (RSI) dates back to I. J. Good (1965), where he defined an “ultraintelligent machine” as a system that can surpass humans in all intellectual activities and design better machines to improve itself. Yudkowsky (2008) used the phrase “recursive self-improvement” for a specific feedback loop: an AI uses its current intelligence to improve the cognitive machinery that produces its intelligence. This feedback loop in modern AI may indicate the model rewriting its own weights directly, or more broadly the model improves the training pipeline and the deployment system, which in turn enables a better successor model with improved performance across economically valuable tasks.

递归自我提升(RSI)的概念可以追溯到 I. J. Good(1965 年),他将“超智能机器”定义为一种能够在所有智力活动中超越人类,并设计出更好的机器来提升自身的系统。Yudkowsky(2008 年)使用“递归自我提升”一词来描述一个特定的反馈循环:AI 利用其当前的智能来改进产生其智能的认知机制。在现代 AI 中,这种反馈循环可能表现为模型直接重写自身的权重,或者更广泛地表现为模型改进了训练流水线和部署系统,进而促成性能更强、在具有经济价值的任务中表现更好的后续模型。

The speed of research development in AI has been shown to drastically accelerated in frontier labs (Anthropic; OpenAI). I explicitly mention “deployment system” because the layer between the raw model and the real-world context seems to be as important as the model’s raw intelligence (i.e. the evals right after pretraining). Harnesses are important components of AI deployment, as shown by successful coding agent products such as Claude Code and Codex. A harness is the system surrounding a base model that orchestrates execution and decides how the model thinks and plans, calls tools and acts, perceives and manages context, stores artifacts, and evaluates results. This one post will focus on research around harness engineering and how it contributes to RSI.

前沿实验室(如 Anthropic 和 OpenAI)的 AI 研究发展速度已显著加快。我明确提到“部署系统”,是因为原始模型与现实世界上下文之间的这一层,其重要性似乎不亚于模型的原始智能(即预训练后的评估结果)。正如 Claude Code 和 Codex 等成功的编码智能体产品所展示的那样,Harness 是 AI 部署的重要组成部分。Harness 是围绕基础模型构建的系统,它负责编排执行过程,决定模型如何思考和规划、调用工具并采取行动、感知和管理上下文、存储工件以及评估结果。本文将重点探讨围绕 Harness 工程的研究及其如何促进 RSI。

Much recent work on auto-research, self-improving agents, and evolutionary program search can be organized around this question. Other work on model self-play, synthetic data, test-time training and a broader theme of continual learning also matches the RSI vision (e.g. Yuan et al. 2024, Chen et al. 2024), Zhao et al. 2025, Choi et al. 2026)) but they will not be the focus of this post.

近期关于自动研究、自我提升智能体和演化程序搜索的许多工作都可以围绕这个问题展开。其他关于模型自我博弈、合成数据、测试时训练以及更广泛的持续学习主题的工作也符合 RSI 的愿景(例如 Yuan 等人 2024,Chen 等人 2024,Zhao 等人 2025,Choi 等人 2026),但它们不会是本文的重点。

Harness Design Patterns

Harness 设计模式

Compared with early agent frameworks, “agent = LLM + memory + tools + planning + action”, harnesses engineering additionally include workflow design (e.g. loop engineering), evaluation, permission controls, and persistent state management. It is no longer only prompt templates, but closer to runtime and software system design: how the model observes, acts, memorizes, checks itself, and improves. The design should be deliberately simple and generic to enable generalization, likely with reference to existing software engineering practices to benefit from pretraining knowledge. There is also a strong analogy between operating systems and harnesses. Similar to an OS, a harness should encapsulate complicated logic while keeping the interface simple. Meanwhile, configs, tool interfaces and other protocols may gradually become standardized across the industry.

与早期的智能体框架“智能体 = LLM + 记忆 + 工具 + 规划 + 行动”相比,Harness 工程额外包含了工作流设计(如循环工程)、评估、权限控制和持久化状态管理。它不再仅仅是提示词模板,而更接近于运行时和软件系统设计:即模型如何观察、行动、记忆、自我检查和改进。其设计应刻意保持简单和通用,以实现泛化,并可能参考现有的软件工程实践,从而利用预训练知识。操作系统与 Harness 之间也存在很强的类比关系。与操作系统类似,Harness 应封装复杂的逻辑,同时保持接口简洁。与此同时,配置、工具接口和其他协议可能会逐渐在行业内实现标准化。

Pattern 1: Workflow Automation

模式 1:工作流自动化

Defining a workflow in which the model can operate, test, and iterate is a key design for automation. Karpathy’s autoresearch repo (https://github.com/karpathy/autoresearch) is a clean example of how such a workflow can be constructed. A common workflow follows a goal-oriented loop of plan, execute, observe/test, improve, and execute again until the goal is achieved. The process may trigger proactive requests to users for clarity in task specification or execution preference. A simplified Codex agent loop: the agent calls tools and tool responses affect the model’s next generation. The workflow graph also emphasizes the model analyzing its own trajectories and failure cases and then iterating on its progress through an “agent runtime” rather than a static prompt template.

定义一个模型可以操作、测试和迭代的工作流是自动化的关键设计。Karpathy 的 autoresearch 仓库(https://github.com/karpathy/autoresearch)是一个如何构建此类工作流的清晰示例。常见的工作流遵循以目标为导向的循环:规划、执行、观察/测试、改进,然后再次执行,直到达成目标。该过程可能会主动向用户请求澄清任务规范或执行偏好。一个简化的 Codex 智能体循环:智能体调用工具,工具的响应会影响模型的下一次生成。工作流图还强调了模型通过“智能体运行时”而非静态提示词模板来分析自身的轨迹和失败案例,并据此迭代其进度。

Pattern 2: File System as Persistent Memory

模式 2:将文件系统作为持久化内存

A recurring pattern in long-horizon agent systems is simple control over rich states and artifacts. A harness should not carry the entire workflow and all logs in context; instead, it should keep durable state in files. In long-horizon agentic rollout, artifacts such as experiment logs, code diffs, paper summaries, error traces, and past rollout trajectories often grow much longer than the context window that the model has trained for. Learning how to read, write, and edit the file system (commonly via bash commands) is a foundation skill for LLMs, and thus managing persistent memory in the simple form of files naturally benefits from improvements in core model capability.

在长程智能体系统中,一个反复出现的模式是对丰富的状态和工件进行简单的控制。Harness 不应将整个工作流和所有日志都放在上下文中;相反,它应该将持久状态保存在文件中。在长程智能体运行中,实验日志、代码差异、论文摘要、错误追踪和过去的运行轨迹等工件,往往会远超模型训练时的上下文窗口长度。学习如何读取、写入和编辑文件系统(通常通过 bash 命令)是 LLM 的一项基础技能,因此以简单的文件形式管理持久化内存,自然会受益于核心模型能力的提升。

Pattern 3: Sub-agent and Backend Jobs

模式 3:子智能体与后端任务

A harness can spawn multiple subagents to execute in parallel and monitor backend jobs. This is useful when the main agent needs to search multiple hypotheses, run experiments concurrently, or delegate isolated subtasks without polluting the main context. The parent agent then needs a small process manager: launch jobs, inspect logs, cancel failed runs, and merge results back into the main agent thread. The key design choice is to make parallelism explicit and inspectable. If subagent outputs only live in a transient chat context, they quickly become obsolete and hidden. If they are stored as files, logs, and status records, the model can recover after interruptions and reason over its own execution history.

Harness 可以生成多个子智能体并行执行并监控后端任务。当主智能体需要搜索多个假设、并发运行实验或委派独立的子任务而不污染主上下文时,这非常有用。此时,父智能体需要一个小型进程管理器:启动任务、检查日志、取消失败的运行,并将结果合并回主智能体线程。关键的设计选择是使并行性变得明确且可检查。如果子智能体的输出仅存在于瞬时的聊天上下文中,它们很快就会过时并被隐藏。如果它们以文件、日志和状态记录的形式存储,模型就可以在中断后恢复,并对其自身的执行历史进行推理。

Case study: Coding Agent Harness

案例研究:编码智能体 Harness

The core interface of mainstream coding agents has become stabilized across Claude Code, Codex, OpenCode, and Cursor-style agents. They commonly use a loop like: With access to a set of tools, the coding agent is able to develop and debug issues in a given repository, similar to how human developers are equipped with IDEs.

主流编码智能体的核心接口在 Claude Code、Codex、OpenCode 和 Cursor 风格的智能体中已趋于稳定。它们通常使用如下循环:通过访问一组工具,编码智能体能够在给定的代码库中开发和调试问题,这类似于人类开发者使用 IDE 的方式。