all posts

Morph Cloud vs E2B: Fork the Machine or Rent a Session

Ajay Kumar··9 min read

Line up Morph Cloud and E2B and ask "which one is more isolated" and you get a boring answer: both are built on Firecracker microVMs, both aimed squarely at running code an AI agent wrote. The hypervisor argument is over before it starts. That's good news — you can skip the part of the evaluation everyone over-invests in and go straight to what actually shapes your codebase: which primitive each platform puts on top of the VM, and what mental model that primitive forces onto your agent loop.

The thesis, up front: Morph leans hard into snapshot, branch, and instant clone as the product — the machine is the thing, and you're meant to keep it, fork it, and rewind it. E2B leans into the code-interpreter and agent-runtime developer experience — the session is the thing, it starts fast, does its job, and goes away, with a broad ecosystem of framework integrations around that shape. Neither is the worse idea. They answer different questions about what an agent actually is.

Disclosure: I'm Ajay, founder of PandaStack, which competes with both. So I've written this the only way I think is defensible — Morph and E2B described qualitatively from their stated positioning, no invented latencies, prices, quotas, or API names for either, and my own measured numbers confined to one clearly marked section you can skip. Check every characterisation of either vendor against their current docs; both ship fast and a blog post ages badly.

Same substrate, different product

Both sit on the same architectural bet: a container is a polite suggestion to the kernel, and code an LLM wrote thirty milliseconds ago shouldn't be arguing with your host kernel directly. Each sandbox gets a guest kernel and a hardware virtualization boundary, and the interesting engineering moves up a level — how fast you get a machine, what you can do with it, and what happens to it when you stop looking.

Which is why a feature-matrix comparison of these two is mostly noise. Both run a shell command, write a file, install a package. The divergence is in the verbs each SDK makes cheap: Morph's vocabulary is heavy on snapshot, branch, and clone; E2B's on create a sandbox, run this code, stream the output, kill it. What's cheap becomes what you build.

Two mental models for what an agent needs

Morph: a persistent, forkable machine

Morph's positioning treats the environment as durable and worth keeping. You warm a machine up — clone the repo, install the dependency tree, seed the database — and that warmed state becomes an asset rather than a setup cost you re-pay per task. The operations that matter are the ones that take that state somewhere: snapshot it, clone it, branch it, hand the branch to a different line of reasoning. The agent doesn't rebuild its world each turn; it navigates a tree of worlds it already has.

This fits long-running coding agents, environments with expensive setup, and any loop where the agent's context is not just tokens but an installed toolchain and a running process tree. The cost is conceptual weight: you now own state, and owning state means retention policy, cleanup, and a bill that doesn't go to zero because nobody typed anything. Verify Morph's current semantics — what a snapshot captures, how long it lives, what a clone shares with its parent — in their own docs, not my paraphrase.

E2B: a disposable execution session

E2B's centre of gravity is the code-interpreter loop: the model emits Python, something runs it right now without hurting anyone, the result comes back as stdout, an error, or a chart, and the agent takes another turn. The sandbox is a means, not a possession — start it fast, use it, drop it. The product surface reflects that, optimised for the distance between "the model produced code" and "I have the result and the artifacts," with an ecosystem that assumes an agent framework is calling in.

That model is honest about what a lot of agents genuinely are. If your agent is a research assistant, a data analyst, or a chat product with a Python tool, the environment is not precious — rebuilding it is a `pip install` away, and keeping it warm between user messages is a tax on nothing. The failure case is the other kind of agent: the forty-step refactor across a real repo, where losing the environment loses twenty minutes of work and the disposable model quietly becomes you writing your own checkpointing layer.

The trap here is picking the model you like rather than the one your agent has. Watch a real trace for ten minutes and count two things: how many tool calls happen inside one environment before it's discarded, and how many times the agent wishes it could undo the previous step. High on either points you at fork-first. Low on both, and a disposable session is the cheaper, simpler thing — take it.

Why fork is the primitive that changes agent design

