camelAI moves its AI agent from VMs to Cloudflare's edge

According to the team, costs fell by several orders of magnitude, responses got faster, and cheaper models became viable. All the code was open-sourced on July 24.
By camelAI07-31 · 9 min read⚑ Tutorial / how-to
🎧 Listen to the podcast0:00 / --:--
0:00 / --:--
In-depth · XiaoHu explains
One-minute overview
  • Most teams run AI agents inside full Linux virtual machines. camelAI did too—until the numbers convinced it to dismantle the machine entirely.
  • The overhaul came in three steps: move the AI agent out, move the files into a database, then remove the command line. Nothing changed for users.
  • Removing the command line was the most radical step. But in the code, "removed" still leaves a narrow escape hatch.
⚑ This article is based on camelAI's own engineering blog. Its performance, cost, and model-quality claims are self-reported and have not been independently verified. Anything marked "Verified" below was checked against the open-source repository and Cloudflare's official documentation.
The starting point

An always-on machine and high-speed disk for every user could not support camelAI's planned scale

This is camelAI CTO Miguel Salinas's account of an architectural overhaul. The team completely rebuilt its AI agent, moving it from dedicated virtual machines to a lightweight architecture running on Cloudflare Durable Objects. According to camelAI, both cost and latency fell sharply. The migration happened in three stages, and all the code was open-sourced on July 24, making every mechanism verifiable in the repository.

New to camelAI? Here's the short version

camelAI is an AI coding assistant built by a three-person team: Illiana Reed leads product, Miguel Salinas leads engineering, and Isabella runs operations.

You tell it what you want in a chat box. It writes the code, installs dependencies, runs the project, and deploys it to a working URL. It can also connect to your databases and dozens of external services, run Python notebooks, and build dashboards.

The company's own description is "an AI software engineer that lives in its own computer." That "computer" was a Linux virtual machine assigned to each user—and it is exactly what this overhaul removes.

Most teams run AI agents in full Linux virtual machines or container sandboxes. camelAI started the same way.

The problem was the cost structure. Every user needed an always-on machine plus high-speed disk storage for project files. As the user base grew, scaling meant adding real machines and real disks. At camelAI's planned scale, the economics did not work.

When the user is active When the machine is running and billable One day Twice the users, twice the cost
Illustration only; the source gives no exact durations. The virtual-machine architecture bills for the gap between these timelines.

The hard part is that AI agents naturally assume they are running on Linux. They have been trained to reach for bash whenever they hit a problem. camelAI also started with the Claude Code harness, which itself requires a full virtual machine. A harness is the software layer around the model that runs the conversation loop and manages tools and state.

What a harness actually does
To make AI self-improving, start with the shell around the model: Lilian Weng explains harness engineering
That article explores the same idea—leave the model alone and change the software around it—and shows what a harness controls and how much difference redesigning it can make.

Instead of trying to schedule virtual machines more efficiently, the team redesigned the system around a more fundamental premise: it did not need virtual machines at all.

Just over four months earlier, camelAI CEO Illiana Reed had published a post beginning, "Every camelAI user has a persistent computer, a real Linux environment," calling it a core product promise. The post explained that Modal, Cloudflare Containers, and Fly.io's Sprites had all proved unsuitable, so the team spent a week building its own container service. Miguel notes that the old post remains online, although camelAI no longer runs any machines on that infrastructure.

The virtual machine contained three things: the AI agent itself, the project files, and the command line. The three-stage overhaul moved them out one by one. Each time, the team had to answer the same question: who would take over the work that component used to do?

BEFORE REPLACED WITH One Linux VM · always on AI agent Project files bash shell STEP 1 STEP 2 STEP 3 Cloudflare's edge Database + object storage 64 fixed methods Move all three, and the machine is no longer needed
The three-stage migration. Each of the next three sections removes one component and measures what that step actually solved. Diagram based on the original post and repository source.
Step 1

First, move the AI agent: faster responses, but the machine remains

The Claude Code harness could not be separated from its virtual machine, so the first job was to write a new one.

