Manuscript Offprint

arXiv:2609.03894

CROCODIL: Cross-Model Code Editing with LLMs

Linghan Zhong, Aditya Thimmaiah, Jayanth Srinivasa, Milos Gligoric, Junyi Jessy Li

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Figure

CROCODIL: Cross-Model Code Editing with LLMs

Linghan Zhong¹, Aditya Thimmaiah¹, Jayanth Srinivasa², Milos Gligoric¹, Junyi Jessy Li¹

linghanz@cs.utexas.edu, auditt@utexas.edu, jasriniv@cisco.com, gligoric@utexas.edu, jessy@utexas.edu

¹The University of Texas at Austin ²Cisco Research

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/Crocodile1.

1 Introduction

Large language models (LLMs) have become ubiquitous tools for code generation and editing. Developers use them to draft new functions (Chen et al., 2021; Austin et al., 2021; Nijkamp et al., 2023), refactor existing modules (Gautam et al., 2025), and patch failing tests (Xia and Zhang, 2022; Xia et al., 2023; Yang et al., 2024; Tufano et al., 2019). With a wide range of models available, development teams often use multiple LLMs. Different developers may prefer different models (Liang et al., 2024), and the same developer may switch between models from one session to the next as task demands, latency, or cost shift (Pyo et al.,

Figure

Figure 1: Cross-edit example: vanilla 0lmo3 7B over-edits a Qwen3.5 35B A3B-generated function by renaming the identifier tmp_dir to td. Trained with CROCODIL, it makes only the requested change.

2026). As a result, the pre-edit code each LLM assistant is tasked to edit not only includes native code authored by itself (self-edit) but also foreign code that another model originally generated (cross-edit). These models are trained on different corpora and tuned under different post-training objectives (Ouyang et al., 2022; Rozière et al., 2023; Hui et al., 2024). They accordingly hold their own preferences in style. Do these preferences lead an LLM to make more edits during cross-edit than during self-edit, implementing foreign code toward its own conventions?

Prior work on benchmarking LLM code editing ability (Just et al., 2014; Widyasari et al., 2020; Cassano et al., 2024) is ill-suited for answering this question. Such benchmarks usually support varying only the editor LLM for each edit task, but not the author of the pre-edit code. With this limitation, we cannot easily evaluate how much of an editor's output is driven by who wrote the pre-edit code.

We first reveal that (1) LLMs are excessive code editors, and (2) mixing and matching implementor and editor models when coding makes the LLMs' edits more excessive. To systematically assess how the editing behavior of LLMs differs on native code compared to foreign code, we introduce a novel data-collection framework that gathers pre-edit code from merged GitHub pull requests (PRs) on popular Rust crates, and use a set of models to implement the pre-edit code themselves. We then run existing tests to ensure the implementations are correct. Each of the models is then asked to apply the original PR's edit to every implementation.

Using five LLMs on this corpus, we find that the four open-weight models edit their own implementations up to 14% less than they edit the other models' implementations, on 14 of 16 model pairings. The gap cannot be closed by prompt engineering: a system prompt asking for the smallest possible edit cannot consistently make edits smaller or improve edit success. This motivates a training signal that explicitly penalizes excessive editing without sacrificing correctness. Fewer changes per PR could mean faster code reviews, fewer tests to run for that PR, and thus faster overall development.

To address this gap, we introduce CROCODIL (Cross-model Code Editing with LLMs), a post-training framework for code editing models with a novel reward function to reduce this excessive editing while preserving functional correctness. CROCODIL's components penalize large changes while rewarding build and test success. We reuse our data-collection framework to gather the training tasks, so the model can be trained against code by another LLM whose style it is not familiar with. We show that CROCODIL halves 01mo3 7B's edit size on implementations by every model, while improving build and test pass rates on every implementor but 01mo3 7B itself. When restricted to tasks where edits by both the base model and the CROCODIL-trained model pass every test, CROCODIL still produces smaller edits, demonstrating that our model indeed reduces excessive non-task-related edits.