Snapshotting sounds like a persistence feature — a nice-to-have next to "we support volumes." It isn't. Fast branching changes which search strategies are affordable inside an agent, and search is most of what makes agents good. Four patterns fall out of it, none practical when a branch costs a fresh environment build.

  1. Best-of-N. Get to a decision point, then explore N continuations from that exact state and keep whichever passes the tests. With fresh sandboxes you pay setup N times and — worse — accept that the N environments are only approximately identical, which quietly invalidates the comparison. Branching from one live state makes them identical by construction.
  2. Tree-of-thought over environments, not just tokens. Most tree-search implementations branch the conversation and pretend the world is stateless. It isn't: the agent installed something, edited a file, migrated a schema. Branching the machine alongside the reasoning is the only version where a node means what you think it means.
  3. Undo the last tool call. The most useful capability nobody ships, because it's hard without a checkpoint. The agent ran a migration, a package upgrade, or an `rm -rf` it composed itself at 2am with tremendous confidence. With a checkpoint that's a restore; without one it's an incident and a retry from scratch.
  4. Hibernate across a human-shaped gap. An agent waiting six hours on a code review shouldn't hold a hot VM, or rebuild its world when the review lands. Same primitive, pointed at economics rather than correctness.

All four hinge on one question you should put to both vendors — and to me: does a snapshot capture guest memory, or only the filesystem? Disk-only restores your files; full-machine restores your running processes, your warmed interpreter, your loaded weights. Two very different products wearing the same word. Don't take anyone's marketing on it, mine included: start a long-lived process, snapshot, restore, see what's still breathing.

SDK ergonomics and language coverage

You'll know which SDK you prefer within an hour of writing real code, and no screenshot tells you in advance. The structural questions are narrower than "is it nice." Are non-Python languages supported to the same depth, or is the TypeScript SDK a thin afterthought? Is streaming exec available, or do you get output only after the command exits — unbearable for a build step a user is watching? Do errors surface as typed exceptions, or strings you have to regex?

E2B's public identity is the agent-developer DX story with a wide ecosystem of framework integrations, and that's the practical differentiator: "my orchestration framework already has an adapter" saves more engineering time in week one than any latency delta. Morph's identity is the branching primitive, so the SDK question there is how naturally clone-and-explore composes with your existing agent loop. Check current language coverage for both directly in their docs.

State, ports, and self-hosting posture

State persistence follows from the mental model. A fork-first platform wants long-lived state by default, so the questions are retention, cost at rest, and whether an idle machine keeps existing. A session-first platform wants the opposite, so the questions are timeouts: what counts as idle, is it configurable, what happens to your files at the boundary. Silent reaping of a long agent session is a bad way to learn a platform's defaults.

Ports matter more than they used to, because agents increasingly build things a human is meant to look at. If the agent scaffolds a web app, someone needs a URL. Ask both platforms how a guest port becomes reachable, how that URL is authenticated, and whether it's stable across a snapshot-restore or a branch — a preview URL that changes every time the environment moves is one you'll end up proxying yourself.

Self-hosting posture is often the whole decision and takes five minutes to resolve. Some teams cannot send customer code to a third party — regulated data, a VPC requirement, a security team that reasonably wants to read the execution layer rather than trust a marketing page. Get both vendors' current source-availability from their own repos, not a competitor's blog post. And note that "open source," "self-hostable," and "bring your own cloud" are three different guarantees; the last often means a proprietary control plane in your account.

Pricing shape: billed-while-idle vs per-second execution

I'm not quoting a single number for either vendor — prices change monthly and a stale figure is worse than none. But the shape is stable enough to reason about, and it follows the mental models exactly.