The foundation was pi, Mario Zechner's open-source AI agent toolkit, released under the MIT license and holding 81,000 GitHub stars. pi is a stack of libraries, not a single program. Its top layer is a command-line tool that assumes an operating system underneath it. The lower layers provide the raw components an AI agent needs—conversation loops and state management—without caring where they run. camelAI did not modify a single line of pi. It simply used the bottom two layers.

Verified

camelAI's package.json includes only @earendil-works/pi-agent-core and @earendil-works/pi-ai, both at version 0.80.6. It does not include pi-coding-agent, the command-line layer that assumes an operating system is present.

The new harness runs inside a Durable Object. This is a small Cloudflare compute instance with its own dedicated storage, activated in a data center close to the user. camelAI assigns one to each chat session.

Think of it this way

A conventional cloud service is like taking a number at a bank. A different teller may handle you each time, so you have to explain everything again. A Durable Object is more like a dedicated receptionist with a private drawer: you return to the same person, and the drawer still contains whatever you left there last time.

The virtual machine still exists at this stage; the AI agent simply no longer lives inside it. When a command needs to run, the AI agent calls the machine remotely. Anthropic describes its own hosted AI agents in similar terms: the brain and the hands are separated.

AI agent In a nearby data center AWAKE Wakes only for commands Virtual machine Runs commands only ASLEEP The machine may sleep through the entire chat—but it still costs money
The architecture after separating the brain from the hands. Diagram based on the original post.

This brought three benefits. The AI agent could respond without waiting for a machine to boot. The machine could sleep while the AI agent worked—and stay asleep for the entire turn if no command was needed. One brain could also direct several hands, operating multiple machines at once.

In the product, those "hands" are called projects. Each project had a virtual machine and a Git repository, created directly from code with Cloudflare Artifacts, so camelAI did not need to operate its own Git server. At this stage, the AI agent still had a command line and was largely unaware that it no longer ran inside the virtual machine.

Solved
Latency. Requests no longer had to travel to a central virtual machine. The AI agent was close to the user and did not need to wait for a machine to boot.
Not solved
Cost. Every user still had a virtual machine, so neither the expense nor the scaling problem changed.
Step 2

Next, replace the disk: store files as data and eliminate always-on machine costs

The next version removed the virtual machine without changing the project structure. The file system moved into the Durable Object, while large files went to Cloudflare R2, Cloudflare's object storage service.

The building blocks already existed. Cloudflare's Agents team had created a package called @cloudflare/shell, which describes itself as "an experimental Worker sandbox execution and filesystem runtime." camelAI reused substantial parts of its code.

A Durable Object's storage is already a SQLite database, with a 10 GB limit per instance and a per-row size limit. Small files are therefore stored directly in a row. Files larger than roughly 1.5 MB go into Cloudflare R2, leaving only a pointer in the database row. To the AI agent, it still looks like a normal file system. Underneath, it is a table and an object store.

AI agent writes a file LIMIT 1.5 MB Small file Large file Durable Object database app.tsx Content stored in row data.csv Pointer only → 10 GB PER INSTANCE Cloudflare R2 Large file stored here PAY FOR STORED DATA
How files are routed at the 1.5 MB threshold. Diagram based on the original post and repository source.
Verified
  • The threshold is a hard-coded constant in workspace-filesystem-do.ts: DEFAULT_INLINE_THRESHOLD = 1_500_000, or 1.5 million bytes.
  • Cloudflare's official documentation sets the storage limit for each SQLite-backed Durable Object at 10 GB on the paid plan, with a 2 MB limit per row. The 1.5 MB threshold leaves headroom below that hard 2 MB ceiling; it was not chosen arbitrarily.
What this step changes

In the virtual-machine architecture, files persisted because camelAI kept paying to maintain a machine and its disk. Now files persist because the data itself has been stored. Idle data is cheap; an idle machine is not. That is where this step cuts the real cost.

Version history still runs through Cloudflare Artifacts, so every project retains a complete Git history.

Solved
Storage costs and the cost of maintaining an always-on machine. Persistence changed from infrastructure that must stay alive into data that simply remains stored.
Still remains
The compute used while the AI agent is working. It still has a command line at this point, so commands need somewhere to run—and that environment is billed by the minute.
Step 3 · The key move

