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

*Mo Li, Qitai Tan, Kai Chen, Ting Cao, Yunxin Liu*

[NeurIPS page](https://neurips.cc/virtual/2026/poster/150227) · [OpenReview](https://openreview.net/forum?id=jqSgr9lIkj) · [alphaXiv](https://www.alphaxiv.org/abs/2603.26664) · [Open on the map](../papers.html#p150227)

Category: [LLM Agents, Evals & Benchmarks](../pcat/17.md) › [Software Engineering Benchmarks](../pgroup/646.md) · Type: new method · Keywords: next-commit prediction, supervised contrastive learning, code generation, organic code evaluation, GitHub repository analysis

Areas: [Code & Coding Agents](../areas/codegen.md) › Code Verification › Coding agent benchmarks; [AI Agents](../areas/agents.md) › Agent Benchmarking › Coding agent benchmarks; [Evaluation & Benchmarks](../areas/evaluation.md) › Language Model and Agent Benchmarks › Software Engineering Benchmarks; [Benchmarks for LLMs & Agents](../areas/bench-llm-agents.md) › Cross-Domain Agent Evaluation › Coding Agent Benchmarks

## Summary
Learning to Commit introduces next-commit prediction and a supervised contrastive reflection framework to teach coding agents organic code conventions, evaluated on a new benchmark measuring file localization, API reuse, bloat, and style.

## Explained to a 5-year-old
We look at old code changes in a project. A computer tries to guess what the next change will be, like predicting the next sentence. It learns from the old changes how to write code that fits the project's style. Then it uses that learning to write better code that matches what real developers like. This helps the code be accepted when it's shared.

## Explained to a 5-year-old, longer
When people write code, they follow certain rules and styles. Sometimes computers that write code forget those rules, so the code looks weird to humans. To help, we look at the project's history of changes, called commits. We teach a computer to predict what the next change will be, using those old commits as examples. The computer tries to guess each change, compares its guess to the real change, and learns what patterns to follow. It builds a small guide that tells it how to write code that matches the project's style. This guide helps the computer write code that looks natural and fits with the rest of the project. Over time, the computer gets better at making changes that real developers would accept. We test it on several real projects and see that the code is more organic and easier to merge. The computer also learns to avoid copying the same parts too much and to keep the code tidy. This makes the code more pleasant for human reviewers. By using the project's own history, the computer understands the subtle habits of the developers. This helps the code flow smoothly with the existing codebase. Ultimately, the computer becomes a helpful assistant that writes code that feels like it belongs.

## For a technical reader
The system predicts the next commit in a repository by treating each historical diff as a self-supervised target. It generates candidate diffs, compares them to the ground-truth diff using contrastive learning, and extracts a reusable skill document that conditions future generations. This reflection mechanism improves organicity metrics and raises test-pass rates on SWE-bench Pro, bridging the gap between benchmark performance and real-world mergeability.

## Problem
LLM-based coding agents produce functionally correct code that lacks organicity, ignoring project conventions and architectural constraints, which leads to rejected pull requests in practice.

## Method
The approach uses next-commit prediction as a self-supervised task, where each historical commit diff provides dense supervision. An agent attempts each commit, performs supervised contrastive reflection by comparing its prediction to the oracle diff, and distills a reusable skill document to guide future generations.

## Results
The approach improves organicity on held-out tasks and raises test-pass rates on SWE-bench Pro, narrowing the gap between benchmark success and real-world mergeability.

## Contributions
The paper introduces next-commit prediction as a paradigm for learning coding skills from repository history, proposes the Learning to Commit benchmark with Organicity Evaluation, and presents a supervised contrastive reflection framework that distills reusable skill documents.

## Practical relevance
The work aims to make LLM-based coding agents produce code that aligns with project conventions, improving real-world mergeability and reducing rejected pull requests.

This page was written by language models from the title and abstract of each paper, and the answers were checked by two other models. It can be wrong: check the paper itself. [Suggest a correction](../feedback/?on=p/150227)