A persistent-machine model tends toward billing for existence: the environment is up, so it costs, whether or not anything runs inside it. That's coherent — you asked for a machine to be kept — but idle becomes a real line item, and an architecture that leaves environments lying around between turns finds that out on the invoice. A disposable-session model tends toward billing for a session's lifetime, which approximates per-execution when sessions are short, and quietly becomes the first model the moment you keep sessions alive for convenience.

  • Keeping environments warm between turns? Model idle hours explicitly — that's usually the dominant term, not compute.
  • Spinning up per task? Model create frequency, any per-create overhead, and the setup you re-pay each time (the dependency install is often more expensive than the sandbox).
  • Branching aggressively? Model stored state separately. Enthusiastic branching produces a lot of saved machines, and storage at rest is the line that surprises teams in month three, not week one.
  • Ask about boundary conditions: minimum billing granularity, what "idle" means (no API calls, or no CPU), and whether a paused environment bills differently. Then verify everything against each vendor's current pricing page — the shapes above are a reasoning aid, not a quote.

Side by side, qualitatively

Every cell below is qualitative or an explicit instruction to check the docs — not hedging for its own sake, but the difference between a comparison you can trust and one I invented to look thorough.

  • Mental model — Morph: a persistent machine you keep, snapshot, and branch. E2B: a disposable execution session you start, use, and drop.
  • Isolation boundary — Both: Firecracker microVM territory, own guest kernel behind hardware virtualization. This is the axis where they agree; stop comparing here.
  • Headline primitive — Morph: snapshot / clone / branch from running state, sold as the product. E2B: fast sandbox create plus a code-interpreter-shaped runtime and SDK.
  • Agent search patterns — Morph: best-of-N and backtracking are the native use case. E2B: possible, but you'll build more of the checkpoint layer yourself; confirm current snapshot capabilities in their docs.
  • Developer experience — Morph: ergonomics centred on state manipulation. E2B: ergonomics centred on run-code-get-result, plus a broad set of agent-framework integrations.
  • State persistence — Morph: long-lived by default, so ask about retention and cost at rest. E2B: session-scoped by default, so ask what the idle timeout reaps.
  • Ports, previews, and SDK coverage — Both: check how a guest port is exposed and authenticated, whether that URL survives snapshot or branch, and whether non-Python SDKs are first-class. Easy to test, easy to assume wrongly.
  • Self-hosting — Check each vendor's own repo and docs for current source availability. Don't infer it from any comparison post, this one included.
  • Pricing shape — Morph: leans toward paying for a machine that exists. E2B: leans toward paying for a session's lifetime. Both: verify at the source; I quote no numbers.

Where PandaStack fits (the part with my numbers in it)

Here's my side, with falsifiable figures rather than adjectives. PandaStack is an open-source Firecracker platform, and the design bet is that you shouldn't have to choose between the two mental models above: a create should be cheap enough to treat as disposable, and a fork cheap enough to treat as routine.

There is no warm pool of idle VMs. Every create restores a baked Firecracker snapshot on demand, landing at 179ms p50 and about 203ms p99; the restore step itself is roughly 49ms, the rest being network-slot allocation, a rootfs reflink, and a readiness probe. The one slow path is the first-ever spawn of a new template — a genuine cold boot in around 3 seconds that bakes the snapshot every later create reuses. Each host pre-allocates 16,384 /30 subnets with namespaces and TAP devices already standing, which is where much of that latency budget was recovered.

Forking is copy-on-write on both layers: guest memory is shared with the parent and copied on write, and the rootfs is cloned by filesystem reflink so blocks are shared until something writes. Same-host forks land in 400–750ms; cross-host forks are 1.2–3.5s, because the memory image has to come from object storage before the restore can happen. That's the cross-host tax I told you to demand from every vendor, including me. Beyond sandboxes, managed PostgreSQL 16 runs as a dedicated microVM per database (create takes 30–90s, because it blocks until Postgres genuinely accepts connections instead of lying to you early), and git-driven app hosting serves a built repo behind a stable URL — same substrate, so what the agent builds has somewhere to live.

from pandastack import Sandbox

# Every create is a snapshot restore: p50 179ms, p99 203ms.
# The restore step itself is ~49ms; there is no warm pool behind it.
sbx = Sandbox.create(template="code-interpreter", ttl_seconds=900)

