Building Production-Ready LLMs for Automated Code Repair: A Scalable IDE Integration Case Study

replit · Tech · 2024 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.5 (schema v2)

Generated from extraction.json — do not edit by hand. Every claim cites verbatim source evidence; stated means the quote directly asserts the claim, implied means it supports it indirectly.

Problem

Domain: Production code-repair model training and IDE integration

Replit needed a production-ready model that could turn Language Server Protocol diagnostics into reliable code repairs inside its IDE, where deterministic LSP fixes covered only a small share of Python diagnostics and general code models were not trained on Replit's session events.

Constraints:

Architecture

Replit built Code Repair 7B as an end-to-end LLMOps pipeline around IDE-native data. Operational transformations, session events, LSP diagnostics, and project snapshots reconstruct the filesystem at the moment of an error; filtering removes deterministic or unsuitable diagnostics; a serverless verification step reruns Ruff/Pyright diagnostics; large code LLMs plus DSPy synthesize numbered line diffs; regex/application/LLM filters keep usable examples; DeepSeek-Coder-Instruct-v1.5 is fine-tuned on MosaicML infrastructure; and the model is evaluated against both a LeetCode-derived benchmark and a held-out Replit repair benchmark.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  replit-ide-session[Replit IDE session] --> operational-transformation-stream[Operational transformation stream]
  replit-ide-session --> session-event-timeline[Session event timeline]
  operational-transformation-stream --> filesystem-reconstruction-pipeline[Filesystem reconstruction pipeline]
  session-event-timeline --> filesystem-reconstruction-pipeline
  lsp-diagnostics-dataset[LSP diagnostics dataset] --> filtering-pipeline[Filtering pipeline]
  filtering-pipeline --> training-example-corpus[Training example corpus]
  filesystem-reconstruction-pipeline --> serverless-diagnostic-verifier[Serverless diagnostic verifier]
  serverless-diagnostic-verifier --> training-example-corpus
  training-example-corpus --> synthetic-diff-generator[Synthetic diff generator]
  synthetic-diff-generator --> diff-verification-pipeline[Diff verification pipeline]
  diff-verification-pipeline --> fine-tuning-dataset[Fine-tuning dataset]
  fine-tuning-dataset --> training-infrastructure[Training infrastructure]
  training-infrastructure --> code-repair-7b-model[Code Repair 7B model]
  code-repair-7b-model --> evaluation-harness[Evaluation harness]
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Replit IDE session Source of user code edits, diagnostics, and development events. Operational transformation stream, Session event timeline
Operational transformation stream Edit-by-edit representation used to replay a project to the diagnostic timestamp. Replit IDE session, Filesystem reconstruction pipeline
Session event timeline Merged stream of diagnostics, editor actions, installs, runs, shell commands, and other IDE events. Replit IDE session, Filesystem reconstruction pipeline
LSP diagnostics dataset BigQuery-backed source of diagnostic rows used to choose code-repair training examples. Filtering pipeline, Filesystem reconstruction pipeline
Filtering pipeline Removes deterministic CodeAction cases, stylistic diagnostics, private projects, and non-Python projects. LSP diagnostics dataset, Training example corpus
Training example corpus Intermediate set of reconstructed code/diagnostic examples that feeds synthetic diff generation. Filtering pipeline, Filesystem reconstruction pipeline, Serverless diagnostic verifier, Synthetic diff generator
Filesystem reconstruction pipeline Replays project state at each diagnostic timestamp and verifies reconstructed files against snapshots. Operational transformation stream, Session event timeline, Serverless diagnostic verifier, Training example corpus
Serverless diagnostic verifier Runs Ruff and Pyright in bursty filesystem-backed environments to confirm expected diagnostics. Filesystem reconstruction pipeline, Training example corpus
Synthetic diff generator Uses large code LLMs and DSPy few-shot prompting to synthesize numbered line diffs from real error states. Training example corpus, Diff verification pipeline
Diff verification pipeline Extracts, applies, and filters generated diffs so fine-tuning sees parseable and likely-correct repairs. Synthetic diff generator, Fine-tuning dataset
Fine-tuning dataset Schema-templated code, diagnostic, and line-diff examples used for supervised fine-tuning. Diff verification pipeline, Training infrastructure
Training infrastructure MosaicML/LLM Foundry setup that fine-tunes the selected 7B code model with FSDP and activation checkpointing. Fine-tuning dataset, Code Repair 7B model
Code Repair 7B model Fine-tuned DeepSeek-Coder model that predicts numbered line diffs for IDE diagnostics. Training infrastructure, Evaluation harness
Evaluation harness Measures functional correctness and exact-match repair quality against LeetCode-derived and Replit-specific benchmarks. Code Repair 7B model

