
Agents are useful because they help us automate work by taking actions in the real world. But getting agents to do valuable work reliably takes more than just a good model: it requires a carefully designed harness that's fit to a set of tasks.智能体之所以有用,是因为它们能帮助我们在现实世界中采取行动,从而自动化工作。但让智能体可靠地完成有价值的工作,仅靠一个好的模型是不够的:它需要一个精心设计的外挂框架,以适应一组特定的任务。
The core agent algorithm is simple: give the LLM context and let it call tools in a loop until it's done. This is the most fundamental loop. But it’s far from the only loop that powers agents. Swyx recently wrote a great piece on "loopcraft: the art of stacking loops", the idea that you can stack and extend loops to build more effective agents.核心智能体算法很简单:给大语言模型提供上下文,让它在循环中调用工具,直到任务完成。这是最基本的循环。但它远非驱动智能体的唯一循环。Swyx 最近写了一篇关于"循环工艺:堆叠循环的艺术"的精彩文章,核心思想是你可以堆叠和扩展循环,以构建更高效的智能体。
Here's how we think about that stack, and how to instrument each level with LangChain primitives.以下是我们对这个堆叠的理解,以及如何使用 LangChain 原语对每个层级进行插桩。
Loop 1: The Agent循环 1:智能体
At its core, an agent is just a model calling tools in a loop until a task is complete.从本质上讲,智能体就是一个模型在循环中调用工具,直到任务完成。
.png)
This is what LangChain’s create_agent gives you. Pick any model, plug in tools, and you have a working agent loop. Tools are what give the agent the power to take action in the real world.这就是 LangChain 的 create_agent 所提供的功能。选择任意模型,接入工具,你就拥有了一个可运行的智能体循环。工具赋予智能体在现实世界中采取行动的能力。
Take our internal docs agent as an example (which we’ll use as a motivating example for the rest of this blog). At the first loop level, it receives a request for a documentation improvement, the model plans and draft changes, and it uses tools to clone repos, read files, write docs, open a pull request, etc.以我们的内部文档智能体为例(我们将在本文剩余部分以此作为驱动示例)。在第一个循环层级,它接收到文档改进请求,模型进行规划并起草修改,然后使用工具来克隆仓库、读取文件、撰写文档、发起拉取请求等。

Level 2: Verification loop层级 2:验证循环
The agent loop gets work done, but it doesn't always produce correct or consistent work on the first pass. When consistency matters, it's often useful to wrap it in a verification loop that checks the output and sends feedback back to the model when it falls short.智能体循环能够完成工作,但它并不总能在第一次尝试时就产生正确或一致的成果。当一致性很重要时,将其包装在一个验证循环中通常会很有用,该循环检查输出并在不达标时将反馈发送回模型。
.png)
The verification loop adds a grader: something that checks the agent's output against a rubric and, if it fails, sends the result back with feedback. Graders can either be deterministic or agentic (LLM as a judge is a classic example, here).验证循环增加了一个评分器:它根据评分标准检查智能体的输出,如果未通过,则将结果连同反馈一起返回。评分器可以是确定性的,也可以是基于智能体的(大语言模型作为评判者是这里的经典例子)。
RubricMiddleware handles this pattern, or you can wire it up with an after_agent hook on create_agent.RubricMiddleware 处理这种模式,或者你也可以 digitally 你也可以通过 create_agent 上的 after_agent 钩子来连接它。
For our docs writer example, the grader runs tests after each attempt, checking that all links resolve, all CI checks pass, and the diff is scoped to what was actually requested. No manual review needed to catch those classes of error.以我们的文档撰写器为例,评分器在每次尝试后运行测试,检查所有链接是否可解析、所有 CI 检查是否通过,以及差异范围是否仅限于实际请求的内容。无需人工审查即可发现这类错误。
One tradeoff: adding verification increases latency and cost per run. It's worth it when quality matters more than speed, which is most production use cases.一个权衡是:增加验证会提高每次运行的延迟和成本。当质量比速度更重要时,这是值得的,而大多数生产用例正是如此。

Level 3: Event driven loop层级 3:事件驱动循环
One of the most important parts of agent development is the integrations layer: connecting your agent to your ecosystem so that it can run in the background.智能体开发中最重要的部分之一是集成层:将你的智能体连接到你的生态系统中,使其能够在后台运行。
The event-driven loop connects your agent to your ecosystem. An event fires — a new document lands, a schedule triggers, a webhook arrives — and the agent runs. The agent isn't something you invoke manually; it's a component running continuously inside a larger system.事件驱动循环将你的智能体连接到你的生态系统。一个事件触发——新文档到达、计划任务触发、webhook 到达——智能体便开始运行。智能体不是你需要手动调用的东西;它是一个在更大系统中持续运行的组件。

LangSmith Deployment supports the trigger infrastructure, including support for cron schedules and webhooks. One popular example of crons in action is “heartbeats” in openclaw, which turn your agent into an always-on, proactive assistant.LangSmith Deployment 支持触发基础设施,包括对 cron 计划和 webhook 的支持。定时任务的一个流行例子是 openclaw 中的"心跳",它将你的智能体转变为一个始终在线、主动响应的助手。
Our docs agent is powered by Fleet, our no-code agent builder. Fleet's channels and schedules handle event-driven and cron-style triggers. We use a channel to fire off the docs agent whenever a message is sent in our #docs-plz Slack channel.我们的文档智能体由 Fleet 驱动,这是我们的无代码智能体构建器。Fleet 的频道和计划任务处理事件驱动和 cron 风格的触发器。我们使用一个频道,每当我们的 #docs-plz Slack 频道中有消息发送时,就会触发文档智能体。

