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

2026-03-27Software Engineering

Software EngineeringComputation and Language
AI summary

The authors studied how AI coding assistants often produce correct code that human project maintainers reject because it doesn't follow the project's unique style and rules. They created a method called Learning to Commit that helps the AI learn from the project's past code changes in order, so it can better understand how the project evolves over time. This approach lets the AI generate code that fits the project's style and architecture, not just general programming rules. Their tests showed that this method improves the AI's ability to create code changes that align well with real future project needs.

Large language modelscoding agentspull requestscode organicityrepository memorysupervised contrastive reflectioninternal API usagearchitectural constraintscommit historycode style consistency
Authors
Mo Li, L. H. Xu, Qitai Tan, Ting Cao, Yunxin Liu
Abstract
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.