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

学习承诺:通过在线仓库记忆生成有机的拉取请求

Learning to Commit: Generating Organic Pull Requests via Online Repository Memory

Tsinghua University(清华大学)

Mo Li, L. H. Xu, Qitai Tan, Ting Cao, Yunxin Liu

AI总结:

本文提出Learning to Commit框架,通过在线仓库记忆提升生成拉取请求的有机性,通过对比历史提交改进代码风格和架构约束。

摘要:

基于大语言模型(LLM)的编程代理在受控基准测试中表现优异,但生成的拉取请求常被维护者拒绝。根本原因不是功能错误,而是缺乏有机性:生成的代码忽略项目特定的约定,重复内部API已提供的功能,并违反隐含的架构约束。仅仅让代理接触最新仓库快照不够:快照显示代码库的最终状态,但不显示通过多年开发积累的仓库特定变更模式。我们引入Learning to Commit框架,通过在线仓库记忆弥合这一差距。给定一个具有严格时间线分割的仓库,代理对早期提交进行监督对比反思:它盲目尝试解决每个历史问题,将其预测与 oracle diff 进行比较,并将差距转化为持续增长的技能可重用模式,捕捉编码风格、内部API使用和架构不变量。当新PR描述到达时,代理根据这些积累的技能生成更改,这些更改基于项目自身的演变,而非通用预训练先验。评估基于真正未来、已合并的拉取请求,这些请求在技能构建阶段无法被看到,涵盖多个维度,包括功能正确性、代码风格一致性、内部API重用率和修改区域合理性。在具有丰富提交历史的专家维护仓库上的实验表明,在线仓库记忆在持有未来任务上的有机性得分显著提高。

英文摘要:

Large language model (LLM)-based coding agents achieve impressive results on controlled benchmarks yet routinely produce pull requests that real maintainers reject. The root cause is not functional incorrectness but a lack of organicity: generated code ignores project-specific conventions, duplicates functionality already provided by internal APIs, and violates implicit architectural constraints accumulated over years of development. Simply exposing an agent to the latest repository snapshot is not enough: the snapshot reveals the final state of the codebase, but not the repository-specific change patterns by which that state was reached. We introduce Learning to Commit, a framework that closes this gap through Online Repository Memory. Given a repository with a strict chronological split, the agent performs supervised contrastive reflection on earlier commits: it blindly attempts to resolve each historical issue, compares its prediction against the oracle diff, and distils the gap into a continuously growing set of skills-reusable patterns capturing coding style, internal API usage, and architectural invariants. When a new PR description arrives, the agent conditions its generation on these accumulated skills, producing changes grounded in the project's own evolution rather than generic pretraining priors. Evaluation is conducted on genuinely future, merged pull requests that could not have been seen during the skill-building phase, and spans multiple dimensions including functional correctness, code-style consistency, internal API reuse rate, and modified-region plausibility. Experiments on an expert-maintained repository with rich commit history show that Online Repository Memory effectively improves organicity scores on held-out future tasks.

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

↑