个人双语阅读版,非官方译本。
Personal bilingual reading edition, not an official translation.
How to Build AI Loops That Are Replacing Prompt Engineering如何搭建 AI 循环:正在取代提示词工程的新方法
原文 Source: https://x.com/Lummox_eth/status/2111100800625787154
⚠️ 文中的实验次数、改进比例、基准耗时等数字,均为作者转述的第三方说法(原文多用 reportedly / 据报道),本版未独立核实。原文配图(封面及 5 张插图)未能通过接口取到,本版不含图片。
Figures in the text (experiment counts, % improvements, benchmark times) are third-party claims as relayed by the author, not independently verified. The article's cover and 5 inline images could not be retrieved and are not included.
Introduction引言
For two years, getting better results from AI meant writing better prompts.
过去两年,想让 AI 出更好的结果,靠的就是把提示词写得更好。
Longer instructions, smarter system messages, increasingly complicated frameworks. Engineers spent hours figuring out which words made an agent perform better.
指令越写越长,系统提示越写越巧,框架越搭越复杂。工程师要花上好几个小时,琢磨到底哪些措辞能让 agent 表现更好。
That approach is starting to lose its advantage.
这套打法的优势,正在消失。
Andrej Karpathy's autonomous research system ran roughly 700 experiments in two days and discovered around 20 improvements. Shopify's CEO reportedly used a similar approach to improve a smaller model by 19%. Boris Cherny, the creator of Claude Code, said he had gone eight months without writing code by hand. (Source cited by the author: philschmid.de)
Andrej Karpathy 的自主研究系统两天里跑了大约 700 次实验,找到了大约 20 处改进。据报道,Shopify 的 CEO 用类似的方法,把一个较小的模型提升了 19%。Claude Code 的作者 Boris Cherny 说,他已经八个月没手写过代码了。(作者注明的出处:philschmid.de)
The common thread is not a better prompt.
这些事的共同点,不是更好的提示词。
It is a loop.
而是一个循环(loop)。
A system that gives AI a goal, lets it work, checks the result, and keeps going until the objective is reached.
也就是这样一套系统:给 AI 一个目标,让它去干,检查结果,然后接着干,直到目标达成。
Here is how these loops work, why they are becoming so powerful, and how to build your first one.
下面讲讲这种循环怎么运作、为什么越来越强,以及怎么搭出你的第一个。
1. The engineer who ran 700 experiments1. 跑了 700 次实验的工程师
In March 2026, Andrej Karpathy released autoresearch, a small open-source system designed to automate machine learning experiments.
2026 年 3 月,Andrej Karpathy 发布了 autoresearch:一个小型开源系统,用来把机器学习实验自动化。
The architecture was surprisingly simple.
它的架构简单得出人意料。
Three important files controlled the process.
整个流程由三个关键文件控制。
train.pycontained the training code the agent could modify.train.py:训练代码,agent 可以修改。prepare.pyhandled data preparation and evaluation.prepare.py:负责数据准备和评估。program.mddescribed the objective, constraints, and experimental rules.program.md:写明目标、约束和实验规则。
The agent had one job: improve model performance without changing the evaluation system.
agent 只有一个任务:在不动评估系统的前提下,提升模型表现。
It would inspect the code, propose a modification, train for five minutes, compare the result against the previous experiment, and decide whether to keep the change.
它会先看代码,提出一处修改,训练五分钟,把结果和上一次实验对比,再决定这处改动留不留。
Then it started again.
然后从头再来。
Over two days, the system reportedly completed around 700 experiments and identified roughly 20 improvements. The combined changes reduced a time-to-GPT-2 benchmark from 2.02 to 1.80 hours.
据报道,两天里这个系统完成了大约 700 次实验,找出了约 20 处改进。这些改动叠加起来,把一项“训练到 GPT-2 水平所需时间”的基准从 2.02 小时压到了 1.80 小时。
One discovery involved a missing scaling factor in the attention mechanism, something that ordinary syntax checks would never flag.
其中一项发现,是注意力机制里漏掉了一个缩放因子——这种问题,普通的语法检查永远查不出来。
The significance was not that AI suddenly became a better researcher than Karpathy.
这件事的意义,不在于 AI 突然成了比 Karpathy 更厉害的研究者。
It was that an agent could investigate hundreds of measurable hypotheses without requiring someone to approve each experiment.
而在于:agent 可以去验证几百个能量化的假设,不需要有人逐个批准每一次实验。
Humans get tired after dozens of unsuccessful attempts.
人连着失败几十次,就会累。
A properly controlled loop can keep exploring as long as its budget allows.
一个管控得当的循环,只要预算还够,就能一直探索下去。
2. A loop is not a prompt running every hour2. 循环,不是每小时跑一次提示词
Most people confuse automation with autonomous iteration.
很多人把“自动化”和“自主迭代”混为一谈。
They schedule a prompt, receive an answer, and call it an agent.
他们给一条提示词设个定时任务,拿到回答,就管这叫 agent。
But running the same instruction repeatedly does not create a useful feedback system.
可同一条指令反复跑,并不会形成有用的反馈系统。
A real loop has five stages:
真正的循环有五个阶段:
Discover → Plan → Execute → Verify → Iterate
发现 → 规划 → 执行 → 验证 → 迭代
The agent examines the problem, chooses an approach, performs the work, evaluates the outcome, and uses that evidence to determine what happens next.
agent 先摸清问题,选定做法,动手干活,评估结果,再根据这些证据决定下一步。
Three components make the difference.
真正拉开差距的,是三个组件。
Verification: The result must pass an objective test. A compiler, benchmark, test suite, or deterministic validation script.
验证:结果必须通过客观的检验——编译器、基准测试、测试套件,或者结果确定的校验脚本。
Memory: The system records what was attempted, what failed, and which changes produced improvements.
记忆:系统要记下试过什么、哪些失败了、哪些改动带来了提升。
Stopping conditions: The loop ends when the objective is achieved or a hard limit is reached.
停止条件:目标达成,或者撞到硬性上限,循环就结束。
Without verification, the agent can confidently repeat mistakes.
没有验证,agent 会信心满满地重复犯错。
Without memory, it keeps rediscovering the same failures.
没有记忆,它会一次又一次踩同样的坑。
Without stopping conditions, it can consume resources indefinitely.
没有停止条件,它可能没完没了地烧资源。
A loop is not useful because it runs without supervision.
循环之所以有用,不是因为它能在没人看着的时候跑。
It is useful because its progress can be measured without constant supervision.
而是因为它的进展可以被衡量,不需要人一直盯着。
3. The self-healing GitHub repository3. 能自我修复的 GitHub 仓库
Now imagine applying the same architecture to ordinary software development.
现在,设想把同样的架构用到日常软件开发上。
A developer pushes code to GitHub.
开发者把代码推到 GitHub。
The CI pipeline detects a failing test.
CI 流水线发现有个测试挂了。
Instead of waiting for someone to inspect the failure manually, an automated workflow sends the logs and relevant repository context to Claude Code or Codex.
不用等人手动去排查,自动化流程会把日志和相关的仓库上下文发给 Claude Code 或 Codex。
The agent investigates the error, creates a candidate fix, and runs the tests again.
agent 排查错误,写出一个候选修复,再把测试跑一遍。
If verification fails, it examines the new output and tries another approach.
验证没过,它就看新的输出,换个思路再试。
If the tests pass, it opens a pull request containing the proposed correction and supporting evidence.
测试通过了,它就开一个 pull request,附上修复方案和支撑证据。
A human reviews the change before merging.
合并之前,由人来审查这次改动。
This is a practical example of a self-healing repository.
这就是“自愈仓库”的一个实际例子。
The workflow does not require an enormous multi-agent system.
这套流程用不着庞大的多 agent 系统。
It needs an event trigger, a coding agent, a reproducible environment, persistent state, and an independent verifier.
它只需要:一个事件触发器、一个编程 agent、一个可复现的环境、持久化的状态,再加一个独立的验证器。
The same pattern can handle dependency updates, formatting violations, reproducible bugs, and routine maintenance.
同样的模式还能处理依赖升级、格式不合规、可复现的 bug,以及日常维护。
The important distinction is that the agent does not decide whether its work is successful.
关键区别在于:活儿干没干成,不由 agent 自己说了算。
The repository's verification system does.
由仓库的验证系统说了算。
4. Build your first AI loop with three files4. 用三个文件搭出你的第一个 AI 循环
The easiest mistake is starting with ten agents, multiple orchestration frameworks, and an expensive monitoring dashboard.
最容易犯的错,是一上来就搞十个 agent、好几套编排框架,外加一个昂贵的监控面板。
Start smaller.
从小处开始。
You can organize a basic coding loop around three files.
一个基础的编程循环,围绕三个文件就能搭起来。
AGENTS.md — Project instructions
AGENTS.md——项目说明
Define the objective, repository conventions, permitted operations, and restrictions.
写明目标、仓库规范、允许的操作和限制。
For Claude Code, the equivalent project-specific instructions can live in CLAUDE.md.
如果用的是 Claude Code,对应的项目说明可以放在 CLAUDE.md 里。
loop.py — The controller
loop.py——控制器
This script invokes the coding agent, manages retries, records progress, and enforces execution limits.
这个脚本负责调用编程 agent、处理重试、记录进度,并强制执行运行上限。
verify.sh — The verification gate
verify.sh——验证关卡
This file contains the commands that determine whether the required work has succeeded.
这个文件里放的,是用来判定任务是否完成的命令。
A simplified controller looks like this:
一个简化版的控制器长这样:
MAX_ATTEMPTS = 10
for attempt in range(MAX_ATTEMPTS):
agent.run(goal="Fix failing tests")
result = verify()
if result.passed:
print("Objective completed")
break
save_feedback(result)(代码同上,不翻译。逻辑:最多试 10 次;每次让 agent 去修失败的测试,然后验证;通过就宣布完成并退出,没通过就把反馈存下来,进入下一次。)
This is conceptual code. A working implementation needs an agent integration, error handling, rollback support, timeouts, and persistent state.
这是示意代码。真正能跑的实现,还需要接入 agent、错误处理、回滚支持、超时控制和持久化状态。
But the architecture is already there.
但架构已经都在这里了。
The agent produces a candidate.
agent 产出候选方案。
The verifier evaluates it.
验证器来评估它。
The feedback informs another attempt.
反馈指导下一次尝试。
The controller determines when to stop.
控制器决定什么时候停。
Once one supervised execution reliably produces acceptable results, the process can be connected to a schedule or GitHub event.
等到在有人看着的情况下,单次运行能稳定产出合格的结果,再把这套流程接到定时任务或 GitHub 事件上。
Get one loop working before trying to build an entire autonomous engineering team.
先让一个循环跑通,再去想搭一整支自主工程团队。
5. Why the verifier matters more than another agent5. 为什么验证器比再加一个 agent 更重要
There is a common misconception in AI engineering.
AI 工程里有个常见的误区。
When one model makes mistakes, add another model to review its output.
一个模型出错了,就再加一个模型来审它的输出。
Sometimes independent reviewers help.
独立的审查者有时候确实有用。
But two AI agents agreeing does not mean their conclusion is correct.
但两个 AI agent 意见一致,不代表它们的结论就是对的。
Imagine an agent optimizing a Python function.
设想有个 agent 在优化一个 Python 函数。
It rewrites the implementation and claims a 30% performance improvement.
它重写了实现,声称性能提升了 30%。
A reviewer examines the code and agrees that the optimization looks reasonable.
审查者看了代码,也觉得这个优化看起来挺合理。
Neither opinion proves anything.
这两个看法,什么都证明不了。
The system needs to run correctness tests and reproducible benchmarks.
系统需要跑正确性测试和可复现的基准测试。
If the new function produces incorrect results, reject it.
新函数算出来的结果不对,否掉。
If performance decreases, reject it.
性能反而变差,否掉。
If correctness is preserved and the measured improvement is real, keep the change.
正确性保住了,实测的提升也是真的,才留下这处改动。
This is the principle behind Karpathy's experiments.
Karpathy 那些实验背后,就是这个原则。
The agent generates possibilities.
agent 负责提出各种可能。
An external evaluation determines which possibilities survive.
外部评估决定哪些可能能留下来。
Better models can improve the quality of proposed solutions.
更好的模型,能提高候选方案的质量。
Better verification improves the reliability of the entire system.
更好的验证,能提高整个系统的可靠性。
6. The two problems that can destroy an autonomous loop6. 能毁掉自主循环的两个问题
The first problem is uncontrolled execution.
第一个问题,是执行失控。
An agent might attempt dozens of variations without making meaningful progress.
agent 可能试了几十种变体,却没有任何实质进展。
Every iteration consumes tokens, compute, and sometimes paid infrastructure.
每一轮迭代都在消耗 token、算力,有时还有付费的基础设施。
A loop needs hard budgets, maximum attempt counts, and a way to detect repeated failures.
循环需要硬性预算、最大尝试次数,还要有办法识别出“在重复失败”。
The second problem is more subtle.
第二个问题更隐蔽。
Comprehension debt.
理解债(comprehension debt)。
An autonomous coding system can generate changes faster than its maintainers can understand them.
自主编程系统产出改动的速度,可能比维护者看懂这些改动的速度还快。
Tests pass. Pull requests merge. Development appears faster.
测试通过,PR 合并,开发看上去变快了。
But the gap between what the repository contains and what the engineering team understands keeps growing.
但仓库里实际有什么,和工程团队真正理解了多少,这两者之间的差距在不断拉大。
Eventually, an unexpected production failure exposes that gap.
终有一天,一次意料之外的线上故障,会把这个差距暴露出来。
Passing tests cannot guarantee maintainability, architectural quality, or complete security.
测试通过,保证不了可维护性、架构质量,也保证不了安全上万无一失。
That is why autonomous loops should initially operate on narrow, verifiable tasks.
所以,自主循环一开始只应该用在范围窄、能验证的任务上。
Authentication, payments, critical infrastructure, and irreversible operations still require stronger controls and human judgment.
身份认证、支付、关键基础设施,以及不可逆的操作,仍然需要更强的管控和人的判断。
The objective is not to eliminate engineers from the process.
目标不是把工程师从流程里踢出去。
It is to eliminate repetitive work while preserving engineering responsibility.
而是去掉重复劳动,同时把工程上的责任留在人身上。
7. The metric that actually matters7. 真正重要的指标
The number of agents running is not a productivity metric.
跑了多少个 agent,不是生产力指标。
Neither is the number of prompts executed, tokens consumed, or pull requests opened.
执行了多少条提示词、消耗了多少 token、开了多少个 PR,也都不是。
The useful measure is cost per accepted result.
真正有用的衡量标准是:每个被采纳的结果,花了多少成本。
How much time, compute, and human review did the system require to produce one verified, useful change?
系统要花多少时间、多少算力、多少人工审查,才能产出一个经过验证、真正有用的改动?
A loop that generates fifty patches and gets two accepted may be less efficient than one producing five carefully verified improvements.
一个循环生成五十个补丁、只被采纳两个,可能还不如另一个只产出五个、但每个都仔细验证过的改进来得高效。
This is why the best starting point is rarely an ambitious autonomous development platform.
所以最好的起点,很少会是一个雄心勃勃的自主开发平台。
It is one annoying recurring task with an objective definition of success.
而是一件烦人的、反复出现的、而且“做成了”能客观定义的任务。
Make that task reliable.
先把这件事做稳。
Add memory.
加上记忆。
Enforce a budget.
设定预算。
Automate execution.
让执行自动化。
Then expand.
然后再扩展。
Karpathy's research experiments illustrate what happens when AI can repeatedly test its own proposals against meaningful evidence.
Karpathy 的研究实验展示了:当 AI 能拿有意义的证据,反复检验自己的提议时,会发生什么。
The same principle can transform ordinary software development.
同样的原则,也能改变日常的软件开发。
Prompt engineering still matters, but the competitive advantage is moving toward something larger.
提示词工程依然重要,但竞争优势正在转向更大的东西:
Designing the environment.
设计环境。
Defining success.
定义成功。
Building verification.
搭建验证。
Creating systems that can continue making progress without requiring another human instruction every few minutes.
打造能持续推进的系统,不需要人每隔几分钟就再下一道指令。
A prompt tells an agent what to do.
提示词告诉 agent 该做什么。
A loop gives it a way to discover whether it actually worked.
循环则让它有办法知道:自己到底做成了没有。
The engineers gaining the biggest advantage are not necessarily using smarter models.
拿到最大优势的工程师,用的未必是更聪明的模型。
They are building better systems around the models they already have.
他们是在手头已有的模型周围,搭更好的系统。
And while everyone else is still rewriting prompts, those systems can keep experimenting, correcting mistakes, and producing verified work long after the conversation ends.
当别人还在一遍遍改提示词时,这些系统可以在对话结束很久之后,仍然持续实验、纠错,产出经过验证的成果。
Links in the article原文中的链接
- Phil Schmid — autoresearch (linked in the article)
https://www.philschmid.de/autoresearch - karpathy/autoresearch on GitHub (linked in the article)
https://github.com/karpathy/autoresearch
— 全文完 · End —
原文作者 Lummox (@Lummox_eth);原文无结尾署名。