← 返回 2026-10-06

基于可复用插件的智能体框架递归自改进 PluginRSI: Recursive Improvement of Agent Harnesses with Reusable Plugins

Yaorui Shi, Yuchun Miao, Yuxin Chen, Jiayuan Zhang, Yueqing Sun, Xierui Song, Xiang Wang, An Zhang 📅 2026-09-26 👍 8 2026-11-11 18:30
LLM智能体 插件化架构 智能体框架优化 自动化搜索 递归自改进

将智能体框架拆解为可积累复用的插件,通过插件变异与重组实现递归优化

前置知识

智能体框架(Harness)

Harness 是包裹语言模型的「脚手架」程序,定义智能体与环境交互的全部方式:提供哪些工具、扮演什么角色、遵循哪些技能指令与流程、如何存取记忆。同一个模型配上不同 harness,在同一基准上的成绩可以相差几十个百分点。它以普通代码形式存在,可以在完全不改动模型参数的情况下被编辑和替换。

本文的全部内容就是如何自动优化 harness,理解这一概念是读懂优化对象 $H = H(W,P)$ 的前提。

递归自改进(Recursive Self-Improvement, RSI)

指智能体利用自身能力改进自身系统的过程:模型或其外围程序在运行中根据执行反馈不断生成更强的版本,形成「改进产生更强改进者」的循环。本文特指不动模型权重、只优化 harness 的递归框架优化:由一个固定的提议者模型驱动搜索,改进完全体现在外围代码上。

PluginRSI 就是一种 RSI 算法,标题中的 Recursive Improvement 正是指这一循环,理解 RSI 才能明白作者的长期愿景。

插件化设计与标准化接口

把 harness 中的每个机制(角色、工具、技能、记忆)封装成独立可替换的组件:YAML 清单声明接口与配置(输入输出 schema、提示词、rubric、元数据),Python 代码实现行为。工作流只通过统一方法(如 Tool.execute、Memory.retrieve)调用插件,不关心内部实现,因此可以单独替换某个插件而不影响其余部分。

插件化是本文方法成立的基础:只有接口解耦了,「只改一个插件、其余固定」的受控变异实验才可行,机制贡献才能被单独度量。

提议者-求解者架构

搜索框架中的双角色分工:求解者(solver)是实际执行任务的语言模型(推理档位设为 none),产生轨迹与得分;提议者(proposer)是另一个分析执行反馈、提出改进方案的语言模型(推理档位设为 xhigh)。两者都不做梯度更新,所有改进都体现为 harness 代码的变更,评估成本以 solver rollout 次数计量。

论文的优化循环、开销分析和全部超参数(如每轮 8 个变异提议)都围绕这两个角色展开,不分清二者就无法理解实验预算。

Held-in / Held-out 评估协议

把基准任务划分为优化过程可见的 held-in 集与完全不参与搜索的 held-out 集。本文在 SWE-bench Verified 上做 400/100 划分,在 held-in 上选出最优 harness 后冻结,再测 held-out 与跨求解模型的表现,用于检验改进是否只是对优化任务的过拟合。所有自动优化方法共享同一划分。

论文几乎每张表都同时报告两种得分,而「held-out 增益大于 held-in 增益」正是其最有说服力的核心证据。

研究动机

智能体的实际表现主要由包裹模型的 harness 决定:它组织工具、角色、技能与流程,同一模型在 SWE-bench Verified 上仅因 harness 不同,resolve rate 就能从约 38%(ReAct 零样本)波动到 55% 以上。2025-2026 年出现了用 LLM 迭代重写完整 harness 实现的递归优化方法,如 Darwin-Godel Machine(DGM)与 Meta-Harness,但这类「整程序重写」存在两大结构性缺陷。其一,多种机制(故障定位策略、补丁生成习惯、测试流程等)耦合在同一份代码里,一次重写同时改动所有机制,单个机制的贡献无法被单独度量,提议者难以判断哪个改动真正有效,搜索容易反复收敛到相似设计、难以探索新机制。其二,已经验证有效的局部机制难以保存:下一轮重写可能顺手覆盖掉它,改进无法跨迭代积累成可复用经验。实验中 Meta-Harness 的 held-out 分数随迭代明显波动,25 轮后 GPT-5.6 Terra 优化下仅 55.00%,正是这种「走两步退一步」现象的体现。

