Papers

研究:编码智能体演进代码时更依赖仓库先例还是任务指令

Precedent or Intent? What Coding Agents Follow When Evolving Existing Code

Why we picked it

做了5625次实验,发现编码Agent几乎总跟着仓库既有代码走,文件放哪、写不写规则结果差很远,管Agent写代码的都该看看。

arXiv 论文通过 5,625 次受控实验,考察四个编码智能体在既有代码与新任务指令冲突时如何取舍。结果显示智能体在冲突时压倒性地遵循仓库先例(359/360 次试验),而非自身默认偏好。先例的影响力取决于位置:三个支持性本地文件可达 96% 采纳率,同层资源文件仅 4%,仅调整文件位置就能让采纳率从 0% 变为 100%。当任务意图与现有代码冲突时,书面优先级规则的联合成功率为 59/60,明显高于仅靠代码示例的 38/60;在开源仓库中,加载一条规则可将联合成功从 0/120 提升至 117/120。

Original · arXiv cs.AI

Precedent or Intent? What Coding Agents Follow When Evolving Existing Code

Existing code reveals past implementation decisions but rarely explains the reasoning behind them. When coding agents implement new features or modify existing functionality, past decisions may conflict with new task instructions. This raises a fundamental question for agentic software evolution: when multiple implementations satisfy the same functional requirements, how do coding agents decide whether to follow existing code or new task instructions? We investigate this question through bidirectional, controlled experiments in purpose-built repositories, followed by validation in real-world open-source repositories. Our approach isolates three competing sources of guidance: (1) agents' default preferences, (2) repository precedents, and (3) explicit task instructions. We conduct 5,625 trials across four coding agents and six implementation pairs, with validation in four open-source repositories spanning three programming languages. We find that agents share the same default implementation choices, yet overwhelmingly follow repository precedent when it conflicts with those defaults (359/360 trials). Crucially, not all precedents carry equal influence: three supporting local files yield 96% adoption, compared with only 4% for sibling-resource files, and changing file placement alone can shift adoption from 0% to 100% at a fixed example count. When new task intent conflicts with existing code, written priority rules achieve substantially higher success than code examples alone (59/60 versus 38/60 joint successes for two agents on two implementation pairs). The effectiveness of explicit rules also extends to open-source repositories, where a harness-loaded rule raises joint success from 0/120 to 117/120. These findings motivate design-decision traceability that preserves not only implementation choices but also the rationale and priorities that should guide future changes.