Learning to Commit: Next-Commit Prediction via Online Supervised Contrastive Reflection

Mo Li, Qitai Tan, Kai Chen, Ting Cao, Yunxin LiuNeurIPS 2026

TL;DR

AI coding agents crush benchmarks by passing unit tests, yet real-world maintainers routinely reject their pull requests because the code feels bloated, alien, and ignorant of project conventions. Learning to Commit solves this by putting agents through a virtual "onboarding" phase: they attempt past commits in chronological order, compare their guesses against what human maintainers actually merged, and distill their mistakes into a living "skill document." The result is code that doesn't just work, it actually belongs—improving architectural alignment while lifting test-pass rates in the process.

What Problem Does This Paper Address?

Imagine hiring a brilliant developer who refuses to learn your team's history. You hand them a bug ticket; they fix it, the tests turn green, and they submit a pull request. Then you read the diff: they re-implemented three helper functions your codebase already has, ignored module boundaries, and violated unwritten architectural rules. You reject the PR.

Today’s LLM coding agents behave like these "amnesiac newcomers." Standard benchmarks like SWE-bench treat software engineering as a series of isolated, stateless puzzles—handing the agent a static snapshot of a codebase and grading solely on whether tests pass. Looking only at the latest snapshot is like looking at a finished skyscraper without seeing the blueprints; it shows what is there, not how the maintainers prefer to build. Consequently, agents produce "alien code" lacking organicity—how indistinguishable a generated patch is from one written by a veteran maintainer.

Methods

Instead of relying on static retrieval (RAG) over past commits or changing model weights, the authors introduce next-commit prediction via a two-phase framework called Learning to Commit.

Figure 1: Overview of the Learning to Commit framework. Repositories are time-split into past commits (skill learning) and future commits (evaluation). The agent extracts reusable skills via on- policy contrastive reflection, conditions on the accumulated skills to generate organic patches for future tasks, and is scored against oracle commits along multiple organicity dimensions.
  1. Repository Onboarding (Supervised Contrastive Reflection): Repositories are split strictly by time. Walking chronologically through historical commits before a cutoff date, the agent undergoes active trial-and-error:
  2. Blind Attempt: Given a synthetic issue description and the historical repo snapshot, the agent explores the codebase using standard tools (search, read, edit) and writes a candidate patch.
  3. Contrastive Reflection: The ground-truth human commit ("oracle diff") is revealed. Because the agent just tried the task itself, comparing its patch to the expert’s exposes its exact, intrinsic blind spots ("on-policy" supervision).
  4. Skill Update: The agent updates a structured markdown skill document via create, revise, and deprecate operations—recording reusable rules about internal APIs, file locations, and architectural boundaries.
  5. Skill-Conditioned Resolution: When a genuinely future issue arrives, the agent receives the current codebase alongside its accumulated skill document, consulting its hard-earned lessons to write an organic patch.

Datasets

  • Learning to Commit Benchmark (New): Curated from 5 major open-source AI engineering repositories (including vllm and milvus), spanning over 63,000 commits. It uses strict per-repository chronological splits (10 historical onboarding commits and 10 future test commits per repo) to prevent data leakage. Crucially, instead of unit tests, it evaluates organicity using deterministic metrics—File IoU (did it touch the exact right files?) and Line Deviation (did it bloat the patch?)—alongside a multi-dimensional pairwise LLM judge validated against human reviewers.
  • SWE-bench Pro: A public, contamination-resistant benchmark with executable test suites. The authors sample 50 tasks and reframe them temporally: for a task at time $t$, the agent onboards using the top-3 relevant commits strictly prior to $t$.

