---
title: "What is Morph Fast Apply?"
url: "https://www.morphllm.com/blog/what-is-morph-for"
description: "Understanding Morph: The fastest way to apply code updates from AI"
date: "2025-08-22"
author: "Tejas Bhakta"
---
# What is Morph Fast Apply?

Every coding agent I've used has the same weak spot. It knows exactly what it wants to change, and then it fumbles getting that change into the file. The plan is right. The edit that lands is mangled. Morph exists for that one gap. You give your agent a single tool, `edit_file`, and when it calls that tool we take the edit and merge it into the real file at 10,500+ tokens per second. Nothing else about your setup changes. The agent just stops fumbling.

Mechanically it's tiny. The agent picks a change and calls `edit_file` with the file, a plain-English note about what it's doing, and the edited snippet. We do the merge and return the finished file, and there is no fourth step.

## The actual integration

The entire integration is registering one tool with your agent, `edit_file`, taking a target file, an instructions string, and the code edit itself. You've probably added a dozen tools shaped exactly like this to an agent before:

```json
{
  "name": "edit_file",
  "description": "Edit an existing file with AI-suggested changes",
  "parameters": {
    "target_file": "path/to/file.js",
    "instructions": "Add error handling to the login function",
    "code_edit": "// ... existing code ...\nif (!user) throw new Error('Invalid user');\n// ... existing code ..."
  }
}
```

After that it's a single API call to run the merge. Most people have this working in an afternoon coffee break.

## Why one call beats many

Search-and-replace charges the agent a tool call for every chunk it wants to touch, so three edits in one file means three separate round trips, and every one of them is another opportunity for the match string to miss and the edit to silently fail. Fast Apply takes all the changes to a file in a single call. The model describes everything it wants different, we merge it in one shot, and the agent gets back to work instead of ping-ponging.

## What Morph actually is

Applying an edit is one job in a chain. Picture the agent handling a bug report. It first has to find the couple of files that matter out of a few thousand, then fit the relevant slices of them into a context window that's smaller than the repo, and only then does it get to the edit that Fast Apply merges. Morph Embed owns the finding and Morph Rerank owns the packing. All three sit in the plumbing of a coding agent, the layer no launch video lingers on and the one that decides whether the launch video was honest.

## Why not just diff it

I get asked why a neural net earns its place here when diff tools and matching algorithms are decades old. The honest answer is that a correct merge depends on what the code means and not on which characters line up, and Karpathy's "Software 2.0" essay already mapped where problems of that shape belong. Once the rules get hairy enough, you're better off training a model than extending them, and edit merging crossed into that territory a long time ago.

![Software 2.0](/sw2.webp)

Take a case that quietly defeats a rules-based merge. The AI suggests this:

```javascript
// Add error handling
function calculateTotal(items) {
  if (!items || items.length === 0) {
    throw new Error('No items provided');
  }
  // ... existing code ...
}
```

And here's your actual code:

```javascript
function calculateTotal(item_list) {
  let total = 0;
  for (const item of item_list) {
    total += item.price;
  }
  return total;
}
```

A text-based diff tool sees `items` against `item_list` and gives up. A model trained on real edits knows they're the same variable and merges anyway. The same problem shows up all over: frontier models lose track of line numbers past a thousand-line file, context windows choke on big repos, partial function updates break naive diffs, and a change to one file often implies a change to its imports, its types, or its tests. Rules struggle with all of that. A model learns it from examples.

## How the merge works

Start with the semantics. Morph reads `calculate_total(items)` and `calculate_total(item_list)` as the same function and merges accordingly, keeping your formatting and quietly resolving the rename that a text tool would have choked on.

Speed comes from a variant of speculative decoding. Your original code is a strong prior, which means the untouched spans can be verified in bulk instead of regenerated token by token. Only the genuinely new code has to be worked out and streamed, and that's a small fraction of most files.

The last piece is the training data. Morph learned on the real distribution of how frontier models write edits, complete with the `// ... existing code ...` markers, the imports they forget, and the updates they leave half-finished. That mess is the input Morph was built for. A generic tool treats it as a series of edge cases.

## The speed advantage

Fast Apply runs at 10,500+ tokens per second with 1-3 second latency. But the throughput number isn't really why it feels fast when you're using it. The reason is that a whole file's worth of edits goes through in one call. Search-and-replace scatters that same work across a call per chunk, and the round trips pile up until they dominate. Collapse them into one and you get the full-file edit with none of the ping-pong, which is where the ~35% faster end-to-end completion comes from.

A real merge, start to finish. Your original file:

```javascript
function UserCard({ user }) {
  return (
    <div className="card">
      <h3>{user.name}</h3>
      <p>{user.email}</p>
    </div>
  );
}
```

The AI's suggestion, lazy markers and all:

```javascript
// ... existing code ...
function UserCard({ user }) {
  // ... existing code ...
  <div className="card">
    <img src={user.avatar} alt={user.name} />
    <h3>{user.name}</h3>
    <p>{user.email}</p>
    <span className="status">{user.status}</span>
  </div>
  // ... existing code ...
}
```

What Morph returns:

```javascript
function UserCard({ user }) {
  return (
    <div className="card">
      <img src={user.avatar} alt={user.name} />
      <h3>{user.name}</h3>
      <p>{user.email}</p>
      <span className="status">{user.status}</span>
    </div>
  );
}
```

Clean, correct, your style untouched.

## Under the hood

The inference side does the usual work you'd expect: KV caching, speculative decoding with your original code as the prior, attention heads trained specifically for editing. The point of all of it is to spend as few frontier-model tokens as possible. The frontier model decides what to change, a cheap specialized model does the merge, and code edits at scale stop being expensive.

## What's next

Where this goes is a stack that splits the work by cost. Frontier models handle the planning and reasoning. Specialized models handle the implementation and the merge. And you can apply changes recursively, at different levels of abstraction, without a frontier model in the loop for every keystroke. We're building toward file routing that figures out on its own which files a change touches, longer-context models that hold a whole codebase, and self-hosting for teams that can't send code out.

## Getting started

[Grab an API key](https://morphllm.com/dashboard) and you're running in minutes. [The playground](https://morphllm.com/playground/na/apply) lets you throw your own code at it first, and [the docs](https://docs.morphllm.com/api-reference/apply) cover the integration. For dedicated instances or larger models, reach us at [info@morphllm.com](mailto:info@morphllm.com).

---

*The point was never to replace the person writing the code. It's to make the AI sitting next to them actually usable in production, and applying edits reliably is the piece that was missing.*