Finally, remove the command line: the AI agent writes JavaScript to call fixed methods

Removing the command line was the most radical of the three steps. camelAI says so itself.

The problem was not just cost. If an AI agent can run arbitrary commands and access the internet, it needs credentials to get useful work done—database passwords, API keys, and more. The team tried keeping credentials outside the environment through authenticated proxy URLs, but the implementation became increasingly fragile and difficult to secure.

The risk is not hypothetical
An unprecedented cybersecurity incident: an OpenAI test model escaped its sandbox and breached Hugging Face
That article gives a full account of what can happen when a model with credentials and internet access escapes its sandbox.

So camelAI removed the command line. The AI agent now writes JavaScript, which is executed through Cloudflare Code Mode. Instead of invoking one tool at a time, it writes a block of code that chains the necessary work together. Each execution starts in a fresh V8 isolate.

Think of it this way

A V8 isolate is not a new computer. It is closer to opening a new tab in a browser that is already running: it appears in a few milliseconds, uses only a few MB of memory, and disappears when the work is done. The next task gets another clean instance. According to Cloudflare, starting a container takes hundreds of milliseconds and consumes hundreds of MB.

Credentials stay outside the sandbox

The sandbox comes with access to the user's data connections and methods for everything the platform can do. Credentials never enter the sandbox. When the AI agent calls a connection method, authentication happens on the platform side. The key never appears anywhere the AI agent can reach.

Ephemeral sandbox V8 isolate AI agent's JavaScript Runs here Methods only Platform side Receives the call Authenticates itself 🔑 Keys stay here External service Credentials blocked Even faulty AI agent code cannot access the keys
How credentials remain isolated on the platform side. Diagram based on the original post and repository source.

How much capability is lost without the command line?

Most of what the AI agent used the command line for was file manipulation: listing directories, reading files, editing files, and searching content. Native tools cover roughly 80% of that work. The remaining 20% consisted of specific commands for specific jobs, which the team converted into explicit methods one by one.

REMOVED ADDED bash shell $ ls / grep / cat $ npm install $ python analyze.py $ wrangler deploy $ Anything goes… 7 native file tools read · write · edit · ls grep · find · delete 64 fixed methods deploy_project · run_notebook add_dependency · take_screenshot…
The command line and its replacements. Method counts and tool names come from the repository source.

The "Anything goes" line on the left is exactly what disappeared. The AI agent can now do only what the team has anticipated and implemented among those 64 methods.

Verified · Two differences from the public account
  • The public description says "read, write, edit, plus our own grep and glob." The code actually contains 7 tools: read / write / edit / ls / grep / find / delete. The extras are ls and delete, while glob is named find in the code.
  • The file containing the methods, code-mode-tools.ts, is 4632 lines long and registers 64 methods. These include platform operations such as deploy_project and run_notebook, along with general-purpose harness tools such as WebSearch and TodoWrite.
  • The sandbox also provides tools.search(). The AI agent searches for tools by keyword, then uses tools.describe() to inspect their parameters. It does not need all 64 manuals loaded into its context at once.
  • The system prompt contains a hard rule: do not use create-worker, wrangler, or package-manager commands for scaffolding, builds, or deployment. It explicitly blocks the model's old habits.

Deployment is the clearest example. Previously, the AI agent ran wrangler deploy through a proxy. The platform had to inspect proxy traffic and infer which session had deployed something. Now deployment is handled by a platform-controlled deploy_project method. The platform knows exactly when a deployment occurs, so it can attach a hook and automatically open the preview when deployment finishes.

Solved
Credential exposure. Keys never enter the sandbox. The platform also regains certainty about what the AI agent is doing, because every action runs through the platform's own code.
Trade-off
The AI agent can now do only what the team anticipated in advance. The next section examines that cost directly.
Results

The results: reportedly lower costs, faster responses, isolated credentials, and open-source code

After all three steps, the new architecture reportedly delivered four gains.

Cost: from paying for uptime to paying per execution

Virtual machines and containers incur ongoing costs.isk charges whenever they are awake, even when no one is using them. An isolate exists only when invoked and disappears when the work is done. When it is not running, it does not exist—and generates no bill. Scaling no longer means adding real machines and real disks.