本文的目标是本文的目标是把 harness 演化从「每轮重写整个程序」改造为「围绕可复用机制的积累与重组」。具体而言:将 harness 形式化为插件参数化对象 $H = H(W, P)$,其中 $P$ 是从共享插件库中选出的机制集合(角色、工具、技能、记忆四类),$W$ 是调度插件调用时序与信息流的 workflow;在求解模型 $\Theta$ 与提议者均固定的前提下,通过搜索最大化期望回报 $J(H) = \mathbb{E}_{x\sim\mathcal{D},\,\tau\sim\Phi(\cdot\mid x,H,\Theta)}[r(\tau,x)]$。方法需要做到三点:(1) 单个机制可以在其余 harness 完全固定时被独立改进与验证;(2) 有实证增益的机制版本被永久保留在共享库中供后续所有候选复用;(3) 每轮能从不断变大的库中重组出更强的新 harness 候选,最终在不重训模型的情况下持续提升 held-out 性能。

与已有工作不同的是,已有工作分两路:提示词级优化(如 GEPA 的反思式 prompt 进化)只改指令,表达力有限;整程序搜索(DGM、Meta-Harness)表达力强但机制不可分。产业界的模块化 harness 实践(DeepSeek Harness 的「Everything is a plugin」、Claude Code 的插件系统)已经把机制做成可替换组件,但组件由人类专家手动设计与组织。本文的独特切入是把这个工程理念引入自动递归优化:让「插件」成为优化的一等公民——用标准化接口(YAML 清单 + Python 实现)把机制实现与调用它的 workflow 彻底解耦,从而第一次使机制级的受控实验(换一个插件、其余字节不变)、机制级信用分配(minibatch 分数差直接归因于该插件)与机制级复用(版本化插件库跨候选、跨 harness 传递)同时成为可能,把「发现机制」与「组装 harness」解耦成两个互补的搜索算子。

核心方法

直觉上,与其每轮推倒重写整座房子,不如把好用的预制构件存入仓库:每次只实测改进一个构件,再定期用全部存货重新组装房子。技术路线上,harness 被表示为 $H = H(W, P)$:$P$ 是选用的插件集合(每个插件含 YAML 规格与 Python 实现,覆盖角色、工具、技能、记忆四类),$W$ 是协调插件调用与信息流的 workflow,$H$ 是把它们编译为可执行 harness 的确定性程序。优化从初始 harness $H_0 = H(W_0, P_0)$($P_0 \subseteq L$,$L$ 为 75 个插件的种子库)出发,每轮迭代两个阶段:(1) 插件变异——并行生成 $N=8$ 个候选,各自在独立采样的 $b=20$ 任务平衡 minibatch 上做受控对比,有增益的变异版入库;(2) harness 重组——提议者从更新后的库中挑选插件子集并修订 workflow,在全量 400 个 held-in 任务上评估,胜过 incumbent 则接管。共 $T=15$ 轮迭代,返回 held-in 最优 harness。

