arXivDaily arXiv每日学术速递 周一至周五更新
arXiv 2610.38244cs.SEcs.AI
收藏

先例还是意图?编码智能体在演化现有代码时遵循什么

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

University of California, Riverside(加州大学河滨分校);Tulane University(杜兰大学)

Haichao Zhu, Geyang Xu, Zhaorui Yang, Jiyuan Wang, Qian Zhang

AI总结:

该研究探究编码智能体在代码演化中遵循先例还是任务意图,通过实验发现智能体多遵循仓库先例,明确规则比代码示例更有效,推动设计决策可追溯性发展。

摘要:

现有代码揭示了过去的实现决策,但很少解释其背后的推理。当编码智能体实现新功能或修改现有功能时,过去的决策可能与新的任务指令冲突。这为智能体软件演化提出了一个基本问题:当多种实现满足相同的功能需求时,编码智能体如何决定是遵循现有代码还是新的任务指令?我们通过在专门构建的仓库中进行双向受控实验来研究这个问题,随后在真实的开源仓库中进行验证。我们的方法分离出三种相互竞争的指导来源:(1)智能体的默认偏好,(2)仓库先例,(3)明确的任务指令。我们在四个编码智能体和六对实现中进行了5625次试验,并在跨越三种编程语言的四个开源仓库中进行了验证。我们发现,智能体具有相同的默认实现选择,但当先例与这些默认选择冲突时,绝大多数会遵循仓库先例(360次试验中的359次)。重要的是,并非所有先例的影响力都相同:三个支持性本地文件的采用率为96%,而同级资源文件的采用率仅为4%,在固定示例数量下,仅改变文件位置就能使采用率从0%变为100%。当新的任务意图与现有代码冲突时,书面优先级规则的成功率远高于仅使用代码示例(两个智能体在两对实现上的联合成功率为59/60,而仅使用代码示例为38/60)。明确规则的有效性也延伸到了开源仓库中,其中一个由harness加载的规则使联合成功率从0/120提升至117/120。这些发现推动了设计决策可追溯性的发展,该可追溯性不仅保留了实现选择,还保留了应指导未来变更的基本原理和优先级。

英文摘要:

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.

机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。

↑