Agent 还是 Workflow:停止权在代码还是模型?
这篇短文用清晰对比解释 Anthropic 提出的 "agents vs workflows" 之分:两者都是多 LLM 调用编排,区别在于控制流的归属。Workflow 的每一步和终止条件由开发者写在代码里,结果可预测,适合固定重复的任务;Agent 把工具集和决策权交给 LLM,由模型自主选择下一步并自行判断何时结束,灵活但不可控。作者特意指出,单次 LLM 调用不算其中任何一种;在任务明确时,Workflow 通常表现更稳,不必盲目追逐 Agent。文章配有多张对比图,适合刚接触 Agent 工程的读者建立基本框架。
Ever since Anthropic dropped the article building effective agents, everyone's been talking about agents and workflows. Both agents and workflows are ways of building more powerful systems with LLMs, and they both involve orchestrating multiple calls to the LLM.
A workflow does this through predetermined steps where you have one LLM call which goes to another call which goes to another call. These predetermined steps are written in code by the developer.
The code itself decides when to stop the program, when to call the next LLM. It's all written into the code itself.
自从 Anthropic 发布《构建高效 Agent》一文以来,所有人都在讨论代理(agent)和工作流。代理和工作流都是利用 LLM 构建更强大系统的方式,两者都涉及对多次 LLM 调用的编排。
工作流通过预定的步骤来实现:一个 LLM 调用接着另一个调用,再接着下一个调用。这些预定步骤由开发者用代码编写。
代码本身决定何时停止程序、何时调用下一个 LLM。一切都写在代码里。
An agent, though, doesn't use predetermined steps. It calls an LLM and gives it a bunch of tools, different options of things that it can do next. The LLM decides which tool to call and then responds to the result of those tools.
The LLM itself decides when to stop the program when it thinks it's finished. In other words, this is the LLM making it up as it goes along, which hands a lot more power to the LLM, but of course makes it less predictable.
然而,代理不使用预定步骤。它调用 LLM,并给它一组工具,也就是接下来可以做的不同选项。LLM 决定调用哪个工具,然后根据这些工具的结果作出回应。
LLM 自己决定在认为任务完成时停止程序。换句话说,这是 LLM 在随机应变,这赋予了 LLM 更多权力,但当然也降低了可预测性。
Both agents and workflows involve multiple LLM calls. If you're just making one LLM call, it's not really either of those things.
The crucial difference is who decides when to stop:
代理和工作流都涉及多次 LLM 调用。如果你只做一次 LLM 调用,那它其实不算其中任何一种。
关键区别在于由谁决定何时停止:
Agents are really good in situations where the steps to complete the task are not particularly clear, where it needs the ability to improvise to figure out its way through a difficult problem.
But workflows are great for things that need to be done the same way again and again. Workflows are often unfairly maligned because they're not as exciting and sexy as agents.
You'll often get better results from using a workflow than using an agent, as long as the task is clearly specified.
代理非常适合那些完成任务步骤不太清晰的情况,它需要即兴发挥的能力,在难题中摸索出自己的道路。
但工作流非常适合那些需要一遍遍以相同方式完成的事情。工作流常常被不公平地贬低,因为它们不像代理那样令人兴奋和时髦。
只要任务定义清晰,使用工作流往往能得到比使用代理更好的结果。
For instance, you can use a workflow to parallelize work. Let's say we take in a chunk of text, we can split it into two parts, summarize each of them independently, and then summarize the summaries afterwards.
例如,你可以用工作流来并行化处理。假设我们拿到一段文本,可以把它分成两部分,分别独立总结,之后再对摘要进行总结。
That's the difference between agents and workflows. I don't know whether it's me being old and boring, but I am more excited by workflows than agents.
这就是代理和工作流之间的区别。不知道是不是我这个人又老又无趣,但我对工作流的热情确实高于代理。