核心创新是把「机制级归因 + 经验累积」引入 harness 搜索,这是与整程序重写的本质区别。变异阶段保持 workflow 与其余插件完全不变,只替换单个插件,得到 $H_i = H(W, (P\setminus\{p_i\})\cup\{p_i'\})$,于是 minibatch 分数差可以干净地归因到这一个机制;每个 minibatch 由 10 个解出与 10 个未解出任务组成,迫使提议者同时审视「哪里失败」与「哪里可能退化」,各分支独立采样也带来多样探索信号。有实证增益($S_{\mathcal{M}}[H_i] > S_{\mathcal{M}}[H]$)的插件版本被写入按 kind/name/version 版本化管理的共享库,供后续所有候选复用;重组阶段负责全局组合,挑选插件并重写 $W \to W'$。消融证明闭环缺一不可:去掉变异 Kimi-K3 held-out 从 69.00% 跌至 57.00%,去掉重组跌至 59.00%;而只给 Meta-Harness 挂插件库几乎无增益(63.00% 到 64.00%),说明增益来自完整闭环而非库本身。

方法步骤详情

完整流程(Algorithm 1):初始化时种子库 $L$ 含 75 个插件(角色 20、工具 16、技能 31、记忆 8),从论文与开源系统抽取并经人工校验;初始 harness 只装 coder 角色、terminal 工具、debugging 技能、experience-bank 记忆 4 个插件和简短 ReAct 式 workflow。每轮分两步:插件变异——为 $N=8$ 个分支各采样 10 解出 + 10 未解出的 minibatch,提议者读代码与轨迹后选一个插件产出修改版,重编译对比,若 $S_{\mathcal{M}}[H_i] > S_{\mathcal{M}}[H]$ 则入库;harness 重组——综合变异结果与历史反馈,选 $P' \subseteq L$ 并修订 $W \to W'$,新候选 $H' = H(W', P')$ 在 400 个 held-in 任务上评估,更优则替换。每轮成本 $400 + 8 \times 20 = 560$ 次 solver rollout,共 15 轮;插件按 kind/name/version 版本化存储。

技术新颖性

新颖性体现在三层。表示层:首次把递归 harness 优化的搜索对象定义为「插件参数化的 harness」,用版本化包、JSON Schema 配置与统一类别接口(Role.render、Tool.schema/execute、Skill.load、Memory.update/retrieve)实现机制与工作流彻底解耦,比 AgentSquare 等模块化 workflow 搜索粒度更细——覆盖可执行工具与记忆机制而非仅提示词编排。搜索层:把进化计算的「局部变异 + 全局重组」两算子显式分配到两个阶段,并用平衡 minibatch 配对比较做机制级筛选,相当于给黑盒程序搜索加上组件级信用分配,这是 GEPA(提示词级)与 DGM/Meta-Harness(整程序级)都不具备的。系统层:插件库成为跨迭代、跨 harness、跨任务甚至跨模型的可迁移资产——复用进化库使后续从初始 harness 出发的优化 2 步达 69%(不复用 65%),这是改进锁死在单一血统里的整程序重写结构上做不到的;发现的机制本身也可解释,如失败感知终端反馈在筛选批把 10/20 提到 14/20。

Overview of PluginRSI. (1) Plugin mutation explores individual plugin changes in parallel while keeping the remaining harness fixed. (2) Harness recomposition selects plugins from the updated library and revises the workflow to construct a new harness candidate.
Figure 2: Overview of PluginRSI. (1) Plugin mutation explores individual plugin changes in parallel while keeping the remaining harness fixed. (2) Harness recomposition selects plugins from the updated library and revises the workflow to construct a new harness candidate.
Python implementation of the initial harness workflow.
Figure 6: Python implementation of the initial harness workflow.
Examples of plugin and harness manifests. (a) plugin.yaml defines a terminal tool and its instance configuration. (b) harness.yaml assembles a harness by mapping workflow aliases to versioned plugins and their configurations.
Figure 8: Examples of plugin and harness manifests. (a) plugin.yaml defines a terminal tool and its instance configuration. (b) harness.yaml assembles a harness by mapping workflow aliases to versioned plugins and their configurations.

实验结果

SWE-bench(Table 1):GPT-5.6 优化 held-out 65.00%,最强基线 Meta-Harness 55.00%;Kimi-K3 优化 69.00% 对 63.00%,held-out 增益大于 held-in(6-10 对 2.5-4pp),非过拟合。迁移:GPT 版换 Kimi/GLM-5.2 得 60.00%/52.00%,Kimi 版换 GPT/GLM 均 64.00%。终端任务(Table 2):69.5%/73.3% 对 Meta-Harness 64.4%/66.7%。问答(Table 3):总体 0.675 对 0.638。附加对比(Table 7):held-out 超其余方法 6-14pp。效率(Figure 3/13):更少 rollout 超基线全预算,token 输入/输出 +7.5%/+19.8%。消融(Table 4):去变异/去重组/去初始插件 = 57.00/59.00/67.00%。库演化(Figure 4/5):75→132 个插件、候选约 1300 LoC(基线 400);复用进化库 2 步达 69% 对 65%。

Comparison on SWE-bench Verified. Harnesses are optimized and selected on 400 held-in tasks, then fixed for evaluation across solver backbones. Values are resolve rates (%).
Table 1: Comparison on SWE-bench Verified. Harnesses are optimized and selected on 400 held-in tasks, then fixed for evaluation across solver backbones. Values are resolve rates (%).
Results on Terminal-Bench-2.1 with Kimi-K3. Values are resolve rates (%).
Table 2: Results on Terminal-Bench-2.1 with Kimi-K3. Values are resolve rates (%).
Results on QA benchmarks. We optimize harnesses on 150 tasks from three held-in domains. Both optimization and evaluation are on Kimi-K3. Values are accuracies.
Table 3: Results on QA benchmarks. We optimize harnesses on 150 tasks from three held-in domains. Both optimization and evaluation are on Kimi-K3. Values are accuracies.
Ablation study on SWE-bench Verified. Harnesses are optimized and selected with Kimi-K3 on 400 held-in tasks, then fixed for evaluation across solver backbones.
Table 4: Ablation study on SWE-bench Verified. Harnesses are optimized and selected with Kimi-K3 on 400 held-in tasks, then fixed for evaluation across solver backbones.
Hyperparameters.
Table 5: Hyperparameters.
Model configurations for the proposer and solvers.
Table 6: Model configurations for the proposer and solvers.
Results on SWE-bench Verified with Kimi-K3 as both proposer and solver. Values are resolve rates (%).
Table 7: Results on SWE-bench Verified with Kimi-K3 as both proposer and solver. Values are resolve rates (%).
Sources used to construct the seed plugin library.
Table 8: Sources used to construct the seed plugin library.
Composition of the seed plugin library. Coverage is summarized by function.
Table 9: Composition of the seed plugin library. Coverage is summarized by function.
Plugin interfaces exposed to the workflow.
Table 10: Plugin interfaces exposed to the workflow.
Optimization dynamics. Held-in and held-out resolve rates of the best held-in harness against cumulative solver rollouts. PluginRSI yields higher performing harness with fewer solver rollouts, and held-in performances aligns better with held-out scores.
Figure 3: Optimization dynamics. Held-in and held-out resolve rates of the best held-in harness against cumulative solver rollouts. PluginRSI yields higher performing harness with fewer solver rollouts, and held-in performances aligns better with held-out scores.
Plugin reuse effectiveness. On held-out tasks, optimizing from initial harness w/ the evolved plugin library accelerates convergence.
Figure 4: Plugin reuse effectiveness. On held-out tasks, optimizing from initial harness w/ the evolved plugin library accelerates convergence.
Plugin accumulation statistics. (a) Number of plugins in the plugin library. (b) Candidate implementation size during optimization.
Figure 5: Plugin accumulation statistics. (a) Number of plugins in the plugin library. (b) Candidate implementation size during optimization.
Repair-scope control in the coder role. The mutated instructions specify where to place guards, transactions, or cleanup when repairing persistent mutations.
Figure 9: Repair-scope control in the coder role. The mutated instructions specify where to place guards, transactions, or cleanup when repairing persistent mutations.
Incremental evidence retrieval in the memory plugin. Mutation replaces retrieval by lexical overlap with deduplication and summaries of entries not previously returned.
Figure 11: Incremental evidence retrieval in the memory plugin. Mutation replaces retrieval by lexical overlap with deduplication and summaries of entries not previously returned.
Failure-aware terminal feedback. The mutated tool interprets command output and tracks repeated failures to guide subsequent checks.
Figure 12: Failure-aware terminal feedback. The mutated tool interprets command output and tracks repeated failures to guide subsequent checks.
Token cost analysis. (a) Total token usage per solver rollout, including solver and proposer tokens. (b) Solver tokens per rollout. (c) Proposer tokens per proposal, with plugin mutation and harness recomposition reported separately.
Figure 13: Token cost analysis. (a) Total token usage per solver rollout, including solver and proposer tokens. (b) Solver tokens per rollout. (c) Proposer tokens per proposal, with plugin mutation and harness recomposition reported separately.
查看结构化数据
任务指标本文基线提升
SWE-bench Verified held-out(GPT-5.6 Terra 优化) resolve rate (%) 65.00 Meta-Harness 55.00 +10.00pp
SWE-bench Verified held-out(Kimi-K3 优化) resolve rate (%) 69.00 Meta-Harness 63.00 +6.00pp
SWE-bench Verified held-out(Kimi 优化迁移到 GLM-5.2) resolve rate (%) 64.00 Meta-Harness 59.00 +5.00pp
Terminal-Bench-2.1 held-out(Kimi-K3) resolve rate (%) 73.3 Meta-Harness 66.7 +6.6pp
QA 五域 held-out(250 题,Kimi-K3) accuracy 0.588 Meta-Harness 0.568 +0.020
QA 总体(held-in + held-out 平均) accuracy 0.675 Meta-Harness 0.638 +0.037
SWE-bench Verified held-out(Kimi-K3,附加基线) resolve rate (%) 69.00 AHE 63.00 / SkillOPT 60.00 / A-Evolve 57.00 / DGM 55.00 +6.00 至 +14.00pp
消融:SWE-bench held-out(Kimi-K3) resolve rate (%) 69.00(完整方法) 去插件变异 57.00 / 去 harness 重组 59.00 两个阶段各贡献约 10-12pp

局限与改进

作者承认三点局限:(1) 评估在固定任务集上只跑 15 轮迭代,动态任务分布下的长期演化与不断增长的库管理尚未探索;(2) 机制迁移强依赖任务域与求解模型,QA 各域几乎不重叠,held-out 增益仅从 0.568 到 0.588(数学策略搬不到法律题上);(3) 插件变异在「其余固定」前提下评估,发现不了需与其他插件或 workflow 协同变化才生效的机制。我的补充观察:其一,minibatch 仅 20 题,配对比较统计功效有限,1-2 题波动即可决定入库,噪声增益可能混入库中(作者也强调 local gains 只是证据而非保证);其二,SWE-bench 的 held-out 与 held-in 同属 12 个源仓库,100 题每题值 1 个百分点,且 Seaborn、Flask 在 held-out 无覆盖,跨仓库泛化未经验证;其三,种子库构建含大量人工(论文清单人工挑选、75 个插件人工校验),方法下限与初始质量强耦合;其四,全部结果基于 2026 年 9 月闭源 API 快照,作者发现 8 月底 GPT 系模型退化后被迫重跑全部实验,复现对 API 版本敏感。

独立分析的弱点

独立分析五点弱点。第一,单插件变异的表达力边界:协同性机制(如「更换记忆条目格式 + 相应调整 workflow 检索时机」)在单变量实验中永远不会被同时发现,每轮仅 8 个单点变异,搜索呈局部性;可引入成对或小集合联合变异,或允许变异阶段低概率微调 workflow。第二,筛选信号噪声大:$b=20$ 且 solved/unsolved 各半使分数差只能取 0-10 的整数,建议每候选多次重采样配对或做序列概率比检验再决定入库。第三,库无界增长:75 到 132 已让提议者需查阅大量插件文档,达数百时上下文与检索都成瓶颈,可引入功能聚类、语义检索与基于近期贡献的淘汰机制。第四,评估协议偏乐观:held-out 仅 100 题且与 held-in 共享仓库分布,跨仓库跨语言泛化未经验证,应在全新仓库的外部集上做迁移测试。第五,成本结构:变异使每 rollout 输出 token 增 19.8%,提议者还用 xhigh 推理档位,对预算敏感团队不友好,可研究级联筛选——先用极小 minibatch 粗筛再全量确认。

未来方向

作者提出的方向包括:长程任务(long-horizon tasks)上的 harness 优化、跨域与跨模型更显著的机制迁移、插件与 workflow 的联合优化、以及增长中插件库的管理策略。基于本文成果还可以自然延伸:一是把插件变异与强化学习结合,用任务回报直接微调插件参数而非仅靠 LLM 重写文本(作者团队此前的 Skill1 已在技能层面做过类似尝试,两个思路可以合并);二是在开放任务流上做在线持续演化,让库随任务分布漂移自动增删,与 Continual Harness 一脉相承;三是对插件库做版本谱系与机制去重分析,量化「哪些机制普遍有效」,逐步沉淀跨领域通用的机制库;四是把进化出的插件库作为组织级资产直接接入生产级模块化 harness(如 DeepSeek Harness 形态),把论文结论——积累可复用机制是持续改进的基础——落到工程实践;五是从理论上刻画机制级信用分配的统计性质与「变异-重组」组合搜索的收敛条件。

复现评估

复现难度中上。有利面:代码已在 GitHub 开源(github.com/syr-cn/PluginRSI);基准全部公开,held-in/held-out 由固定 task-ID 列表定义(附录 I),QA 用种子 50 采样;超参数完整(Table 5:$T=15$、$N=8$、$b=20$、10:10 平衡、seed 42;Table 6:各模型推理档位与 token 上限);种子库来源(Table 8/9)与提议者提示词(附录 H)均公开。不利面:依赖三个闭源 API(GPT-5.6 Terra、Kimi-K3、GLM-5.2,2026 年 9 月快照),作者因 8 月底 GPT 系性能退化重跑全部实验,对 API 版本高度敏感;无需训练 GPU,成本在 API 费用——每轮 $400 + 8 \times 20 = 560$ 次 SWE-bench rollout(每次真实仓库跑测试),15 轮合计 8400 次以上,叠加 xhigh 提议者开销,总费用未披露但显然不低。总体:工程能力足够者 1-2 周内可复现主表量级,精确对齐数字较难。

相似论文推荐