Cloudflare OS explained: How it tackles hallucinations, overreach, and errors

An agent wants to merge code, but before you approve, the system tells it the merge is done. The whole platform assumes AI will mess up.
By lord.technology08-06 · 12 min read⚑ Expert view · personal take
Deep Dive · xiaohu's take
Key Takeaways
  • Cloudflare open-sourced its internal AI office platform, Cloudflare OS, where every document is its own isolated app whose code you can modify on the fly.
  • The most counterintuitive feature is when an agent asks to merge code, the system replies "done" before you approve, then spins up a fake branch for it to continue working on.
  • Jamie Lord read the entire source code and concludes the system's core principle is a total lack of trust in AI.
  • After examining all five mechanisms, there's a trade-off: the leash that keeps it safe is the same one that limits how much it can do.
⚑ The main analysis comes from Jamie Lord's third-party review. All source code references in this article were checked by us against the cloudflare/cloudflare-os repository. Performance figures and statements like "AI cannot introduce major security vulnerabilities" are Cloudflare's official claims, and are flagged where they appear.
Overview

What is Cloudflare OS, and why does it assume AI will fail?

On August 5, Cloudflare open-sourced its internal AI office platform, Cloudflare OS, which has been used company-wide for three months. You can deploy it on your own servers.

What is Cloudflare OS?

Every employee gets their own agent workspace pre-loaded with company knowledge and internal skills, ready to research, write documents, build spreadsheets and slide decks, or simply take on assigned tasks.
Connects to and works with your company's systems GitHub, Google Drive, Slack, Notion, Linear, and internal databases—the repo includes 16 connectors for reading and writing.
Every document is its own mini-app Behind each slide deck or spreadsheet is its own codebase and database, which you can ask the agent to extend at any time.
Non-technical staff can build apps safely Apps are isolated from each other. If one person breaks their app, it doesn't affect anyone else, and the security team doesn't have to babysit.
Models are swappable, and costs are transparent Works with Anthropic, OpenAI, Google, and Workers AI, all tracked through a single gateway for cost monitoring.
Fully open-source, not locked to Cloudflare Released under the Apache 2.0 license, it runs on the open-source workerd runtime and can be moved entirely to your own servers.

Cloudflare employees have been using it internally for three months, creating over 4,000 of these mini-apps in the last 30 days alone. The sales team estimates it has saved them over 10,000 hours.

Related Article
Cloudflare Open-Sources Its Internal AI Office Platform: An 'AI Operating System' for Every Employee
That article covers the full feature set and steps for self-deployment.

Jamie Lord, author of Architecting on Cloudflare and a solutions architect at UK-based CDS, has done a deep, source-level analysis of Cloudflare OS. His key insight:

Core Finding

Cloudflare OS is, at its heart, a system built on a total distrust of AI. It treats AI errors—hallucinations, overreach, mistakes—as inevitable facts of life and then works the architecture to make it impossible for AI to break the system.

Traditional Thinking

Try to make AI smarter and less error-prone: write better prompts, give it more permissions.

The Cloudflare OS Approach

Acknowledge that AI can confidently spout nonsense and break things. Since 100% correctness is impossible, build the platform as a "canary cage." Let AI think it has unlimited power and work efficiently, but keep real control (the ability to commit) firmly in human hands.

In one sentence: It demonstrates how, in an era where LLMs are still unreliable, you can use capabilities, isolates, and simulations to build a next-gen agent operating system architecture that lets AI automate workflows but can never cause a corporate security disaster.

The core philosophy behind this design can be broken down into these five key mechanisms.

Premise: AI will fail 01 Simulate success Before you approve, the system tells the agent it's done 02 Sandbox isolation Each doc gets its own room; bad code breaks only its room 03 Withhold keys Keys stay with the gatekeeper; agent gets a few methods 04 Track data lineage Tracks what it read; checks permissions before sharing 05 Distrust humans too External PRs over a few lines are closed Five mechanisms, five safety features—together they form a single coherent philosophy.
Illustration created for this article. One section below covers each mechanism.
Mechanism 1