sbx.filesystem.write("/work/main.py", "print(sum(range(100)))")
r = sbx.exec("python /work/main.py", timeout_seconds=30)
print(r.exit_code, r.stdout.strip())   # -> 0 4950

# The agent built something a human is meant to look at.
sbx.exec("cd /work && setsid python -m http.server 8000 >/tmp/http.log 2>&1 &")
print(sbx.preview_url(8000))

sbx.kill()

Code: branching for agent backtracking

The pattern the whole post is about, in its simplest honest form: warm one environment, checkpoint it, fan out candidates from that identical state, let the losers evaporate. The important line is the one that isn't there — no repeated clone, no repeated install, no hoping the four candidates ran against the same world.

from pandastack import Sandbox

# One environment, warmed once: repo cloned, dependencies installed.
base = Sandbox.create(template="code-interpreter", ttl_seconds=1800)
base.exec("git clone --depth 1 https://github.com/acme/service /work")
base.exec("cd /work && pip install -r requirements.txt", timeout_seconds=300)

# Checkpoint before the agent is allowed to touch anything.
checkpoint = base.snapshot()
print("checkpoint:", checkpoint)

candidates = [
    {"id": "retry-backoff", "patch": "patches/retry-backoff.diff"},
    {"id": "null-guard",    "patch": "patches/null-guard.diff"},
    {"id": "reorder-init",  "patch": "patches/reorder-init.diff"},
    {"id": "widen-timeout", "patch": "patches/widen-timeout.diff"},
]

survivors = []
for plan in candidates:
    # Same-host fork: 400-750ms. Cross-host: 1.2-3.5s. Cheap enough to be routine.
    vm = base.fork()
    vm.filesystem.write("/work/candidate.diff", open(plan["patch"]).read())
    vm.exec("cd /work && git apply candidate.diff")
    result = vm.exec("cd /work && pytest -q", timeout_seconds=600)

    if result.exit_code == 0:
        survivors.append((plan["id"], vm.id))
    else:
        # "Undo the last tool call" is just: throw the branch away.
        print("FAIL", plan["id"], result.stderr[-300:])
        vm.kill()

# base was never mutated -- it is still exactly the checkpointed state.
print("survivors:", survivors)
base.kill()

The TypeScript SDK mirrors the same surface if your orchestration lives there, including the persistent-session shape for agents that outlive a single request.

import { Sandbox } from "@pandastack/sdk";

// Persistent: exempt from the idle reaper, holds session state across turns.
const session = await Sandbox.create({
  template: "agent",
  persistent: true,
  metadata: { session: "review-4417" },
});

await session.exec("cd /work && ./bootstrap.sh", { timeoutSeconds: 600 });

// Blocked on a human for the next few hours: park it instead of paying for idle.
await session.hibernate();

// Later: the next operation wakes it with its state restored, not rebuilt.
const status = await session.exec("cd /work && git status --short");
console.log(status.stdout, status.exitCode);

await session.kill();

Which reader should pick which

Pick Morph if your agent's environment is expensive to build and precious once built — a long-running coding agent on a real repo, a workflow where branching and rewinding is the core loop, and you want the vendor whose whole product is that primitive rather than one that added it later. Confirm branching semantics and pricing at the source first.

Pick E2B if your agent's environment is genuinely disposable — a code interpreter, a data-analysis tool call, a chat product that runs Python and shows a chart — and you want the shortest path from "the model emitted code" to "I have the result." The ecosystem argument is real: if your orchestration framework already ships an E2B adapter, that's a week you don't spend on plumbing, and a week beats a benchmark you were never going to be bottlenecked by.

Pick PandaStack if you need to run the execution layer yourself — data residency, a VPC requirement, a security team that wants to read the code rather than trust it — or if you want both models on one substrate with no warm pool to size, plus managed Postgres and app hosting so what the agent built has somewhere to run. Weighing the wider field? /blog/e2b-alternatives covers Modal, Daytona, Northflank, Vercel Sandbox and Fly.io Sprites on the same axes.

