Skip to content

Your AI agent reinstalls packages every session

Ephemeral sandboxes made sense for code execution. They fall apart for agents that do real work across sessions. Here's the persistence argument.

Your AI agent keeps reinstalling npm packages. There's a better way.

Every AI agent sandbox works the same way: spin up, run code, tear down. The environment lives for seconds or minutes, then vanishes. For evaluating a code snippet, that's fine. For an agent that's supposed to maintain a codebase or run a multi-day research project, it's a problem.

Agents are doing more than executing functions now. They manage projects, conduct research over days, maintain repos, run business processes. All of these require state. And state doesn't survive a teardown.

What persistent actually means

A persistent environment has four properties. The file system survives between sessions: files from Tuesday are still there on Thursday. OS-level state (running services, cron jobs, environment variables) carries forward. The agent doesn't need to explicitly serialize and restore anything through an API, the same way your laptop doesn't lose your files when you close the lid. And there's no session timeout forcing everything into an arbitrary window.

Ephemeral sandboxes offer none of this. That's by design. But it limits what agents can actually accomplish.

The tax you're paying

If your agent runs in an ephemeral environment, every workflow pays three taxes. They compound in ways worth examining.

Setup. Every session starts from zero. Install dependencies. Clone the repo. Configure tools. Rebuild working context. In a persistent environment this happens once. In a sandbox, it happens every session. At 10 sessions a day, you're burning real compute on work that produces nothing.

Context. Agents accumulate knowledge as they work. A research agent builds a corpus. A dev agent maps out the codebase. A testing agent learns which tests are flaky. In an ephemeral environment, all of that has to be serialized to some external store and restored next time. You end up building a state management layer on top of infrastructure that was designed to be stateless:

## Save state before sandbox dies
state = {
    "files_analyzed": files_analyzed,
    "findings": findings,
    "next_steps": next_steps,
    "installed_packages": installed_packages,
}
save_to_external_store(state)

## Next session: restore everything
state = load_from_external_store()
reinstall_packages(state["installed_packages"])
restore_files(state["files_analyzed"])

Every line of that code exists because the infrastructure doesn't handle persistence. It's overhead.

Continuity. Long tasks get chopped into session-sized chunks. An agent refactoring a codebase can't work for 8 hours if sessions expire after 1. So the workflow becomes: work 55 minutes, serialize, tear down, spin up, restore, continue. Each handoff is a chance for state restoration bugs, version mismatches, incomplete serialization. Problems that don't exist when the environment just stays alive.

Where persistence matters most

Software development is the clearest case. An agent implementing a feature needs to clone a repo, understand the architecture, install dependencies, write code, run tests, fix failures, iterate. Steps 2 through 5 are a loop. The agent's understanding of the codebase, its installed tooling, its test results, that's all state. In a persistent environment, the agent treats its desktop like you treat your laptop: it's there when you come back, in the state you left it.

Multi-day research is similar. A research agent accumulates browser bookmarks, downloaded papers, notes, intermediate results, and a workspace organization that encodes its mental model. Asking it to pack all that up between sessions is like asking a researcher to box up their entire office every evening and unbox it every morning.

Workflow automation is where ephemeral breaks down completely. An agent processing invoices or monitoring dashboards needs cron jobs and background services. Ephemeral sandboxes can't run cron jobs because the environment doesn't exist between executions.

Agents that learn from their environment (which tools work best, what the project conventions are, cached analysis) lose everything on reset. Persistence lets agents improve over time, across sessions.

The simplest approach: a VM that doesn't get destroyed

The most straightforward persistent environment is a virtual machine that sticks around. The agent gets a Linux desktop with a data disk that survives reboots. No state management API, no serialization. A computer that stays how the agent left it.

This is what we built with Le Bureau. Each agent gets an Ubuntu 22.04 desktop with 20-80 GB of persistent storage on a separate data disk. The desktop comes with a browser, terminal, VS Code, and the OpenClaw agent framework installed. The agent runs npm install once. Clones a repo once. Configures its tools once. Next session, everything is still there.

Other options exist at different levels. Fly.io Sprites gives you persistent Linux VMs with 100 GB NVMe and fast boot times, but no GUI. Docker volumes can persist data between container runs, though you lose OS-level state. E2B is adding GUI capabilities and moving toward persistence.

A pattern we like is hybrid: persistent desktop as the home base, ephemeral sandboxes for isolated code execution when you need to run something untrusted. Le Bureau supports this. The desktop persists, and the agent can spin up E2B sandboxes for risky operations.

When to stay ephemeral

Persistent environments aren't always right. If you're running untrusted code, you want the environment to vanish afterward. A compromised session shouldn't affect future ones. If your workload is "run this function 10,000 times with different inputs," disposable environments are cheaper and simpler. If your agent architecture already externalizes all state to a database, persistence at the infrastructure level is redundant. And if your agent only works 10 minutes a day, paying for a 24/7 VM doesn't make sense.

Try it

If you want to see the difference, do this: time your agent's session initialization. If it spends more than 30 seconds setting up before it can do real work, persistence will save you time and money on every single session.

Le Bureau has a free tier with 2 vCPU, 4 GB RAM, and 20 GB persistent storage. Deploy your agent, let it set up its workspace, shut it down, bring it back. See what changes when state just works.


Le Bureau provides persistent cloud desktops for AI agents. Full Linux environment, VNC access, real-time monitoring, and plugin support. Free during the beta.

Ready to give your AI agent a real desktop?

View plans

Get our next articles

Subscribe to our newsletter so you don't miss a thing.