跳转至

编码代理的工作集:代码库规模任务中的一致性债务

文章背景与核心概要

本文研究了编码代理(Coding Agents)如何通过将上下文管理建模为“耦合事实图(coupled-fact graph)”的重建,来处理代码库规模(repository-scale)的任务。作者引入了“一致性债务(coherence debt)”这一概念——即进行代码编辑所需的事实同时缺失于近期上下文和参数化内存时所产生的差距。

通过对 5 个评估框架(harnesses)下的 7 个模型进行评估,该研究探讨了信息可用性、模型在信息缺失情况下的行为以及过时的约定如何影响代理的成功率。核心发现挑战了关于上下文长度、距离以及像 SWE-bench 这样评估基准的一些传统假设,为未来代理框架的设计提供了重要的洞察。


核心发现与关键概念 (Key Findings & Core Concepts)

1. 一致性债务的机制 (The Mechanics of Coherence Debt)

  • 事实重建: 在每一次编辑时,编码代理都依赖于由其近期上下文窗口或参数化内存提供的事实。
  • 缺失的代价: 两个通道都没有覆盖到的事实构成了“一致性债务”。扣留必需的事实会带来与其所支持的工作量成正比的性能惩罚。
  • 距离无关性: 空间邻近性并不决定有效性。提供的事实无论距离编辑位置很远还是紧挨着,其作用效果是一样的。
  • 失败对称性: 当 API 重命名破坏了模型对真实库的参数化内存时,所有测试的模型都会以相同的方式失败——通过和未通过的测试用例完全一致。
  • Fact Reconstruction: At each edit, a coding agent relies on facts supplied either through its recent context window or parametric memory.
  • The Cost of Absence: Facts that are covered by neither channel form "coherence debt." Withholding a required fact exacts a performance penalty proportional to the work it supports.
  • Distance is Irrelevant: Proximity does not dictate efficacy. A supplied fact works just as well far from the edit as it does right next to it.
  • Failure Symmetry: When an API rename defeats a model's parametric memory of a real library, all tested models fail identically—passing and missing the exact same tests.

2. Token 消耗与评估框架差异 (Token Consumption & Harness Discrepancies)

  • 不平等的代价: 所有测试都通过的配置,其消耗的 Token 数量仍然可能存在十倍以上的差异。这种低效源于不同评估框架以不同速率重复构建完全相同的内容。
  • 收益递减: 如果根本的事实仍然被扣留,那么投入更多的计算资源或 Token 也无法带来任何性能恢复。
  • Unequal Pricing: Configurations where every test passes can still exhibit a greater than tenfold difference in tokens consumed. This inefficiency stems from harnesses rebuilding the exact same content at varying rates.
  • Diminishing Returns: Spending more compute or tokens yields zero recovery if fundamental facts remain withheld.

3. 信息缺失下的代理行为 (Agent Behavior under Missing Information)

  • 主动捏造 vs. 停滞: 当代理缺少必需的事实宣称时,它不会简单地停下来或表明自己受阻,而是会生成错误的工作(例如,捏造文件或猜测数值)。
  • “受阻”响应: 代理承认自己受阻而不是盲目猜测的频率完全取决于模型本身,从每次试验到一次都没有,表现各异。
  • 工具盲区: 由于缺失事实会导致主动捏造而非工作缺失,因此纯粹通过追踪读取行为构建的监控工具将无法察觉这个已经被错误填补的漏洞。
  • Active Fabrication vs. Stalling: When an agent lacks a required fact, it does not simply halt or say it is blocked; instead, it generates wrong work (e.g., fabricating files or guessing values).
  • The "Blocked" Response: The frequency with which an agent admits it is blocked rather than guessing is entirely model-dependent, varying from every trial to none.
  • Instrument Blindness: Because missing facts result in active fabrication rather than absent work, monitoring tools built purely on tracking reads will look for a hole that has already been incorrectly filled.

4. 过时约定 vs. 缺失上下文 (Stale Conventions vs. Missing Context)

  • 对标准的偏好: 当标准规范与现有代码发生冲突时,即使标准规定的是劣质代码,代理也会始终如一地遵循标准。因此,一份过时的约定文件的危害甚至超过了没有文件
  • Preference for Standards: When standard practices and existing code conflict, agents consistently follow the standard even when it prescribes inferior code. Consequently, a stale convention file costs more than no file at all.

5. 对基准测试的影响(如 SWE-bench) (Implications for Benchmarks (e.g., SWE-bench))

  • 参数化替代: 由于模型很可能已经具备了 SWE-bench 上热门代码库的先验知识,参数化内存严重替代了主动读取过程。
  • 失效的指标: 因此,读取量已不再能可靠地预测模型在 SWE-bench 等基准测试中的成功率。
  • Parametric Substitution: Because models likely already possess prior knowledge of popular repositories on SWE-bench, parametric memory substitutes heavily for active reading.
  • Broken Metrics: As a result, read volume no longer reliably predicts success on benchmarks like SWE-bench.

对评估框架设计的建议 (Recommendations for Harness Design)

基于这些发现,作者建议代理评估框架应做到以下几点: 1. 维持可用性: 在代理编写代码时,主动将编辑所依赖的事实保持在上下文中可用。 2. 评估输出而非输入: 检查代理产生的内容是否具备所需的事实,而不是仅仅追踪它读取了什么。

Based on these findings, the authors recommend that agent harnesses: 1. Maintain Availability: Actively keep the facts an edit depends on available in the context when the agent writes. 2. Evaluate Output over Input: Check the availability of facts against what the agent produces, rather than merely tracking what it reads.