Research Papers 论文研究 5h ago Updated 2h ago 更新于 2小时前 49

What Context Does a Coding Agent Actually Need to Act? 编码代理实际上需要什么样的上下文才能行动?

Coding agents require significantly less context than assumed; compressed representations match full-file performance while using only one-third of the tokens (19K vs 94K per resolved issue). Natural language summaries of code are ineffective for resolving behavioral issues compared to source code, regardless of whether the summarizer is a frontier model or a smaller 3B parameter model. Surrounding context in multi-file scenarios provides negligible benefit; reducing file remnants to UML skeleto 编码代理解决代码问题所需的上下文极其精简,核心信号仅存在于被编辑的代码本身,而非整个仓库。 自然语言摘要在行为推理上表现极差(4/45),远不如源代码(27/45),且差距源于表示形式而非摘要模型能力。 压缩上下文策略可将解决单个问题所需的Token从94K降至19K,同时保持与完整文件相当的修复效果。 实验发现温度设为0的API推理存在约9%的随机性翻转,构成了基准测试中的显著噪声基底。 研究通过固定定位(Oracle)隔离变量,验证了UML骨架等简化表示并未比删除上下文带来显著优势。

65
Hot 热度
75
Quality 质量
70
Impact 影响力

Analysis 深度分析

TL;DR

  • Coding agents require significantly less context than assumed; compressed representations match full-file performance while using only one-third of the tokens (19K vs 94K per resolved issue).
  • Natural language summaries of code are ineffective for resolving behavioral issues compared to source code, regardless of whether the summarizer is a frontier model or a smaller 3B parameter model.
  • Surrounding context in multi-file scenarios provides negligible benefit; reducing file remnants to UML skeletons performs statistically identically to deleting them entirely.
  • Temperature-0 API inference introduces a significant noise floor, flipping approximately 9% of per-instance outcomes even between byte-identical runs, challenging the reliability of small effect sizes in benchmarking.

Why It Matters

This research fundamentally challenges the prevailing assumption that larger context windows automatically lead to better coding agent performance, suggesting that efficiency gains can be achieved through smarter context compression rather than raw token capacity. For AI practitioners, it highlights critical flaws in current evaluation methodologies, particularly regarding the stability of API-based inference, urging a re-evaluation of benchmark results that may be obscured by inherent stochasticity.

Technical Details

  • Methodology: The study isolates the "acting" phase of coding agents by fixing code localization with an oracle and varying only the context representation, evaluated on SWE-bench Verified.
  • Context Compression: Demonstrated that compressed context (UML skeletons/signatures) achieves equivalent issue resolution rates to full files while reducing token usage by approximately 67%.
  • Summary Inefficacy: Found that natural language summaries fail to capture necessary behavioral signals, with a frontier model's summaries performing no better than those from a 3B model ($4/45$ vs $27/45$ correct behavioral answers).
  • Statistical Rigor: Utilized pre-registered hypotheses and exact McNemar tests ($p=0.75$) to validate that surrounding context removal does not impact performance, alongside releasing a gold-validated instrument for deterministic patch construction.

Industry Insight

  • Optimize for Compression: Developers should prioritize building context compression pipelines (e.g., extracting signatures and skeletons) over simply increasing context window sizes, as this yields substantial cost and latency benefits without sacrificing accuracy.
  • Re-evaluate Benchmarks: The discovery of a 9% outcome flip rate in temperature-0 inference suggests that many reported marginal improvements in coding benchmarks may be statistical noise; rigorous statistical testing and multiple runs are essential for valid comparisons.
  • Source Over Summaries: When designing agentic workflows, rely on raw code structure and signatures rather than LLM-generated summaries for decision-making logic, as summaries lack the precision required for behavioral reasoning.

TL;DR

  • 编码代理解决代码问题所需的上下文极其精简,核心信号仅存在于被编辑的代码本身,而非整个仓库。
  • 自然语言摘要在行为推理上表现极差(4/45),远不如源代码(27/45),且差距源于表示形式而非摘要模型能力。
  • 压缩上下文策略可将解决单个问题所需的Token从94K降至19K,同时保持与完整文件相当的修复效果。
  • 实验发现温度设为0的API推理存在约9%的随机性翻转,构成了基准测试中的显著噪声基底。
  • 研究通过固定定位(Oracle)隔离变量,验证了UML骨架等简化表示并未比删除上下文带来显著优势。

为什么值得看

这篇文章挑战了“越大越好”的上下文窗口迷思,为构建高效、低成本的编码Agent提供了实证依据。它揭示了当前基于摘要或简化表示的上下文工程方法的局限性,并指出了基准测试中潜在的评估噪声问题。

技术解析

  • 实验设计:在SWE-bench Verified数据集上,固定代码定位(使用Oracle),仅改变代码表示形式(原始代码、自然语言摘要、UML骨架、删除剩余部分),评估其对Issue Resolution的影响。
  • 摘要失效:对比发现,自然语言摘要无法回答大多数行为逻辑问题(仅4/45实例有效),而源代码有效率为27/45。即使使用前沿大模型生成的摘要,效果也与3B小模型相当,证明瓶颈在于“文本摘要”这一表示形式本身。
  • 上下文压缩效率:采用压缩上下文策略,将解决一个Issue所需的平均Token数从94K降低至19K(约为原来的三分之一),且修复成功率与使用完整文件无显著差异。
  • 噪声基底发现:在Byte-identical(字节完全相同)的输入下,Temperature=0的API调用仍有约9%的实例结果发生翻转,表明当前基准测试中对微小改进的宣称可能受到此噪声水平的干扰。

行业启示

  • 优化Agent上下文策略:不应盲目堆砌仓库全量上下文,应优先聚焦于被修改文件的精确切片及必要的依赖签名,大幅降低推理成本。
  • 警惕摘要工程的局限性:对于需要复杂逻辑推理的代码任务,简单的NL摘要可能无效,需探索更结构化的代码表示方法或直接使用源码片段。
  • 严谨评估基准测试:在进行Agent性能对比时,必须考虑API非确定性带来的噪声(~9%),统计显著性检验需更加严格,避免将随机波动误认为模型进步。

Disclaimer: The above content is generated by AI and is for reference only. 免责声明:以上内容由 AI 生成,仅供参考。

Agent Agent Code Generation 代码生成 Research 科学研究 Evaluation 评测 Benchmark 基准测试