Container · billed while awake Billing runs from startup to shutdown, used or not Dynamic Worker · billed per run The gaps cost nothing because no instance exists TIME →
The difference between the two billing models. Diagram based on the original post and Cloudflare's official pricing documentation.

camelAI's comparison is that thousands of executions cost roughly the same as a few minutes on the container services it evaluated. The independently checkable figures are Cloudflare's own numbers, published in its March 24, 2026 announcement for Dynamic Workers:

A few ms
Typical isolate startup time; a typical container takes hundreds of milliseconds
About 100×
Cloudflare's stated startup-speed gap; memory efficiency is 10 to 100 times better
$0.002
Price for each unique Worker loaded that day; waived during testing

But the entire post lacks a before-and-after bill. Its conclusion says costs are "orders of magnitude lower," yet it never provides numbers such as the previous monthly cost and the current one. That claim comes from camelAI alone and cannot be independently checked by readers.

Latency: the AI agent runs in the data center closest to the user

The AI agent runs on Cloudflare's edge, so requests no longer detour through a central virtual machine. It does not wait for a virtual machine to boot either; it can begin responding as soon as the user finishes speaking.

Security and cheaper models: credentials stay out, and tool boundaries become clearer

Credentials never enter the sandbox. Authentication happens on the platform side, so the AI agent never holds a key.

A command line is open-ended: almost anything can be typed into it. Cheaper models are more likely to experiment aimlessly, take detours, or get stuck in that environment. camelAI says they perform noticeably better when given a small set of methods with clear boundaries. That feeds directly into cost. Making the product economical is the point of the architecture, and model spending has to fall too.

There are no public numbers for this claim either. The repository contains 52 test files that run real models, plus a group with camel-free- in their filenames, apparently intended for cheaper models on the free tier. But no benchmark results have been published.

All the code is open source

camelAI released its repository under the MIT license on July 24 at Github.com/qaml-ai/camelAI. Every mechanism described above can be traced to its corresponding source file. That is how the items marked "Verified" in this article were checked.

What remains

After the teardown, Linux survives in only three places: building apps, running data analysis, and querying databases

Building a user's application still requires a container because this work genuinely needs Linux. User applications are built with Vite, Tailwind, and React Router, and adding a dependency requires bun install.

The team considered building inside a Worker, since the finished application is itself a Worker. But Cloudflare does not support that path well, and a Worker has only 128 MB of memory and a fraction of one CPU. Builds would be slow, and many projects would simply run out of memory. We verified the 128 MB limit in Cloudflare's official documentation; it is the same on free and paid plans.

The solution is to start a container when a build is needed, copy the project in, run the build, retrieve the result, and shut the container down. Notebooks work the same way. Linux is still used—but only for the few seconds when it is genuinely necessary.

Verified · The code differs here

The public account mentions two containers, but the production configuration actually defines three categories. The third runs SQL queries and data exports and is not mentioned in the blog. A code comment explicitly says that this container does not run user code.

ContainerPurposeSizeMaximumSleep after idle
Build sandboxRuns bun install and frontend builds2 vCPU · 8 GiB1002 minutes
Analysis sandboxRuns notebooks, shell, and DuckDB2 vCPU · 8 GiB1005 minutes
Query sandboxRuns SQL queries and exports (not publicly mentioned)0.5 vCPU · 4 GiB252 minutes

Data comes from the repository's production configuration and container-sizing.ts.

Code comments explain why the idle timeout is only 2 to 5 minutes: memory and disk are billed by provisioned capacity for as long as the container remains awake; only CPU is billed by actual usage. A running container burns money even when it is doing nothing. This is the same rule that explains why camelAI removed its always-on virtual machines, just at a different scale.

"Removing bash" still leaves an escape hatch in the code

The repository includes a method called analysis_exec, which can run shell commands inside the analysis container. Its tool description explicitly calls it an escape hatch for data tasks that run_notebook cannot handle.

