arXivDaily arXiv每日学术速递 周一至周五更新
arXiv周末暂无论文更新,休息一下吧,周末愉快~~
arXiv 2607.18161cs.SEcs.AIcs.OS

TRIM:通过代理轨迹最小化减少人工智能生成的代码冗余

TRIM: Reducing AI-Generated CodeSlop via Agent Trajectory Minimization

Alex Mathai, Shobini Iyer, Aleksandr Nogikh, Petros Maniatis, Franjo Ivancic, Junfeng Yang, Baishakhi Ray

首次发表
浏览论文内容

中文总结 AI 辅助

研究人工智能生成代码冗余问题,提出TRIM算法,通过最小化代理轨迹间接减少代码冗余,实验证明该方法有效且高效,能显著降低代码冗余,同时减少验证成本。

中文摘要 AI 辅助

编码代理在许多下游任务中越来越多地用于加速代码生成。然而,代理生成的代码往往比人工编写的代码更大、更冗长。本文指出原因在于代理自身的搜索过程,迭代时会积累推测性编辑等,导致代码库冗余。为此正式定义此现象为代码冗余(CodeSlop),并引入TRIM算法,通过最小化代理轨迹来间接减少代码冗余。实验表明,TRIM能有效减少17.9%-32.9%的代码冗余,且性能回归可忽略不计,效率也高,验证成本约为Delta Debugging等算法基线的一半。

英文摘要

Coding agents are increasingly used to accelerate code generation in many downstream tasks, such as fixing bugs, building applications, and prototyping. However, despite their value as coding assistants, agent-generated code tends to be larger and more verbose than the corresponding human-written implementation. In this work, we show that the cause lies in the agent's own search process: while iterating toward a passing solution, an agent accumulates speculative edits, abandoned hypotheses, and temporary changes that persist into the final patch. This may seem harmless for a single patch, but the problem compounds as agents take responsibility for ever-larger portions of a codebase-a codebase that was once minimal and well-maintained slowly accumulates redundancy faster than it can be cleaned up, drifting to a state that is harder to maintain. Given the magnitude of this problem, we take a step towards alleviating this issue. First, we formally define this phenomenon as CodeSlop-the residual and functionally unnecessary edits commonly seen in AI-generated code. We then introduce our algorithm TRIM (Trajectory-guided Redundancy Identification and Minimization). Rather than minimizing CodeSlop directly, TRIM instead minimizes agent trajectories. As we show empirically, this indirect technique of minimizing CodeSlop is highly effective: TRIM cuts CodeSlop by 17.9%-32.9% across agentic scaffolds, with negligible performance regression. TRIM is also highly efficient, requiring roughly half the validation cost of algorithmic baselines such as Delta Debugging.

发表机构

  • Dept. of Computer Science Columbia University(计算机科学系哥伦比亚大学)
  • Google Inc(谷歌公司)
  • Google DeepMind(谷歌DeepMind)

机构由 AI 辅助整理,请以论文原文为准。

↑