Simulate Success: The System Tells the AI It's Done Before You Approve

How it works
When an agent wants to do something with real consequences—merge a PR, send an email, write data to a production system—it must go through a small service called Gatekeeper. Until you approve, the gatekeeper "lies." It creates a simulated environment where the action appears to have succeeded. When the agent goes back to check the branch, it sees a fake "merged" state.
Effect
The agent thinks it’s done, continues its work based on that fake state, and queues up the next three steps that depend on it. No real actions occur; they all wait in the queue. Later, you look at the batch and approve or discard it all at once. If you discard, everything the agent built on that false premise disappears with it.
Benefit
This eliminates the friction of AI constantly pausing for approval while ensuring it can't touch the real world without authorization. The agent gets the throughput of auto-approval; you keep the veto power of review.

This approach is described in the interface documentation for gatekeeper developers:

It is suggested that the gatekeeper "simulate" actions that have not been approved yet, meaning the Session interface should behave as if all actions have been applied.

It is suggested that the gatekeeper "simulate" actions that have not been approved yet, that is, the Session interface should reflect the state of the resource as if all actions had been applied.
cloudflare/cloudflare-os · gatekeeper.ts
The world the agent sees (dashed) vs. what actually happens (solid) Agent writes code, works Merge this PR Gatekeeper holds the keys Merged ✓ (fake) Approval queue · real actions wait Human Approves or discards the batch The agent never stops; the action that actually hits the world waits for a human.
Illustrated based on the source code's interface docs. Dashed lines show the agent's reality; solid lines show what truly happens.

One important detail: simulation is recommended, not mandatory. It's up to each gatekeeper's developer. The real red lines are the other three: every action must go through the approval queue, reads must be authorized, and actions with side effects must never be truly executed before approval. "Simulating success" is just an optional optimization to keep the agent moving.

Databases already use this trick

It's essentially optimistic concurrency applied to real-world actions: assume things will go smoothly, let everyone work ahead, and check for conflicts at commit time. If there's a conflict, the whole batch rolls back. The cost is the same: the agent lives in a fake state for a while, and the things it thinks it accomplished may never actually happen. But that's fine, what it believes doesn't matter. The final write to the system waits for a human.

Mechanism 2

Sandbox isolation: Every document lives in its own room, so bad code can't spread

How it works
When you create a slide deck in Cloudflare OS, the system spins up a separate instance called a gadget: its own runtime, its own database, and outbound network access disabled by default. Each document is an independent sandbox process, built on V8's lightweight isolate technology.
Effect
The security boundary moves from code to the platform. For the past 25 years, the boundary in multi-tenant software has been drawn in the application code: one shared service holds everyone's data, and a missing tenant_id in a WHERE clause leaks customer B's data to customer A. Security depended entirely on whether the code was written correctly. One bad day for a junior engineer meant a data breach.
Benefit
Even if the AI writes buggy code, it can only harm its own owner, because there's no one else in that sandbox to leak to.
Past 25 years: boundary lives in code One shared service Data A Data B Data C Data D Missing a tenant_id leaks data next door Cloudflare OS: boundary lives on the platform Room A Room B Room C Room D The same crack hits a wall The red line on the left is the same bug. On the right, it has nowhere to go because there's no one else in that box.
Illustration created for this article based on the original text and official README.

Kenton Varda, the lead behind Cloudflare OS and creator of Cloudflare Workers, said on launch day: the sandbox is so safe you can tinker freely, and AI cannot introduce major security vulnerabilities. A company's security team can let non-technical colleagues vibe code and still sleep at night.

They gave up on making AI write perfect code

They didn't try to make AI code more trustworthy. They abandoned that goal entirely. Security no longer depends on writing code correctly. What the agent writes is no longer a security issue.

This "isolate every document" idea comes from Kenton's decade-old startup, Sandstorm, which didn't take off. Two reasons are often cited. First, it was too expensive: containers were the only option, and spinning one up was costly. Second, per Kenton: the world wasn't ready—there wasn't enough skill or patience to adapt software. Both reasons together make sense: it finally became cheap and the skills finally exist.

