循环工程的艺术
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.
核心智能体算法很简单:为 LLM 提供上下文,并让它在循环中调用工具直到完成。这是最基本的循环。但这远非驱动智能体的唯一循环。
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.
,即你可以通过堆叠和扩展循环来构建更高效的智能体。
Here's how we think about that stack, and how to instrument each level with LangChain primitives.
以下是我们对该技术栈的思考,以及如何使用 LangChain 原语对每一层进行插桩。
Loop 1: The Agent
循环 1:Agent
At its core, an agent is just a model calling tools in a loop until a task is complete.
从本质上讲,agent 就是一个 model,在循环中调用 tools 直到任务完成。
[
[
](https://x.com/sydneyrunkle/article/2066928783534289358/media/2066901901262696449)
](https://x.com/sydneyrunkle/article/2066928783534289358/media/2066901901262696449)
This is what LangChain’s
这就是 LangChain 的
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.
提供给你的。选择任何模型,插入工具,你就拥有了一个可运行的智能体循环。工具正是赋予智能体在现实世界中采取行动的能力的关键。
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.
以我们内部的文档 agent 为例(我们将在本博客的其余部分将其作为启发性示例)。在第一个循环层级,它接收文档改进请求,模型进行规划并起草更改,然后使用工具克隆仓库、读取文件、编写文档、发起 pull request 等。
[
[
](https://x.com/sydneyrunkle/article/2066928783534289358/media/2066...