Building a Next-Generation AI-Enhanced Code Editor with Real-Time Inference

cursor · Tech · 2023 · source Agentic: no · promotional bias: low · source-backed · extracted with prompt 0.5.4 (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: AI-assisted software development and real-time code editing

Cursor wanted an AI-native code editor that could predict edits, apply rough model plans, and keep developers in flow without the latency, context, and UX limits of ordinary autocomplete or extension-based AI coding tools.

Constraints:

Architecture

Cursor forked VS Code and built an editor deeply integrated with an ensemble of custom models and frontier models. Cursor Tab predicts low-entropy next edits and jumps using a low-latency sparse/MoE model, cache-aware prompts, KV-cache reuse, and speculative edits. Frontier models handle higher-level reasoning and sketch changes, while a specialized Apply model turns those sketches into actual diffs. The editor streams results quickly enough that users can review while generation continues.

Diagram confidence: reconstructed (reconstructed from prose).

flowchart LR
  cursor-editor[Cursor editor] --> cursor-tab-model[Cursor Tab model]
  cursor-editor --> frontier-reasoning-models[Frontier reasoning models]
  frontier-reasoning-models --> apply-model[Apply model]
  apply-model --> speculative-edits-engine[Speculative edits engine]
  speculative-edits-engine --> cursor-editor
  cursor-editor --> prompt-and-cache-layer[Prompt and cache layer]
  prompt-and-cache-layer --> cursor-tab-model
  prompt-and-cache-layer --> kv-cache[KV cache]
  prompt-and-cache-layer --> cloud-inference-infrastructure[Cloud inference infrastructure]
  kv-cache --> cloud-inference-infrastructure
  speculative-edits-engine --> cloud-inference-infrastructure
Drag to pan · scroll or use +/− to zoom · reconstructed from the source's described component topology

Components

Component Role Interacts with
Cursor editor VS Code-derived IDE that owns the AI-native editing UX, context capture, and diff presentation. Cursor Tab model, Frontier reasoning models, Apply model, Prompt and cache layer, Speculative edits engine
Cursor Tab model Custom low-latency model that predicts next edits, jumps, and low-entropy coding actions. Cursor editor, Prompt and cache layer
Frontier reasoning models More capable models used for reasoning-intensive planning and rough code sketches. Cursor editor, Apply model
Apply model Specialized model that turns rough frontier-model code sketches into concrete diffs. Cursor editor, Frontier reasoning models, Speculative edits engine
Prompt and cache layer Cache-aware prompt design and cache warming layer for long code context. Cursor editor, Cursor Tab model, KV cache, Cloud inference infrastructure
KV cache Stored transformer keys and values reused across requests to avoid recomputing repeated prompt context. Prompt and cache layer, Cloud inference infrastructure
Speculative edits engine Speculative-decoding variant that feeds existing code chunks back through the model and streams changed sections faster. Cursor editor, Apply model, Cloud inference infrastructure
Cloud inference infrastructure Remote GPU-backed serving path used instead of relying on local user hardware for heavy model work. Prompt and cache layer, KV cache, Speculative edits engine

Data flow

A user edits code in the Cursor editor. The editor sends long code context and recent editing state to specialized low-latency models for Cursor Tab predictions, reusing warmed KV cache where possible. For instruction-driven edits, a frontier model drafts a rough change, the Apply model converts that sketch into a concrete diff, and speculative edits stream unchanged code chunks plus generated changes through the same diff interface.

4 supporting quotes
“Where Cursor really works via this ensemble of custom models that we've trained alongside the frontier models that are fantastic at the reasoning intense things.”transcript, stated
“The frontier models are quite good at sketching out plans for code and generating rough sketches of the change, but actually, creating diffs is quite hard for frontier models, for your training models.”transcript, implied
“we let the model sketch out this rough code block that indicates what the change will be and we train a model to then Apply that change to the file.”transcript, stated
“reusing the KV cache results in lower latency, lower costs, cross requests. So as the user starts typing, you can immediately warm the cache with let's say the current file contents, and then when they press Enter,”transcript, stated

Why this architecture

Cursor chose deep IDE ownership plus specialized models because the product needed both UX control and model specialization. Forking VS Code enabled native AI editing experiences; Cursor Tab's sparse low-latency model fit long-context, short-output next-edit prediction; Apply separated planning from diff application; and cache-aware cloud inference avoided recomputing repeated code context on every keystroke.

4 supporting quotes
“It's a fork of VS Code, and VS Code is one of the most popular editors for a long time. Everybody fell in love with it. Everybody left Vim, I left DMAX for it.”transcript, stated
“They're incredibly low latency, so you need to train small models on this task. In particular, they're incredibly pre-fill token hungry. What that means is they have these really, really long prompts where”transcript, stated
“And so, the perfect fit for that is using a sparse model, meaning an MOE model. So that was one breakthrough we made that substantially improved its performance at longer context.”transcript, stated
“So one other thing that Apply lets you do is it lets you use fewer tokens with the most intelligent models. This is both expensive in terms of latency for generating all these tokens and cost.”transcript, stated

Models used: frontier models · Cursor Tab model · Apply model · MoE model · Sonnet · o1

Scale

Alternatives considered (roads not taken)

Ship as a VS Code extension

Rejected because: Cursor wanted control over the editor UX and AI-native interaction model, so it forked VS Code rather than only layering on an extension.

“It's a fork of VS Code, and VS Code is one of the most popular editors for a long time. Everybody fell in love with it. Everybody left Vim, I left DMAX for it.”transcript, stated
“And so, you decided to fork VS Code, and start to build a lot of the amazing features we'll be able to talk about. But what was that decision like?”transcript, stated

Use frontier models for both planning and patch application

Rejected because: Frontier models can plan code changes but still mess up line counting and diff application in large files.

“You try to do this with Sonnet, with o1, any frontier model and it really messes up stupid things like counting line numbers”transcript, stated

Apply rough edits with deterministic matching

Rejected because: The team found deterministic matching breaks too often for a good editing experience.

“- Contrary to popular perception, it is not a deterministic algorithm. - Yeah, I think you see shallow copies of Apply elsewhere and it just breaks most of the time because you think you can try to do”transcript, stated
“because you think you can try to do some deterministic matching, and then it fails at least 40% of the time and that just results in a terrible product experience.”transcript, stated

Run heavy model and embedding work locally

Rejected because: Local models would only work well on the newest machines, while much of Cursor's user base used less powerful Windows hardware.

“So, local models really only works on the latest computers, and it's also a big overhead to build that in. So even if we would like to do that, it's currently not something that we are able to focus on.”transcript, stated

Patterns

model-routing (model-architecture)

Cursor separated reasoning and implementation: frontier models sketch plans, while custom models handle Cursor Tab prediction and Apply diff generation.

“ensemble of custom models that we've trained alongside the frontier models that are fantastic at the reasoning intense things.”transcript, stated
“planning and then maybe the implementation details can be handled by the less intelligent ones.”transcript, stated

latency-optimization (serving)

Cursor used small specialized models, MoE for long-context short-output tasks, KV-cache reuse, cache warming, and speculative edits to make editor interactions feel immediate.

3 supporting quotes
“They're incredibly low latency, so you need to train small models on this task.”transcript, stated
“One interesting thing is cache warming. You're probably going to use some piece of context and you can know that before the user's done typing.”transcript, stated
“What this actually ends up looking like is just a much faster version of normal editing code.”transcript, stated

context-compaction (context-management)

Cursor designed cache-aware prompts and reused KV cache so repeated long code context did not have to be recomputed for every keystroke or request.

“you need to design the actual prompts you use for the model such that they're caching aware.”transcript, stated
“I don't need to pass those first N tokens through the entire model because I already have all those keys and values.”transcript, stated

eval-driven-development (evaluation)

The team distinguishes coding benchmarks from real coding tasks, warning that benchmark performance can miss messy, context-dependent user intent.

“that's a really, really hard, critically important detail of how different benchmarks are versus real coding”transcript, stated
“Humans are saying half-broken English sometimes and sometimes you're saying, "Oh, do what I did before."”transcript, stated

Tradeoffs

Own the IDE surface

Chose Fork VS Code over Only building an extension on top of the existing editor.

Rationale: The product needed deeper control over editor behavior and AI-native interaction patterns than a conventional extension would provide.

“It's a fork of VS Code, and VS Code is one of the most popular editors for a long time.”transcript, stated
“And so, you decided to fork VS Code”transcript, implied

Specialize models by job

Chose Custom Cursor Tab and Apply models alongside frontier models over A single frontier model for every editing task.

Rationale: Specialized models were faster, cheaper, and better suited for low-latency next-edit prediction and diff application.

“Cursor Tab, for example, is a great example of where you can specialize this model to be, even better than even frontier models”transcript, stated
“This is both expensive in terms of latency for generating all these tokens and cost.”transcript, stated

Use cloud inference rather than local-only models

Chose Remote inference with caching and serving optimizations over Relying on every user's local machine for heavy model execution.

Rationale: Most users did not have powerful enough local machines, so cloud inference remained necessary despite the serving complexity.

“To go to the cloud, you have to think about all these things with the caching and the large code base where a large number of programmers are using the same code base.”transcript, stated
“most of our users, more than 80% of our users are in Windows machines, which many of them are not very powerful.”transcript, stated

Gotchas (what bit them)

Frontier coding models can plan a change but fail at applying it precisely.

Root cause: Diff application requires file-position and matching details that remain hard in large files.

Resolution: Cursor trained a dedicated Apply model to turn rough sketches into concrete edits.

“frontier models are quite good at sketching out plans for code and generating rough sketches of the change”transcript, stated
“we train a model to then Apply that change to the file.”transcript, stated

Deterministic patch application is brittle in production UX.

Root cause: Matching rough generated code against real files is not a simple deterministic algorithm.

Resolution: Use a trained Apply model instead of shallow deterministic matching.

“Contrary to popular perception, it is not a deterministic algorithm.”transcript, stated
“it fails at least 40% of the time and that just results in a terrible product experience.”transcript, stated

Long code prompts can crush latency and GPU capacity if recomputed on every keystroke.

Root cause: Cursor Tab prompts contain lots of code context but generate few tokens.

Resolution: Use sparse models, cache-aware prompt design, KV-cache reuse, and cache warming.

3 supporting quotes
“they're incredibly pre-fill token hungry. What that means is they have these really, really long prompts where they see a lot of your code”transcript, stated
“if every single keystroke that you're typing in a given line you had to rerun the model on all of those tokens passed in”transcript, stated
“you're gonna kill your GPUs with load.”transcript, stated

Academic or benchmark coding performance can overstate product readiness.

Root cause: Real programming requests are context-dependent and often expressed messily by humans.

Resolution: Evaluate against real coding behavior and rough intent, not only benchmark-style tasks.

“when you push them a little bit outside of that, Sonnet is I think the one that does best at maintaining that same capability.”transcript, stated
“real coding, it's not interview style coding.”transcript, stated

Evaluation

Cursor evaluates model choices through task-specific evals, real coding behavior, and whether the result preserves interactive product feel, while treating generic coding benchmarks as incomplete proxies.

Metrics: task-specific Cursor Tab evals · latency and time to first token · diff application failure rate · real-code editing quality outside benchmark distributions · GPU load and serving cost

3 supporting quotes
“if you look at evals on the task we set it at.”transcript, stated
“This will significantly lower TTFT.”transcript, stated
“that's a really, really hard, critically important detail of how different benchmarks are versus real coding”transcript, stated

Outcomes

The transcript emphasizes interactive latency, GPU load, long code prompts, and a user base where more than 80% were on Windows machines rather than local model-ready hardware.

3 supporting quotes
“the goal of Cursor Tab is let's eliminate all the low entropy actions you take inside of the editor.”transcript, stated
“What this actually ends up looking like is just a much faster version of normal editing code.”transcript, stated
“So, we can use the same exact interface that we use for diffs, but it will just stream down a lot faster.”transcript, stated