Building a Unified Inline Code Editing Model for GitHub Copilot
Microsoft CodeAI Team, Microsoft VS Code Team, Julia Gong, Benjamin Liggett, Shengjie Ma, Ulugbek Abdullaev, Zhehui Liao, Benjamin Steenhoek, Gaurav Mittal, Fuhui Fang, Satarupa Guha, Hang Zhao, Anand Mooga, Cheng Long, Benjamin Simmonds, Soojin Choi, Luciana Abud, Nathan Halstead, Alexandru Dima, Yu Hu, Elsie Nallipogu
cs.SE, cs.CL, cs.LG
2026-11-25
One model emits anchored diffs for completion, nearby edits, and cross-file edits. In Copilot, display time falls 6.77% and output tokens 58.93% versus the three-model baseline.
Inline suggestions in GitHub Copilot used to come from three models called in a fixed order: completion at the cursor, a nearby rewrite covering two lines above the cursor and five below (NES, next edit suggestion), and a long-distance edit that can land elsewhere in the file or in another file. One trigger could run up to four model calls. Completion always went first.
That order picks the wrong edit. On the same context, the three-model stack completes Fa to FastingPenguin, while the unified model rewrites Fa to Fish. A single intent often touches the cursor and a distant site, and the old formats cannot emit both in one response.
All three edit types now come out as anchored diffs. Each patch names a file path and a line, deletes at least one line, and may add lines. An insertion deletes its anchor line and adds that line back with the new text, which cut off-by-one line errors in early tests. An empty string means no suggestion. Several patches can ride in one response, and the client caches the later ones so the next edit appears as soon as the developer accepts the first.
Completion is more than 70% of edit opportunities, and nearby rewrites are dismissed more often than gray text at the cursor, so it was trained second. Phase 1 merges nearby and long-distance edits and still calls the old completion model. Phase 2 continues reinforcement learning from that checkpoint and adds completion.
The cursor marker sits at the end of the prompt, so keystrokes do not bust the shared prefix in the key-value cache. Existing labels are mostly single edits. Multi-edit labels are synthesized, at most 10 patches. Pseudolabeling rolls the known edit into the history and keeps the next proposal from the strongest checkpoint of the moment only if the patch checks pass. History playback moves a recent recorded edit into the label when a judge says the intent matches.
Supervised fine-tuning uses 17,454 samples, 45% of them with no edit. Among samples that do edit, 48.30% are a single patch. The checkpoint used to start RL targets about 1.3 patches per response. Across 11 fine-tuning checkpoints, as the mean edit count rose from 1.32 to 2.33, the patch-validity error rate rose from 2.36% to 12.23%.
The reward is 0 or 1. Rules reject critical format errors and patches that stop previously compiling code from compiling. A language-model judge passes abstention at 0.5 and an edit at 0.8. Misplaced insertions, right text on the wrong line, are a veto from an auxiliary grader. Only 355 repaired samples of that failure existed, and they were upsampled fivefold. A hand-written bonus for extra patches dropped median acceptance on the pseudo-online set from 34.4% to 30.7%, with the model padding replies using empty comments. The bonus was removed. Validity penalties cover critical errors only.
Removing the completion model without extra training cut accepted suggestions per user by 22.45% ± 11.24 and characters still present after 30 seconds by 18.99% ± 11.73. Phase 2 then added completion data, including 908 length-focused samples upsampled tenfold, and changed the client. With the checkpoint held fixed, blocking an ignored gray completion from returning as another view cut dismissed suggestions per user by 22.40%.
| Checkpoint | STests v2 total | pass@1 single / multi / span | Reject-to-abstain ÷ accept-to-abstain | Mean patches |
| SFT | 36.8/79 | 79.6 / 53.9 / 72.5 | 1.59 | 1.32 |
| RL stage 1 | 45.4/79 | 89.6 / 65.9 / 79.8 | 2.11 | 1.29 |
| RL stage 2 | 45.6/79 | 92.0 / 75.9 / 84.2 | 2.23 | 1.30 |
Stage 2 scores 19/19 on a 19-case canary that was also used to pick checkpoints, so that score is not an independent quality estimate. The pass@1 numbers come from a HumanEval variant that deletes a span inside existing code and runs the unit tests.
The Phase 1 online test compares the 2-in-1 model plus the original completion model with the three-model baseline, on a random split of VS Code stable users.
| Metric | Relative change | p |
| Time to display | −6.77% ± 1.98 | ≈0 |
| Time to produce | −5.95% ± 1.75 | ≈0 |
| Output tokens | −58.93% ± 1.54 | ≈0 |
| Prompt tokens | −4.83% ± 0.78 | ≈0 |
| Cached suggestion share | +8.86% ± 1.16 | ≈0 |
| Accepted per user | −2.63% ± 9.35 | 0.58 |
| Dismissed per user | +16.00% ± 19.10 | 0.10 |
| Ignored per user | +3.40% ± 8.50 | 0.43 |
| Retained chars, 30s | +2.94% ± 9.08 | 0.53 |
| Retained chars, 5min | +1.26% ± 9.56 | 0.80 |
Latency and token counts drop with high significance. Accepted suggestions, retained characters, and users who accept on two or more days show no significant regression. Cache share rises only 8.86% relative, in line with a mean of 1.3 patches: most responses have nothing later to serve from cache.
Phase 2 changes the control to the 2-in-1 model plus completion. The 3-in-1 model and its client changes cut dismissed suggestions per user by 10.06%, which is not significant after a Bonferroni correction, while output tokens rise 20.98%. Point estimates for retained characters are negative at both windows and not significant. Latency is lower in this comparison; the percentage is not reported there.
The saving is in the format and the call pattern. Nearby edits no longer regenerate unchanged lines, so Phase 1 cuts output tokens 58.93% and time to display 6.77%, with no significant hit on the quality guardrails. Nothing in the experiments shows that one model writes better suggestions than the three specialists.
The client moves the same metrics on its own. Holding the checkpoint fixed, suppressing a repeat of an ignored suggestion cuts dismissals 22.40%. Completion is most of the opportunity. Removing its specialist model before training for it drops accepts by more than a fifth. Diff format first, completion second, is the order that regression forced.
The two phases use different controls, exposure windows, and users. The relative changes should not be multiplied into a cumulative gain against the original three-model baseline. There is no direct A/B of the final 3-in-1 system against that baseline.
The 10.06% drop in dismissals does not survive Bonferroni correction, and output tokens go up 20.98%. Phase 2 token metrics compare the 3-in-1 model with the 2-in-1 model alone, leaving the control's separate completion model out, so the arms do not cover the same tasks. Retained-character estimates are negative. Missing the significance bar does not show the systems are tied.
Phase 1 dismissals sit at +16% with a 19-point half-width and p=0.10. p-values are computed per metric and do not control false positives across the candidate search. A round can already have a clean quantitative scorecard while internal use still finds suggestions that fire too often, insertions on the wrong line, and duplicated code. Some multi-edit labels come from the model's own proposals. A valid patch can still be the wrong intent. The auxiliary grader and the fivefold upsampling were not ablated apart.