文章摘要
文章核心观点是:可靠的AI代理系统需要确定性的控制流程和软件编码,而非复杂的提示链。当前基于提示的方法存在非确定性和难以验证的问题,应将逻辑从自然语言转移到运行时环境中,建立明确的状态转换和验证检查点,同时需要积极的错误检测机制来避免系统静默失败。
文章总结
标题:智能体需要控制流,而非更多提示
来源:https://bsuh.bearblog.dev/agents-need-control-flow/
发布日期:2026年5月7日
核心观点:要构建能可靠处理复杂任务的智能体,关键在于将确定性控制流编码到软件中,而非依赖越来越复杂的提示链。
当你在提示中使用"必须"或"不得跳过"等强调词时,实际上已经触及了提示工程的瓶颈。这就像使用一种编程语言,其语句只是"建议",函数可能在返回"成功"的同时产生幻觉输出——这样的系统既无法进行可靠推理,其稳定性也会随复杂度增加而崩溃。
软件之所以能扩展,依靠的是递归可组合性:通过库、模块和函数构建系统。这种代码化的结构具有可预测性,支持局部推理。而提示链缺乏这种特性——虽然适用于简单任务,但本质上具有非确定性、弱规范性和难以验证的特点。
要建立可靠系统,必须将逻辑从自然语言描述转移到运行时环境中。我们需要确定性框架:明确的状态转换和验证检查点,将大语言模型视为系统组件而非系统本身。
但确定性编排只是成功的一半。在容易发生静默故障的系统中,缺乏主动错误检测的智能体只会更快得出错误结论。若没有程序化验证机制,我们只剩下三种选择: 1. 人工监督:全程安排人员拦截错误 2. 事后审计:运行结束后进行全面验证 3. 听天由命:直接接受输出结果
(注:译文保留了原文的技术论证逻辑,删减了重复强调的修辞,将关键概念如"deterministic control flow"译为"确定性控制流","silent failure"译为"静默故障",并采用技术文档常见的简洁句式结构。)
评论总结
以下是评论内容的总结:
1. LLM的局限性与确定性不足
- 主要观点:LLM本质上是非确定性的,试图通过提示词获得可靠性和确定性是不现实的。
- 关键引用:
- "If you're trying to get reliability and determinism out of the LLM, you've already lost" (评论1)
- "LLMs are not everything we're looking for out of AI" (评论8)
2. 转向软件编写而非直接执行任务
- 主要观点:应该让LLM编写软件来完成任务,而不是在运行时直接执行任务。
- 关键引用:
- "move from using LLMs at run time to accomplish a task to using LLMs to write software to accomplish the task" (评论2)
- "the breakthrough in AI coding was... that a lot of the core process execution moved out of the LLM prompt and into the harness" (评论4)
3. 控制流与验证层的重要性
- 主要观点:需要建立控制流和验证层来确保LLM输出的质量。
- 关键引用:
- "Everyone is building the permission layer. Almost nobody is building the verification layer" (评论21)
- "implement quality control gates, everything works better" (评论20)
4. 混合架构的可行性
- 主要观点:可以结合确定性系统和非确定性LLM的优势。
- 关键引用:
- "in-between non-deterministic LLM work they had deterministic nodes" (评论10)
- "There's probably nothing that prevents mixing both approaches" (评论24)
5. 接受非确定性并设计容错机制
- 主要观点:应该接受LLM的非确定性,并设计相应的容错机制。
- 关键引用:
- "LLMs do not run deterministicly and that is ok" (评论29)
- "assume some failure rate and find compensation control around it" (评论29)
6. 工具与框架的发展
- 主要观点:已有多种工具和框架(如Langgraph、BAML、DSPy等)可以帮助更好地利用LLM。
- 关键引用:
- "we have Langgraph, BAML etc" (评论3)
- "frameworks like DSPy and PydanticAI... allow you to structure LLM calls" (评论28)
7. 与传统编程的结合
- 主要观点:可以将LLM与传统编程方法结合使用。
- 关键引用:
- "you're still allowed to create workflows tying together LLMs and agents" (评论30)
- "If you really need something imperative, then write something imperative!" (评论23)
8. 对当前代理系统的批评
- 主要观点:当前的代理系统可能过于复杂或低效。
- 关键引用:
- "Agents are just reinventing microservices... in the most inefficient way" (评论16)
- "all harnesses are wrong in this respect, some of them deeply so" (评论27)