Data flow

The pipeline starts with Replit IDE sessions: operational transformations replay code state, session events and LSP diagnostics identify error moments, and filters remove deterministic or unsuitable cases. The reconstruction pipeline recreates each project filesystem at diagnostic time, serverless lambdas rerun Ruff/Pyright to verify diagnostics, large code LLMs synthesize numbered line diffs with DSPy, verification filters malformed or inapplicable diffs, and the resulting examples fine-tune a 7B DeepSeek-Coder model that is evaluated against public and Replit-specific repair benchmarks.

4 supporting quotes
“A Replit session is a stream of data across multiple modalities. To support multiplayer features, Replit represents code as a sequence of [Operational”article, stated
“OT data is merged with session events into a single timeline. Here, we work with LSP diagnostics, but many other events are recorded”article, stated
“We first recreate the filesystem of a project at the time of the diagnostic, then use LLMs to generate and verify synthetic diffs.”article, stated
“Databricks to scale up compute as needed. #### Line diff synthesis, distillation, and verification We synthesize diffs using large pre-trained code LLMs with a few-shot prompt pipeline implemented with DSPy. We chose numbered”article, stated

Why this architecture

Replit chose a specialized, IDE-native fine-tuning pipeline because the platform already had massive diagnostic/event telemetry, but general models were not trained to consume Replit session events or emit a consistently parseable repair format. Starting from real error states kept the input distribution grounded in production usage, synthetic diffs reduced user-data noise, numbered line diffs reduced ambiguity and decoding cost, and a 7B model balanced quality with inference latency and cost.

4 supporting quotes
“These models are not trained to interact directly with the development environment and, therefore, have limited ability to understand events or use tools within Replit.”article, stated
“can only provide fixes in limited cases. In fact, only 10% of LSP diagnostic messages in Python projects on Replit have associated fixes. Given the abundance of training data, repairing code errors using LSP diagnostics is therefore the ideal setting to build our first Replit-native AI model. ![An”article, stated
“We found that a well-defined synthetic pipeline resulted in more accurate diffs with less variance in the output space when compared to diffs from users.”article, stated
“We chose the model size of 7B to balance model capabilities with our constraints of inference latency and cost.”article, stated

Models used: DeepSeek-Coder-Instruct-v1.5 · DeepSeek-Coder v1.5 7B Instruct · Starcoder2 · GPT-4 Turbo · GPT-3.5 Turbo · Claude 3 Opus · Claude 3 Haiku · Large pre-trained code LLMs

Scale

Alternatives considered (roads not taken)

Rely on deterministic LSP CodeActions

Rejected because: Only about 10% of Python LSP diagnostic messages had associated fixes, leaving most repair cases uncovered.

“can only provide fixes in limited cases. In fact, only 10% of LSP diagnostic messages in Python projects on Replit have associated fixes. Given the abundance of training data, repairing code errors using LSP diagnostics is therefore the ideal setting to build our first Replit-native AI model. ![An”article, stated

Train from user-fixed errors directly

Rejected because: The source says fixed errors from user data were noisier than synthesized diffs.

“We distill a model from synthesized diffs because fixed errors taken directly from user data are noisier than synthesized diffs.”article, stated

Use Unified Diff format

Rejected because: Unified diffs hallucinated line numbers and had higher decoding cost than numbered line diffs.

“We compared Line Diffs with the Unified Diff format”article, stated

Add dedicated special tokens for each sentinel token

Rejected because: The team judged architecture/vocabulary changes unnecessary because fine-tuning worked without them and latency gains would be marginal.

“we decided this was not necessary based on how finetuning performed without this surgery and because the improvement to decoding latency would have been marginal.”article, stated

Evaluate only on public program-repair datasets

Rejected because: Public datasets may leak into pretraining and are a weak proxy for Replit's real-world user repair distribution.

“many of these datasets have been shown to be leaked in the pre-training corpus of large-language models for code”article, stated
“these evaluation datasets are often curated from professional/well-maintained repositories (e.g. filtered by stars on GitHub), thereby acting as a weak proxy to measure the performance of program repair models on real-world program repair tasks for users of”article, stated

Patterns

synthetic-data-generation (data-engineering)

Replit generated synthetic numbered line diffs from real diagnostic states instead of relying only on user fixes.

“#### Line diff synthesis, distillation, and verification We synthesize diffs using large pre-trained code LLMs with a few-shot prompt pipeline implemented with [DSPy](https:”article, stated
“Compared to synthesizing both the error state and the diff, starting from real error states and synthesizing only the diff is less prone to mode collapse”article, stated

fine-tuning-adaptation (model-customization)

The team fine-tuned a 7B code model to emit Replit's desired line-diff repair format for LSP diagnostics.

“Therefore, we frame code repair as a supervised finetuning problem. Given an LSP error, the line throwing this error, and the code file contents, we finetune a pre-trained code LLM to predict an output line diff.”article, stated
“we finetune a pre-trained code LLM to predict an output line diff.”article, stated

structured-output-contract (output-control)

Inputs and outputs are templated into sentinel-token schemas and numbered line diffs so generated repairs can be parsed and applied.

“we templated data from our IDE into a consistent schema delineated by angle-bracketed sentinel tokens.”article, stated
“responses are more consistently generated and formatted and, therefore, easier to parse.”article, stated

data-quality-loop (data-engineering)

The pipeline verifies reconstructed files, reproduces diagnostics, filters malformed diffs, checks applicability, and uses an LLM filter to improve sample quality.

“As a sanity check, we assert that we can reconstruct the most recent Repl filesystem and match a copy stored in GCS.”article, stated
“We also apply the generated numbered line diffs to the code file with line numbers to ensure that they can be correctly and unambiguously applied”article, stated

eval-driven-development (evaluation)

Replit used both a public LeetCode-style benchmark and a custom held-out Replit repair benchmark to evaluate model quality.

“To solve these issues, we conduct a two-part evaluation of our model.”article, stated
“To test the model in our inference setting–that is to say, fixing LSP diagnostics for users while they are writing code on Replit–we needed to create a completely new benchmark.”article, stated

latency-optimization (production-optimization)

Model size, diff format, and sentinel-token choices were shaped by inference latency and decoding-cost constraints.

“We chose the model size of 7B to balance model capabilities with our constraints of inference latency and cost.”article, stated
“Furthermore, Unified Diffs would have a higher decoding cost. We distill a model from synthesized diffs because fixed errors taken directly from user data are noisier than synthesized diffs.”article, stated

Tradeoffs

Use a specialized 7B model for IDE repair

Chose A fine-tuned 7B DeepSeek-Coder model over Relying only on much larger frontier/API models.

Rationale: The 7B model balanced capability with IDE latency and cost constraints while remaining competitive with larger models on the chosen evaluations.

“We chose the model size of 7B to balance model capabilities with our constraints of inference latency and cost.”article, stated
“Replit Code Repair 7B is competitive with models much larger on both evaluation benchmarks.”article, stated

Synthesize diffs from real error states

Chose Real production error states plus synthetic line diffs over Using user-fixed diffs directly or synthesizing both broken and fixed code end to end.

Rationale: Real inputs preserve production distributions, while synthetic diffs reduce noise and mode collapse risk.

3 supporting quotes
“fixed errors taken directly from user data are noisier than synthesized diffs.”article, stated
“starting from real error states and synthesizing only the diff is less prone to mode collapse”article, stated
“input feature and diff distributions are drawn from the real world.”article, stated

Emit numbered line diffs

Chose Numbered line diffs as the target repair format over Unified diff format.

Rationale: Numbered line diffs reduced ambiguity and decoding cost, while unified diffs had hallucinated line-number behavior in their comparison.

3 supporting quotes
“Line numbers (1) guarantee the non-ambiguous application of diffs in cases where the same line of code is present in multiple places in the file and (2) empirically boost response quality in our experiments and ablations.”article, stated
“line numbers were hallucinated in the Unified Diff both with and without line numbers in the input.”article, stated
“Furthermore, Unified Diffs would have a higher decoding cost. We distill a model from synthesized diffs because fixed errors taken directly from user data are noisier than synthesized diffs.”article, stated

Keep sentinel tokens as ordinary tokenizer pieces

Chose Use textual sentinel tokens mapped to existing tokenizer tokens over Changing the model vocabulary and architecture to add dedicated special tokens.

Rationale: Fine-tuning worked without model surgery, and the expected decoding-latency benefit did not justify changing the architecture.

3 supporting quotes
“We considered modifying the vocabulary and, consequently, the architecture/dimensions of the base model to have dedicated special tokens”article, stated
“we decided this was not necessary based on how finetuning performed without this surgery”article, stated
“However, we decided this was not necessary based on how finetuning performed without this surgery and because the improvement to decoding latency would have been marginal. Our model performed well with each sentinel token mapped to 3-5 tokens from the base model’s tokenizer.”article, stated

Evaluate with both public and production-realistic benchmarks

Chose A two-part evaluation: LeetCode-derived repair plus Replit repair over Depending only on academic/public repair datasets.

Rationale: The team needed public comparability and a benchmark that reflected Replit's real inference setting.

“To solve these issues, we conduct a two-part evaluation of our model.”article, stated
“To test the model in our inference setting–that is to say, fixing LSP diagnostics for users while they are writing code on Replit–we needed to create a completely new benchmark.”article, stated

Gotchas (what bit them)

LSP diagnostics expose many errors but few deterministic fixes.

Root cause: Diagnostics identify errors, but CodeActions only cover a small fraction of Python diagnostic messages.

Resolution: Use diagnostics as the input signal for a learned repair model, while excluding cases that already have deterministic CodeActions.

3 supporting quotes
“while the LSP identifies errors, it can only provide fixes in limited cases.”article, stated
“only 10% of LSP diagnostic messages in Python projects on Replit have associated fixes.”article, stated
“diagnostics with associated CodeActions (deterministic solutions provided by the LSP server) since we will always use the CodeAction at inference”article, stated

Reconstructing executable project state inside Spark was awkward.

Root cause: LSP executables require filesystem directories, while Spark works poorly with dynamically persisted string-backed filesystems.

Resolution: Verify diagnostics with serverless lambdas that can scale up in bursts and provide filesystem-backed execution.

“LSP executables need to be pointed to a filesystem directory, and in a Spark environment dynamically persisting strings is challenging.”article, stated
“For this reason, diagnostics were verified with a serverless lambda that scales up in bursts.”article, stated

Unified diffs introduced hallucinated line numbers and higher decoding cost.

Root cause: The output format did not constrain the model as effectively for this IDE repair task.

Resolution: Use numbered line diffs, which make application less ambiguous and keep generated sequences shorter.

3 supporting quotes
“line numbers were hallucinated in the Unified Diff both with and without line numbers in the input.”article, stated
“Furthermore, Unified Diffs would have a higher decoding cost. We distill a model from synthesized diffs because fixed errors taken directly from user data are noisier than synthesized diffs.”article, stated
“Line numbers (1) guarantee the non-ambiguous application of diffs in cases where the same line of code is present in multiple places”article, stated

Generated diffs can be malformed, inapplicable, or incorrect even when produced by strong models.

Root cause: Synthetic repair generation has a large output space and can produce incomplete line diffs or hallucinated content.

Resolution: Layer regex extraction, application checks, and an LLM correctness filter before admitting examples to training.

3 supporting quotes
“generated diffs are correctly formatted and applicable. We use regular expressions to extract the line diffs and filter out all other text and incomplete/malformed line diffs. We also apply the generated numbered line diffs to the code file with line numbers to ensure that they can be correctly”article, stated
“eliminating samples that cannot be applied due to incorrect line numbers or hallucinated content.”article, stated
“line numbers or hallucinated content. Lastly, we increase the proportion of correct diffs to incorrect diffs by prompting an LLM to filter out incorrect diffs, inspired by ### Supervised finetuning Since the distribution of fixed code matches the training distribution of large code LLMs, we”article, stated

Public program-repair benchmarks can misrepresent production repair quality.

Root cause: Some benchmark data may appear in model pretraining and often comes from professional repositories rather than Replit's user distribution.

Resolution: Add a held-out Replit repair benchmark sampled at the Repl level and deduplicated to avoid leakage.

3 supporting quotes
“many of these datasets have been shown to be leaked in the pre-training corpus of large-language models for code”article, stated
“thereby acting as a weak proxy to measure the performance of program repair models on real-world program repair tasks”article, stated
“We sample at the Repl level and deduplicate (following the procedure recommended in [StarCoder](https://arxiv.org/abs/2305.”article, stated

Evaluation

Replit evaluated Code Repair 7B with a two-part harness. Public benchmark coverage came from DebugBench-style syntactic/reference-error tasks and newer LeetCode competition problems with synthetic bug injection. Production realism came from a held-out Replit repair benchmark sampled from LSP diagnostic types, deduplicated at the Repl level, and labeled with SOTA LLM proposals plus human annotation. Metrics included functional correctness for executable LeetCode cases and exact-match variants for both public and Replit repair tasks.

Metrics: Functional correctness · AST exact match · AST match with string fallback · Pass@1 · LeetCode repair benchmark performance · Replit repair benchmark performance · Dataset-size scaling · Parameter-count scaling

4 supporting quotes
“We measure performance using both functional correctness and exact match metrics.”article, stated
“Functional correctness measures the functional equivalence of target code C against the fixed code C’ produced by the application of a predicted line diff”article, stated
“Exact match compares the target code C against the fixed code C’ produced by the application of a predicted line diff to the input code.”article, stated
“We evaluate the performance of all models in a single pass setting, mimicking their use in a real-world deployment paradigm.”article, stated

Outcomes

The article reports hundreds of millions of daily LSP diagnostics, a 100K-example initial target, 10K/25K/50K/75K data-scaling experiments, 360 LeetCode repair eval samples, 389 Replit repair eval samples, a single-node 8-H100 training setup, and a 7B model size chosen for production latency and cost.

5 supporting quotes
“Replit Code Repair 7B is competitive with models much larger on both evaluation benchmarks.”article, stated
“The overall performance of models on our real-world eval remains low when compared to the Leetcode repair eval”article, stated
“There is a large gap between the performance of Replit Code Repair 7B and other models (except GPT-4 Turbo).”article, stated
“![Performance improves with number of training examples.](https://cdnimg.replit.com/images/bj34pdbp/migration/8af9f4a6082772725a2edd9f12c16f1f8463da85-1134x282.”article, stated
“![Performance improves with number of model parameters.](https://cdnimg.replit.com/images/bj34pdbp/migration/12b3333fe14f9c300a7aff43ab0304cce90c0033-1400x264.”article, stated