# Recursive Agent Optimization Actually Works
**作者**: Amar Singh
**日期**: 2026-05-05T01:15:18.000Z
**来源**: [https://x.com/AmarSVS/status/2051470760947159197](https://x.com/AmarSVS/status/2051470760947159197)
---

If you have built an agent harness before, you know how difficult it is to start debugging LLM behaviors, especially once it starts looking even remotely complex. You might rely on external benchmarks, but they are difficult to make and often don’t mimic the real world. You might start looking at traces yourself, but once they start ballooning in the 100s of thousands of tokens, you likely won’t be able to process that yourself.
This leads us to a realization that there needs to be a new paradigm of building harnesses that are capable of fixing their own bugs and improving over time. It sounds insane to say, but AI truly is becoming our last hope of improving other AI systems. This is the philosophy that led us to building HALO.
## What HALO is
HALO (Hierarchical Agent Loop Optimization) is a methodology for building recursively self-improving agent harnesses, powered by a specialized Recursive Language Model (RLM). The core loop has five steps:
1. Collect traces from your harness
2. Feed those traces into our specialized RLM
3. Have the RLM diagnose what is going wrong
4. Feed that diagnosis into a coding agent, which proposes fixes
5. Redeploy, collect new traces, repeat
The key part of this being the specialized RLM that we’ve built, which we call HALO-Engine. It’s a harness itself that is equipped to analyze arbitrarily large trace datasets to find issues. We’ve gone through several iterations to make this harness better than anything else at this task, including other coding harnesses like Claude Code or RLMs out of the box.
## Experimental setup
We tested HALO on AppWorld, a benchmark of nine simulated apps (Spotify, Splitwise, Gmail, Venmo, file system, phone, and others) operable via 457 APIs across 728 tasks. AppWorld scores agents on two metrics: task goal completion (TGC) and the stricter scenario goal completion (SGC), which requires every task in a scenario to complete correctly. SGC is the headline number AppWorld's leaderboard emphasizes.
We vendored the upstream AppWorld harness and patched it to emit traces in our specific HALO format. We iterated on the harness using its dev split, and ensured that the improvements were based on the traces only, while using the benchmark score as a proxy. The model we used for testing was Sonnet 4.6, while HALO-Engine itself was running on GPT 5.5. We did 5 cycles of running the harness, feeding the traces into the engine, and using that diagnosis to patch fixes to the harness.

## What HALO actually found
The scenario completion rate improved from 73.7 to 89.5 in just five cycles. Each cycle had a small change based on the errors from HALO-Engine.
- Cycles 1-2: dominant failure was "Tool not found" at the root, all caused by the api-predictor (cap 20) leaving out either real fallback APIs or both search/show variants of a tool. Cap-bump narrowed the cluster but did not eliminate it because the predictor still didn't think to predict fallback APIs.
- Cycle 3: Fallback-API hint to the predictor's prompt eliminated error_trace_count entirely.
- Cycle 4: Spotify counting tasks exposed an off-by-one / hallucination risk. Modifying the prompt to verify its inputs helped with this tremendously.
- Cycles 5-6: Further improvements to the prompt to verify entity arguments api calls involving albums/songs and tackling other specific hallucination modes.

## What this means
A few patterns showed up here, and they generalize to harnesses beyond AppWorld.
When viewing traces in aggregate, especially with something like HALO-Engine, it’s easy to note repeated failures, where tool calls are messing up, and hallucination patterns. In fact in other experiments, we noticed that GPT 5.5 is able to improve a harness running with traces produced by itself, showing that there is diagnostic value in being able to take a birds-eye view. It’s like an athlete watching film footage after the game. Decisions are hard in the moment but easy to spot after-the-fact.
Even beyond prompt adjustments, HALO can surface insights on if you are missing crucial tools, if tool call arguments or definitions need to be modified, if your harness itself should have separate sub-agent flows, etc. In the AppWorld demo, there were modifications to hard coded configuration variables along with the prompts used to run the harness.
We expect future harness design to incorporate some sort of agent oversight. Even if it isn’t directly applying the fixes, the diagnostic capability itself is valuable. If you have a harness in production, it’s likely you can significantly improve the accuracy using a loop like HALO.
## Try it yourself
The HALO repo, including the AppWorld demo, the engine, and the CLI, is open source (link in reply).
Hosted HALO engine and trace analysis is coming soon to Catalyst. If you want continuous harness optimization without running the engine yourself, that is where it lands next.
## 相关链接
- [Amar Singh](https://x.com/AmarSVS)
- [@AmarSVS](https://x.com/AmarSVS)
- [11K](https://x.com/AmarSVS/status/2051470760947159197/analytics)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [9:15 AM · May 5, 2026](https://x.com/AmarSVS/status/2051470760947159197)
- [11.4K Views](https://x.com/AmarSVS/status/2051470760947159197/analytics)
- [View quotes](https://x.com/AmarSVS/status/2051470760947159197/quotes)
---
*导出时间: 2026/5/5 17:15:17*
---
## 中文翻译
# 递归 Agent 优化确实有效
**作者**: Amar Singh
**日期**: 2026-05-05T01:15:18.000Z
**来源**: [https://x.com/AmarSVS/status/2051470760947159197](https://x.com/AmarSVS/status/2051470760947159197)
---

如果你之前构建过 Agent(智能体)框架,你就会知道开始调试 LLM(大语言模型)的行为有多么困难,尤其是当它开始变得稍微复杂一点的时候。你可能会依赖外部基准测试,但它们很难构建,而且往往不能反映真实世界的情况。你可能会开始自己查看追踪记录,但一旦这些记录膨胀到数十万 Token,你可能就靠自己无法处理了。
这让我们意识到,需要建立一种新的构建框架的范式,这种范式要能够修复自身的 Bug 并随着时间的推移而改进。说起来听起来很疯狂,但 AI 确实正在成为我们改进其他 AI 系统的最后希望。正是这一理念引导我们构建了 HALO。
## HALO 是什么
HALO(Hierarchical Agent Loop Optimization,分层 Agent 循环优化)是一种构建递归式自我改进 Agent 框架的方法论,由一种专门的递归语言模型(RLM)提供支持。其核心循环包含五个步骤:
1. 从你的框架中收集追踪记录
2. 将这些追踪记录输入我们专门的 RLM
3. 让 RLM 诊断出了什么问题
4. 将该诊断输入到一个编码 Agent,该 Agent 会提出修复方案
5. 重新部署,收集新的追踪记录,重复上述步骤
其中的关键部分是我们构建的那个专门的 RLM,我们称之为 HALO-Engine。它本身就是一个框架,配备了分析任意大小的追踪数据集以发现问题的能力。我们经历了几次迭代,使这个框架在这方面比其他任何工具都要好,包括其他编码框架如 Claude Code 或开箱即用的 RLM。
## 实验设置
我们在 AppWorld 上测试了 HALO,这是一个包含九个模拟应用(Spotify、Splitwise、Gmail、Venmo、文件系统、手机等)的基准测试,可通过 457 个 API 运行,涵盖 728 个任务。AppWorld 通过两个指标对 Agent 进行评分:任务目标完成率(TGC)和更严格的场景目标完成率(SGC),后者要求场景中的每个任务都必须正确完成。SGC 是 AppWorld 排行榜强调的关键数据。
我们将上游的 AppWorld 框架引入内部,并打上补丁,使其以我们特定的 HALO 格式输出追踪记录。我们使用其开发集对框架进行了迭代,并确保改进仅基于追踪记录,同时将基准测试得分作为代理指标。我们用于测试的模型是 Sonnet 4.6,而 HALO-Engine 本身运行在 GPT 5.5 上。我们进行了 5 个周期的循环:运行框架,将追踪记录输入引擎,并利用该诊断结果对框架打补丁进行修复。

## HALO 实际发现了什么
仅用五个周期,场景完成率就从 73.7 提高到了 89.5。每个周期都根据 HALO-Engine 报告的错误进行了微小的改动。
- 第 1-2 周期:主要的失败根源是“未找到工具”,全部由 api-predictor(上限 20)导致,它遗漏了真实的备用 API 或工具的 search/show 变体。提高上限缩小了问题范围,但并未完全消除,因为预测器仍然没有想到去预测备用 API。
- 第 3 周期:在预测器的提示中加入备用 API 提示,完全消除了 error_trace_count。
- 第 4 周期:Spotify 计数任务暴露了“差一错误”/幻觉风险。修改提示以验证其输入对此大有帮助。
- 第 5-6 周期:进一步改进提示,以验证涉及专辑/歌曲的实体参数 API 调用,并解决其他特定的幻觉模式。

## 这意味着什么
这里出现了一些模式,它们可以推广到 AppWorld 之外的框架。
当汇总查看追踪记录时,尤其是使用 HALO-Engine 这样的工具时,很容易注意到重复的失败、工具调用出错的地方以及幻觉模式。事实上,在其他实验中,我们注意到 GPT 5.5 能够改进运行由其自身产生的追踪记录的框架,这表明能够采取“全局视角”具有诊断价值。这就像运动员在赛后观看比赛录像。决策在当下很难做出,但在事后却很容易发现。
除了提示词调整之外,HALO 还能让你发现更深层次的见解:比如你是否缺少关键工具,工具调用参数或定义是否需要修改,你的框架本身是否应该拥有独立的子 Agent 流程等。在 AppWorld 演示中,除了用于运行框架的提示词外,还对硬编码的配置变量进行了修改。
我们期望未来的框架设计能包含某种形式的 Agent 监督。即使不是直接应用修复,诊断能力本身也是很有价值的。如果你有一个正在生产环境运行的框架,你可能可以使用像 HALO 这样的循环来显著提高其准确性。
## 亲自试试
HALO 代码库,包括 AppWorld 演示、引擎和 CLI,已经开源(链接在回复中)。
托管式 HALO 引擎和追踪分析功能即将登陆 Catalyst。如果你想要在不自己运行引擎的情况下进行持续的框架优化,那就是下一个落地的功能。
## 相关链接
- [Amar Singh](https://x.com/AmarSVS)
- [@AmarSVS](https://x.com/AmarSVS)
- [11K](https://x.com/AmarSVS/status/2051470760947159197/analytics)
- [Upgrade to Premium](https://x.com/i/premium_sign_up)
- [9:15 AM · May 5, 2026](https://x.com/AmarSVS/status/2051470760947159197)
- [11.4K Views](https://x.com/AmarSVS/status/2051470760947159197/analytics)
- [View quotes](https://x.com/AmarSVS/status/2051470760947159197/quotes)
---
*导出时间: 2026/5/5 17:15:17*