How much cheaper? Here are the official figures:

hundreds of msTypical container start, hundreds of MB of RAM
a few msAn isolate start, a few MB of RAM
~100xSpeed difference; 10-100x memory efficiency

An isolate is a lightweight execution environment from the V8 engine (the one that runs Chrome). The analysis article claims containers take "several seconds" to cold-start, which is an order of magnitude off from the official numbers. We've used the official figures.

Mechanism 3

Withhold keys: The agent never gets secrets, only a few methods

How it works
The usual way to give an agent GitHub access is to hand it a GitHub token. But tokens in prompts can end up anywhere the prompt's output goes. Cloudflare OS never gives credentials to the agent. The keys stay with the gatekeeper. The agent gets an object with methods, written in code simply as env.PROJECT.
Effect
Configure the GitHub gatekeeper for a repo, and it can let the agent read issues but not source code, redact certain fields, and refuse to merge unreviewed changes. The agent can call listIssues(), but it never sees the token, can't widen its own permissions, and can't reach the network beyond the few methods it has.
Benefit
This protects against prompt injection, where an agent might leak a secret, either accidentally or through malicious instructions. A key can open doors for anyone who finds it. This is more like a leash: it's just enough for one task, can be taken back anytime, and the other end is always in your hand.
Typical approach: hand the token to the agent Agent 🔑 token ends up in logs leaks in output stays downstream Once handed over, you can't take it back. Cloudflare OS: hand over a leash Agent listIssues() Can be cut anytime Gatekeeper 🔑 Keys here The agent never touches the key.
Illustration created for this article. The three red lines on the left are what anyone who's used an MCP server fears.

This "methods, not keys" approach has a formal name: the object-capability model, a concept studied in security circles for decades.

Mechanism 4

Track Data Lineage: The System Knows What the Agent Read and Checks Permissions Before Sharing

How it works
The system logs every piece of data the agent reads. When Alice shares a gadget with Bob, the system checks with each gatekeeper the gadget has touched: does Bob have permission to see everything this gadget has read from you? If any single one says no, Bob can't get in. Going forward, any new read by the gadget that Bob isn't authorized for is immediately blocked.
Effect
This closes a specific leak: an agent reads a sensitive revenue spreadsheet and creates a real-time dashboard. The dashboard is a new object with no permission list of its own. Sharing it is effectively handing that spreadsheet to everyone who can see the dashboard. No single step in the chain is wrong, but the data still leaks.
Benefit
Whether a share is safe no longer depends on the sharer remembering what data powers the dashboard.
Alice's gadget has read from the three sources below GitHub repo Bob can read ✓ Shared calendar Bob can read ✓ Revenue sheet Bob not allowed ✕ Bob tries to open it One "no" closes the door The system checks: can Bob directly read everything this gadget has already read?
Based on the description in the repo's docs/observers.md. The check repeats each time Bob opens it.

Ultra-safe fallback (lockdown mode): For data too sensitive to be described by existing rules, you can simply flag it as "allow no sharing." Once a gadget reads such data, it immediately enters lockdown mode. It can still read, but it can no longer take any action through any gatekeeper, completely sealing off the leak path. The code comments even admit this is a temporary measure, to be replaced by finer-grained rules later.

Also worth noting: prompt injection is still an unsolved problem in this architecture. The source code's TODO list still has two items: detecting whether free-text content in a read could be a hidden injection, and identifying who has written to these content sources.

Mechanism 5

Distrust Human Contributors Too: External PRs Over a Few Lines Are Automatically Closed

How it works
The project's contributing guide gets straight to the point: External contributions are not accepted at this time. Even typo-fix PRs are explicitly discouraged, and anything over a few lines will be closed with a link to this rule.
Why
In the AI era, writing code is cheap, but reviewing it, ensuring quality, and maintaining product coherence is expensive. An external contribution is essentially donating the easy part while creating more of the hard part.
Implication
What's scarce in software has flipped: writing code is no longer the bottleneck. Vouching for it is.