Strictly speaking, then, the command line has not disappeared from the system. It has disappeared from the AI agent's everyday workspace and become a narrow, purpose-specific route through a designated container. That is very different from giving the AI agent unrestricted access to bash at all times—but it is not the same as literally removing the shell.

The trade-off

The AI agent can no longer improvise its own route; the team must anticipate every missing capability

camelAI acknowledges this directly. With a command line, an AI agent can work out its own solution when it encounters something unfamiliar. Now, whenever a capability is missing, the team has to add it.

The honest downside is that we have to anticipate what the AI agent will need. With bash, it could explore on its own. Now, if a capability is missing, we have to add it.

Miguel Salinas, camelAI CTO

The team believes that pressure is good for the product. It forces camelAI to understand what users are actually trying to do and build a proper path for it, instead of letting the AI agent improvise in production.

There is another unmentioned cost

We read camelAI's grep implementation. It loads every file under a directory and scans it line by line in JavaScript. It can inspect up to 20,000 files, returns 100 matches by default, and truncates lines longer than 500 characters.

A purpose-built tool such as ripgrep is a compiled program optimized for parallel disk searches. The two are not in the same performance class. Small projects may hide the difference. The public material does not explain what happens when repositories grow large.

Conclusion

An AI agent does not need a computer—and camelAI had to dismantle one to see it

The industry's default approach is to reproduce a human programmer's work environment for an AI agent: a machine, a file system, and a command line. That is how human programmers work, so the AI agent gets the same setup.

After removing that environment piece by piece, camelAI concluded that an AI agent really needs precise capability interfaces. If it needs file operations, give it seven tools. If it needs deployment, give it a method. It does not need to know whether a real computer exists underneath.

The reusable lesson

The migration path itself is the method: first separate the AI agent from its environment, then move state out of the machine and into data, and finally replace open-ended capabilities with bounded interfaces. Each step can be tested and rolled back independently, making the process far less risky than replacing everything at once.

Nothing changed for users. They still ask the AI agent to build an application and deploy it to a working URL. The AI agent still reads files, writes files, searches content, and publishes projects. The promise from four months earlier—"every user has a persistent computer"—remains intact. That "computer" is now a database table plus a disposable sandbox.

One piece still blocks anyone trying to reproduce this today

Cloudflare Artifacts remains in closed beta. The official documentation, last updated May 5, 2026, says access requires submitting an application form. The version-history layer in this architecture does not yet have a public entry point.

Another issue is not a hard barrier, but it is worth knowing: @cloudflare/shell describes itself as "experimental." The package debuted on March 13, 2026 and had released 19 versions by July 23. The latest was 0.4.3, while camelAI pins version 0.3.7. Nineteen releases in just over four months suggest that this foundation is still changing rapidly.

What anyone can use immediately is the code itself. camelAI released the repository under the MIT license on July 24, and every mechanism has a corresponding source file.

camelAI open-source repository (MIT): Github.com/qaml-ai/camelAI. Four files are enough to inspect the core mechanisms, mapped directly to the three migration stages: workers/main/src/chat-thread-do.ts contains the AI agent's main loop running inside the Durable Object (Step 1); workspace-filesystem-do.ts implements the database-backed file system, with the 1.5 MB threshold near the top (Step 2); code-mode-tools.ts contains the 64 methods that replace the command line (Step 3); and pi-container-tools.ts contains the 7 file tools, including the line-by-line grep implementation.
Source
Our AI Agent Runs in a Cloudflare Durable Object, Not a VMMiguel Salinas, camelAI·Original article·2026-07-28
Editorial note
The source article contains no illustrations. Every chart on this page was created from the original post and repository source. The first timeline is illustrative, and its durations are our assumptions. Items marked "Verified" were checked against the camelAI open-source repository, accessed on 2026-07-31, and Cloudflare's official documentation. Differences involving the number of file tools, the number of container categories, and the grep implementation were either omitted from the public account or inconsistent with the code, and are identified in the article.
↑ End of article
✓ This article is free to read in full

Members can copy or download the full Markdown, and let their AI subscribe and ask.

Read the original ↗
📮 New explainers, straight to your inbox

Found this useful? Leave your email — every new explainer, the moment it's out. Unsubscribe anytime.