Level 4: Hill climbing loop层级 4:爬坡循环
The first three loops automate work. The fourth (and arguably most important) automates improvement!前三个循环自动化工作。第四个(也可以说是最重要的)自动化改进!

Every agent run produce a trace: a record of what the model did, the tools it called, grader feedback, etc. Those traces contain high value signal regarding what's working and what isn't. The hill climbing loop runs an analysis agent over those traces and uses the findings to rewrite the harness with improved configuration. That can include prompt/tool tweaks or grader tweaks.每次智能体运行都会产生一个追踪记录:模型做了什么、调用了哪些工具、评分器反馈等的记录。这些追踪记录包含关于什么有效、什么无效的高价值信号。爬坡循环在这些追踪记录上运行一个分析智能体,并利用发现结果重写配置更优的外挂框架。这可以包括提示/工具调整或评分器调整。
In LangSmith, you can use Engine, our trace analysis agent, to instrument this fourth loop.在 LangSmith 中,你可以使用 Engine(我们的追踪分析智能体)来实现这第四个循环。
Wrapping up the docs agent analogy, we run engine over the docs agent traces to detect any issues. When multiple traces signal a potential problem, an issue is filed requesting changes to the offending prompt or tool.以文档智能体为例,我们在文档智能体的追踪记录上运行 engine 来检测任何问题。当多个追踪记录表明存在潜在问题时,会提交一个 issue,请求对有问题的提示或工具进行修改。

The key move here is that the return arrow doesn't just loop back to the top — it reaches inside and updates the agent loop directly. Each cycle of the outer loop makes the inner loops more effective.这里的关键在于,返回的箭头不只是循环回到顶部——它深入到内部并直接更新智能体循环。外层循环的每个周期都使内层循环更加有效。
Looking forward: prompt and tool configuration are the most simple things to improve, but they're not the only options.For teams running open-weight models, the hill climbing loop can feed into RL fine-tuning, using trace or eval outcomes as training signal to improve the model itself.Auxiliary context like memory and retrieved skills can be improved the same way. The loop is the pattern; what it optimizes is up to you.展望未来:提示和工具配置是最简单的改进对象,但它们并非唯一的选择。对于运行开源权重模型的团队,爬坡循环可以反馈到 RL 微调中,使用追踪或评估结果作为训练信号来改进模型本身。记忆和检索到的技能等辅助上下文也可以用同样的方式改进。循环是模式;它优化什么由你决定。
Human oversight and expertise人工监督与专业知识
Automation doesn't mean removing humans from the loop. At every level, there are natural points where human oversight adds value. An automated grader can check whether links resolve; it takes a human to notice the framing is wrong for the audience. That kind of judgment, earned from context, experience, and taste, is exactly where human review earns its place.自动化并不意味着将人类排除在循环之外。在每个层级,都存在人工监督增加价值的自然节点。自动化评分器可以检查链接是否可解析;但需要人类来注意表述方式对受众来说是否恰当。这种来自语境、经验和品味的判断,正是人工审查的价值所在。
Some expertise should be codified in the prompt/tools themselves, but for sensitive actions, live human review is essential (think financial transactions, DB operations, etc). LangChain makes it straightforward to instrument these touch points in every loop:有些专业知识应该被编码到提示/工具本身中,但对于敏感操作,实时人工审查是必不可少的(想想金融交易、数据库操作等)。LangChain 使得在每个循环中插桩这些接触点变得简单:
- In the agent loop, require human input before sensitive actions/tool calls在智能体循环中,要求在执行敏感操作/工具调用前进行人工输入
- In the verification loop, a human can act as the grader for sensitive workflows在验证循环中,人类可以作为敏感工作流的评分器
- In the application loop, a human can approve outputs before they’re returned to the end user在应用循环中,人类可以在输出返回给最终用户之前批准输出
- In the hill climbing loop, harness improvements can flow through human review before deployment在爬坡循环中,外挂框架的改进可以在部署前经过人工审查
All of LangChain’s open source frameworks make adding a “human in the loop” a first class primitive.LangChain 的所有开源框架都将添加"人在回路"作为一等原语。
Putting it all together综合起来
In case you’d prefer a more tabular view, here’s how those four loops stack together:如果你更喜欢表格视图,以下是这四个循环的堆叠方式:
This is what loop engineering — or loopcraft, as swyx puts it — actually looks like in practice. AI leaders like Steipete, Boris, and Andrej have all arrived at the same conclusion: the potential in agents is in the loops you build around them.这就是循环工程——或者说如 swyx 所称的循环工艺——在实践中的真实样子。像 Steipete、Boris 和 Andrej 这样的 AI 领导者都达成了相同的结论:智能体的潜力在于你围绕它们构建的循环。
We’ve been thinking about loops 1 and 2 for a while. But focus should pivot to loops 3 and 4 where value compounds by embedding agents into your ecosystem that continuously improve in response to your criteria.我们思考循环 1 和 2 已经有一段时间了。但重点应该转向循环 3 和 4,因为在这些循环中,通过将智能体嵌入到你的生态系统中,价值会根据你的标准持续改进而复合增长。
Satya frames the organizational stakes: companies that build learning loops early,where human judgment and token capital compound together, will build an advantage that's hard to replicate.Satya 阐述了组织层面的利害关系:那些早期构建学习循环的公司,在那里人类判断和算力资本共同复合增长,将建立起难以复制的优势。
Acknowledgements致谢
Thanks to Vivek, Mason, Harrison, and Hunter for thoughtful review.感谢 Vivek、Mason、Harrison 和 Hunter 的周到审阅。
Reference参考
- deepagents quickstartdeepagents 快速入门
- create_agent docscreate_agent 文档
- rubric middlewarerubric 中间件
- cron jobs, webhookscron 任务、webhook
- langsmith enginelangsmith engine
- fleet channelsfleet 频道