An unreviewed contribution is untrusted input, whether it came from a careless human or a confident model is almost irrelevant. The system's distrust of AI thus extends to a distrust of human contributors.

The Trade-off

The Cost of This Design: The Tighter You Control AI, The Less It Can Do For You

The five mechanisms above are clever. But they share a common cost: the tighter you control AI, the less work it can do for you. This breaks down into two things.

First, an agent that never gets keys can never do the jobs that require keys. It can't renew a service or call an API that no one has explicitly opened for it. The system design just doesn't give it that power. It can only operate within the bounds you've defined. Anything outside that, a human still has to do.

Second, write operations always need human approval, meaning a human is always in the loop. This design certainly means you don't have to watch every step, but that batch of pending actions still needs your review and your click. And the whole point of an agent was to stop needing a human to watch over it. The human is still in the loop, just moved from "present at every step" to "always present for the final step."

The same agent, the same leash, tied to the same post The good side: it tries to run forward, the leash holds it back Platform constraints Agent Cliff Can't run off The bad side: it wants to do more, but is held in place Same post Agent The work Can't pull it A shorter leash means more safety and less capability. It's one dial with two ends.
Schematic based on the key trade-off mentioned in the original text.

To summarize the trade-off: The same leash that keeps it from running amok is the one that stops it from pulling a heavy load. You can't have maximum autonomy and maximum safety at the same time. Cloudflare chose safety, and chose it firmly. Their bet is that a leashed agent you can actually deploy inside your company is more valuable than a free agent you're too scared to use.

One more paradox: It distrusts everyone, except itself

The system's logic is "trust no one": not AI, not user code, not outside programmers.

But there's one exception: Cloudflare itself.

The technologies used for isolation, approval, and tracking (Workers, Durable Objects, etc.) are all Cloudflare's own, some built specifically for this project and available nowhere else. So this "trust no one" system is itself built on the premise that you must trust Cloudflare.

The saving grace is that it's fully open-source, running on the open-source workerd runtime. In theory, you can move it to your own servers, which is more than most similar products. But using it comes with accepting that premise first.

Finally: Even its creators haven't figured out how to define an Agent

In the repo, there's a table mapping Cloudflare OS components to those of a traditional OS: what maps to the kernel, drivers, processes. The first rows all match up. The last one is blank, with three question marks.

Traditional OSCloudflare OS
Kernelworkshop-backend
Device driversGatekeepers
Shellworkshop-frontend
Processesgadgets
Executablesblueprints
UsersUsers
PermissionsShare permissions
???Agent

The question marks mean: in a traditional OS, there's no such thing as an "AI agent."

It's not a regular user: user permissions are pre-defined, but an agent answers to a specific person, and its permissions need to be granted and revoked in real-time. It's also not a regular program: program code is written in advance, but an agent writes its own code as it goes.

Cloudflare's answer is that the best way to manage this new thing is via "you can only do the specific things I allow" (the capability model), rather than the traditional "what groups are you in, what permissions do you have" list.

But they didn't fill in that row either. This is a new species, and even its creators haven't figured out how to define it.

What you can take away is the pattern, not the code: let reads go straight through, suspend writes and hand back a simulated result so the agent keeps moving, then batch the real actions for a single review. This pattern can be applied to any self-hosted agent pipeline and solves the "either stop for approval or disable safety" dilemma.
Source
Cloudflare OS is an architecture of distrustJamie Lord·lord.technology·2026-08-05
Editor's note
The original article had no illustrations; all diagrams here were created for this piece based on the original text and source code. All cited source code was verified against the cloudflare/cloudflare-os repository: the simulation clause comes from packages/workshop-shared/src/gatekeeper.ts, read tracking from docs/observers.md, lockdown mode and injection TODOs from gatekeeper.ts, and the contribution policy from CONTRIBUTING.md. Container vs. isolate performance figures use Cloudflare's official numbers (the analysis article's "several seconds" differs by an order of magnitude and was not used). Kenton Varda's quotes are from his 2026-08-05 launch post.
↑ 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.