When this whole comparison is overkill

Honest ending: plenty of teams reading this don't need this evaluation at all. If your agent runs trusted code you wrote, in your own infrastructure, for your own users, the isolation both vendors sell is insurance against a threat you don't have — a container and a timeout is a respectable answer. And if your agent makes one Python call per conversation against a fresh `python:3.12`, the branching argument is irrelevant; buy the simplest thing with the best SDK and move on.

The trade-offs are real on the other side too. Fork-first architectures hand you a state-management problem you didn't have: branches nobody cleaned up, storage that grows with your agent's enthusiasm, and a debugging story where "which of the eleven machines was this log from" is a genuine 3am question. Self-hosting means operating KVM hosts, an agent fleet, and object storage — engineering hours, forever.

So run the spike. One real environment, not a hello-world. On each platform: create it cold and warm, and time it. Warm it to a known state, checkpoint, branch four times, time each branch, verify the four are actually identical. Start a long-lived process, snapshot, restore, see what survived. Expose a port and look at the URL you get. Then read the bill, including what saved state costs to keep. That afternoon settles more than every comparison table on the internet, this one included.

Frequently asked questions

What is the main difference between Morph Cloud and E2B?

Both run agent code inside Firecracker microVMs, so isolation isn't the differentiator. The difference is the primitive on top. Morph's product is built around snapshotting, cloning, and branching a running machine — the environment is durable and worth keeping. E2B is built around the code-interpreter and agent-runtime developer experience — create a sandbox, run code, get results, discard it — with a broad set of agent-framework integrations around that shape. Choose based on whether your agent's environment is precious and long-lived or genuinely disposable, and verify current capabilities in each vendor's own documentation.

Why does sandbox forking matter for AI agents?

Fast forking changes which search strategies an agent can afford. Best-of-N exploration needs N environments that are identical at the branch point — building them separately makes them only approximately identical, which invalidates the comparison you're drawing between candidates. Tree-of-thought search over real environments needs the machine to branch alongside the reasoning, or a node in the tree doesn't mean what you think. And "undo the last tool call" — after a bad migration or a self-composed rm -rf — is just restoring a checkpoint. Without cheap forking, each of these becomes a full environment rebuild and stops being practical.

Does a sandbox snapshot save memory state or only the filesystem?

It depends entirely on the platform, and it's the single most consequential question in this category. A disk-only snapshot restores your files. A full-machine snapshot restores running processes, a warmed interpreter, and loaded state. Two very different products use the same word. On PandaStack a snapshot captures guest memory plus the rootfs via Firecracker's native support, and a fork shares that memory copy-on-write with the parent. For any vendor, including this one, test it empirically rather than reading marketing: start a long-lived process, snapshot it, restore, and check whether the process is still there.

How do Morph Cloud and E2B pricing models compare?

I won't quote numbers for either, since pricing changes and a stale figure is worse than none. The shapes follow the mental models. A persistent-machine platform tends to bill for the environment existing, so idle time is a real line item and long-lived environments dominate the invoice. A session-oriented platform tends to bill for a session's lifetime, which approximates per-execution when sessions are short — and converges on the first model if you keep sessions alive for convenience. Model your own pattern, budget stored snapshots separately, and verify current rates on each vendor's pricing page.

Can I self-host Morph Cloud or E2B?

Check each vendor's own repository and documentation for their current source-availability and deployment options rather than trusting a competitor's summary, mine included — this is the kind of detail that changes and that you should never infer secondhand. What I can speak to is PandaStack: the core is Apache-2.0 and built to run on your own Linux KVM hosts, with the control-plane API and a per-host agent under your control and sandboxes executing on your infrastructure. Note that "open source," "self-hostable," and "bring your own cloud" are three different guarantees, and the third often means a proprietary control plane in your account.

Keep reading

Run code in a microVM in one API call.

49ms p50 cold start. Fork, snapshot, and scale to zero.

Start free
Written by Ajay Kumar, Founder, PandaStack.