Key Insights and Ideas

  • Failing first is the secret sauce for localization: When an "observation-only" baseline simply studied expert patches without trying the task first, it learned coding conventions well enough, lifting file localization (File IoU) by just 1 percentage point. Forcing the agent to make a blind attempt first jumped that gain to 5 percentage points. You don't truly learn where files live until you guess wrong and get corrected.
  • Unsupervised self-reflection is worse than amnesia: Having an agent reflect on its own attempts without seeing the ground-truth oracle diff caused its win rate against a memoryless baseline to drop to 44%. Left to its own devices, the agent hallucinates conventions and reinforces its own bad habits.
  • Organicity unlocks functional correctness: Writing idiomatic code isn't just cosmetic. In strict repositories, violating conventions breaks tests, and historical skills point agents toward crucial companion files (like registries or config schemas) that aren't mentioned in the issue description.

Key Results

Trends across onboarding iterations showing skill document growth, rising File IoU, and dropping Line Deviation.

Trends across onboarding iterations showing skill document growth, rising File IoU, and dropping Line Deviation.
  • More organic patches: On the Learning to Commit benchmark (using Claude Opus 4.6 with sequential full-corpus learning), the framework boosted File IoU from 62% to 67%, cut patch bloat (Line Deviation) by roughly a quarter (0.58 to 0.43), and achieved a 59% pairwise win rate over the vanilla agent. Gains held steady across Claude Sonnet 4.6 and Kimi K2.5.
  • Higher test-pass rates: On SWE-bench Pro, conditioning on learned skills lifted pass@1 across all models, with gains scaling alongside base model strength: Kimi K2.5 rose +3.0 percentage points (to 34.0%), Sonnet 4.6 rose +6.0 pp (to 40.0%), and Opus 4.6 jumped +8.0 pp (from 48.0% to 56.0%).

Limitations and Future Work

  • The "Tunnel Effect": Occasionally, loaded skills make an agent overconfident, priming it to jump straight into a familiar pattern while skipping basic exploratory searches—causing regressions on 8 out of 200 pooled task-runs on SWE-bench Pro.
  • Higher exploration cost: Skill-conditioned agents take noticeably more tool-call steps (e.g., 40 vs. 26 steps on average) because they inspect the codebase more thoroughly to verify conventions before committing.
  • Benchmark scope: The newly curated benchmark lacks executable test suites, relying on SWE-bench Pro to verify functional correctness.
  • Future Work: The authors aim to convert this blind-attempt-versus-oracle signal directly into a reinforcement learning objective, training model weights end-to-end rather than relying purely on text-based skill distillation.

Summary updated

Abstract

Large language model (LLM)-based coding agents achieve strong results on controlled benchmarks yet routinely produce pull requests that real maintainers reject. The cause is not functional incorrectness but a lack of organicity: generated code ignores project conventions, duplicates internal APIs, and violates implicit architectural constraints. The latest repository snapshot is insufficient-it reveals the final codebase state, not the change patterns that shaped it. We make three contributions. (1) Paradigm: we propose next-commit prediction as a paradigm for learning agentic coding skill from a repository's own history-each historical commit is a self-supervised target whose oracle diff supplies dense supervision. (2) Evaluation: we establish Organicity Evaluation as a measurable objective for coding agents and contribute the Learning to Commit benchmark-5 curated open-source GitHub repositories under strict per-repository temporal splits-scoring patches along file localisation, internal API reuse, patch bloat, and code-style consistency. (3) Method: we instantiate the paradigm with the Learning to Commit framework, in which the agent performs supervised contrastive reflection: it blindly attempts each historical commit, contrasts its prediction against the oracle, and incrementally distils a reusable skill document that conditions subsequent generations. On the Learning to Commit benchmark and on SWE-bench Pro reframed under our temporal-split protocol, our framework consistently improves organicity on held-out future tasks and further lifts test-pass rates on SWE-bench Pro, narrowing the gap between benchmark success and real-world mergeability.
BibTeX
@inproceedings{li2026learning,
  author = {Mo Li and Qitai Tan and Kai Chen and Ting Cao and Yunxin Liu},
  title = {{Learning to Commit: Next-Commit Prediction via Online Supervised Contrastive Reflection}},
  booktitle = {Advances in Neural Information Processing Systems},
  year = {2026},
  url = {https://openreview.net/forum?id=jqSgr9lIkj},
}
Figure