代码整洁性影响编码代理吗?一项受控的最小对研究
Does Code Cleanliness Affect Coding Agents? A Controlled Minimal-Pair Study
AI总结:
本研究探讨了代码整洁性对编码代理性能的影响,通过构建结构和风格相似但整洁度不同的代码库对,发现整洁性不影响通过率,但显著降低计算成本和文件重复访问。
摘要:
随着自主编码代理的快速普及,其评估主要集中在固定目标代码库的任务完成率上。这留下了一个关键问题未被回答:底层代码的结构和风格质量,即“整洁性”,是否会影响代理导航和修改代码的能力?为了隔离代码整洁性对代理能力的影响,我们引入了一种基于最小对的评估协议:构建结构、依赖和外部行为相同但静态分析规则违反和认知复杂度不同的代码库对。这些对通过代理流水线在两个方向上构建:一个降级干净代码库或清理混乱代码库。我们为六个这样的对编写了33项任务,并通过应用的公共表面进行隐藏测试。在660次使用Claude Code的试验中,代码整洁性没有改变代理的通过率。然而,它显著改变了代理的操作足迹:在整洁代码上工作的代理使用7至8%更少的标记,并减少34%的文件重复访问。我们的发现表明,传统可维护性原则在AI驱动开发时代仍然高度相关,影响编码代理的计算成本和导航效率。代码整洁性与模型选择、工具和提示并列,成为影响代理行为的重要因素。
英文摘要:
As autonomous coding agents see rapid adoption, their evaluation has primarily focused on task completion rates holding the target codebase fixed. This leaves a critical question unanswered: does the structural and stylistic quality, or ``cleanliness'' of the underlying code affect an agent's ability to navigate and modify it? To isolate the effect of code cleanliness from agent capability, we introduce an evaluation protocol built around minimal pairs: repositories that match on architecture, dependencies, and external behaviour, but differ on static-analysis rule violations and cognitive complexity. The pairs are constructed in both directions, by agent pipelines that either degrade a clean repository or clean a messy one. We author 33 tasks across six such pairs, evaluated through hidden tests at the application's public surface. Across 660 trials with Claude Code, code cleanliness does not change the agent's pass rate. However, it substantially alters the agent's operational footprint: agents working on cleaner code use 7 to 8% fewer tokens and reduce file revisitations by 34%. Our findings suggest that traditional maintainability principles remain highly relevant in the era of AI-driven development, shaping the computational cost and navigational efficiency of coding agents. Code cleanliness joins model choice, harness, and prompting as a factor that materially affects agent behaviours.
机构、总结、中文摘要均由AI分析而来,可能存在错误,请以论文正文为准。