AgSpec:在编码代理流水线中突破基于检索的推测解码极限
研究论文 · 2026/10/02
基于检索的推测解码(SD)通过复制现有文本的延续来草拟令牌,适合反复重现代码、日志和早期尝试的编码代理。然而,现有方法在代理流水线中表现不足:其语料库中缺失大量可重用文本,或存储形式与代理输出不同,且草稿长度忽略了接受长度因代理而异并随轮次漂移。我们提出AgSpec,一个为现有检索引擎在编码代理流水线中提供语料库和草稿长度策略的框架。AgSpec从会话、工作区和全局语料库中检索,保留正在进行的会话轨迹,并以代理的输出格式索引打开的文件。它通过离线分析的容量限制每个代理的草稿长度,并根据验证反馈在线调整长度。在两个仓库级多代理编码基准上,AgSpec在大多数评估设置中优于五种基于检索的草稿器和EAGLE-3,在批量大小为1时将生成吞吐量比自回归解码提高最多4.37倍,在批量大小为16时提高最多4.76倍。AgSpec在没有仓库或多代理流水线的基准上也保持有效,表明其增益广泛适用于编码代理。
该研究针对编码代理流水线中检索式推测解码的瓶颈,提出了实用的框架,显著提升了生成吞吐量,并在多个基准上验证了有效性,对提升编码代理效率有重要价值。
Retrieval-based speculative decoding (SD) drafts tokens by copying continuations from existing text, which suits coding agents that repeatedly reproduce code, logs, and earlier attempts. Yet existing methods fall short in agent pipelines: much of the reusable text is missing from their corpora or stored in a form that differs from what the agent emits, and their draft lengths ignore that accept length varies across agents and drifts over turns. We present AgSpec, a framework that supplies the corpus and draft-length policies that existing retrieval engines lack in coding-agent pipelines. AgSpec retrieves from session, workspace, and global corpora, retaining the ongoing session trajectory and indexing opened files in the agent's emission format. It bounds each agent's draft length with an offline-profiled cap and adapts the length online from verification feedback. On two repository-level multi-agent coding benchmarks, AgSpec outperforms five retrieval-based drafters and EAGLE-3 in most evaluated settings, raising generation throughput over autoregressive decoding up to 4.37times at batch size 1 and 4.76times at batch size 16. AgSpec also remains effective on benchmarks without a repository or a multi-agent pipeline, showing that its gains generalize to coding agents broadly.