CROCODIL: Cross-Model Code Editing with LLMs

Linghan Zhong, Aditya Thimmaiah, Milos Gligoric and Junyi Jessy Li at UT Austin with Cisco Research show that a model editing code originally written by a different model makes more and larger edits, then train that behavior down with a two-term reward.
Ask this paper
The setting is realistic and underexamined: teams use several assistants, so any given model routinely edits foreign code written by another model with different stylistic preferences.
Measured effect: models make more, and often excessive, edits on foreign code than on their own, which turns model-switching into a review-cost problem.
CROCODIL's reward is a product, not a sum: a similarity reward penalizes large changes and an execution reward scores build and test success, and multiplying them stops the policy from shrinking edits at the cost of task success.
Post-training rather than prompting: the intervention is applied as a training framework, so the reduced edit size persists without a per-call instruction.
Released at github.com/EngineeringSoftware/Crocodil.
Abstract
Large language models (LLMs) have become ubiquitous tools for code generation and editing. However, development teams often use multiple LLM assistants. Different developers may prefer different models, and individual developers may switch between models across different coding sessions. Because of this, the edits any one model makes are frequently applied to foreign code originally generated by another model. These LLMs are often trained on different datasets, and as a result have different stylistic preferences. Do LLMs behave differently when they edit foreign code originally written by a different LLM with a different coding style? We find that models tend to make more, and often excessive, edits on foreign code. We introduce CROCODIL (Cross-model Code Editing with LLMs), a post-training framework for reducing excessive edits while preserving functional correctness. CROCODIL's similarity reward penalizes large changes, while its execution reward scores build and test success. We use the product of these two rewards to encourage the policy to decrease the edit size without decreasing the edit task success rate. CROCODIL is available at https://github.com/EngineeringSoftware/Crocodil.