Back to Cloudflare

Browser Automation and Isolated Agent Workspaces

November 5, 2026 Wasil Zafar 29 min read

Connect Browser Run, Sandboxes, and Git-backed Artifacts

Table of Contents

  1. Browser Run Controls a Browser Session
  2. Sandboxes Execute Commands With Their Own Boundaries
  3. Artifacts Versions File Trees Through Git Interfaces
  4. Credentials, Network Access, Persistence, and Cleanup
  5. Design a Reproducible Document-Capture or Coding Workspace
  6. Check Workspace Isolation and Capture Reproducible Output Metadata

Browser Run Controls a Browser Session

An accounts-payable team wants to capture a monthly invoice from a supplier portal. A Worker fetches the page and gets back a shell: an empty <div id="app"> and a script tag. The total appears only after a login redirect, and the PDF link is generated by JavaScript. No amount of HTML parsing will produce the number, because the number is not in the HTML.

The fix is not a larger Worker. It is a browser. Browser Run, renamed from Browser Rendering in April 2026, runs headless Chrome on Cloudflare's network and lets your Worker drive it. Three terms make the rest of this article easier to follow:

  • A browser session is one running Chrome instance with an ID, one or more tabs, and isolated browser contexts that hold cookies and storage. You control it through Puppeteer, Playwright, or the Chrome DevTools Protocol (CDP).
  • Quick Actions are stateless single-request endpoints such as /screenshot, /pdf, /markdown, and /json. They handle the browser lifecycle for you and are the right choice when one request is the whole job.
  • CDP is the protocol those libraries speak. A session exposes a WebSocket endpoint, so a client outside Workers can connect too.

A useful analogy is a visitor badge. A browser session lets you walk the public corridors and look at screens, but it does not let you open the building's electrical cabinets. A sandbox, covered next, is a leased workshop. Artifacts is the off-site records office. Each grants a different kind of access, and confusing them is how teams end up with credentials in the wrong place.

Figure 1 shows the control path and the trust boundaries. Your Worker holds the secrets and decides policy. The browser binding creates the session. Guardrails decide which hostnames the browser may contact, and an outbound Worker can add a credential after a request leaves the browser, so the credential never enters it.

Browser Run Controls a Browser Session
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','titleColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
flowchart TD
    W["Worker: auth, policy, secrets"] -->|"browser binding"| CP["Browser Run control plane"]
    CP --> S["Browser session: Chrome process"]
    S --> C1["Context A: cookies and storage"]
    S --> C2["Context B: cookies and storage"]
    C1 --> G{"Guardrail allowlist"}
    G -->|"allowed"| NET["Public origin"]
    G -->|"denied"| BLK["Request blocked"]
    C1 -->|"outboundByHost"| OW["Outbound Worker adds credential"]
    OW --> PRIV["Private service"]
    S -.->|"no shell, no disk"| NONE["No Linux workspace"]
    classDef primary fill:#132440,color:#ffffff,stroke:#0b172b;
    classDef secondary fill:#16476A,color:#ffffff,stroke:#0f314a;
    classDef ok fill:#3B9797,color:#ffffff,stroke:#2a6f6f;
    classDef danger fill:#BF092F,color:#ffffff,stroke:#7a0420;
    classDef warn fill:#c4873b,color:#132440,stroke:#8a5a1f;
    class W,CP,NET primary;
    class S,C1,C2,OW,PRIV,NONE secondary;
    class G ok;
    class BLK danger;

Figure 2 layers the same system and makes the boundary explicit: the browser is a full Chrome, but it is not a machine you administer. Page JavaScript executes inside the browser sandbox, not in your Worker, and it cannot read your Worker's bindings or secrets. That protection runs in one direction only. Code running in the page can still act with the browser's authority, including sending data to any host the guardrail allows.

Browser Run layers and trust boundaries A Worker at the top holds secrets and policy. Below it, the Browser Run control plane manages session lifetime. Below that, a Chrome session runs page JavaScript with cookies and storage. A guardrail sits on the network boundary, and an outbound Worker can add credentials to requests for a private service. Your Worker Authenticates the caller, holds secrets, chooses the session policy Browser Run control plane Creates sessions, enforces guardrails, closes sessions, reports usage Chrome session Page JavaScript, cookies, storage, tabs Ephemeral: no shell and no disk you control Network boundary Guardrail allowlist outboundByHost to a Worker Secrets stay above this line. The browser receives authority, not the credential that grants it.

Configuration follows the model. A guarded session names the hosts it needs, and keep_alive extends the idle window rather than the maximum duration.

import puppeteer from "@cloudflare/puppeteer";

const browser = await puppeteer.launch(env.BROWSER, {
  keep_alive: 120000,
  guardrails: {
    allowedDomains: ["supplier.example", "*.supplier.example"],
  },
  outboundByHost: {
    "private.example.test": env.OUTBOUND,
  },
});
# Two docs disagree on the minimum version; check what is installed
npm ls @cloudflare/puppeteer

Limits are fixed when the session starts. Guardrail policy cannot be widened later, and the idle window has a hard ceiling.

Setting or eventLimitOperational note
Idle timeout60 seconds by defaultThe session closes; keep_alive raises the window
keep_aliveUp to 1,200,000 msAny command inside the window resets the clock
allowedDomains50 entriesPolicy is fixed at session start
allowedDomainSets4 setsPolicy is fixed at session start
Malformed policyRejectedFails the request with 400; never silently widened
Release rolloutAt any timeSessions close, so long-lived browsers must reconnect

Credentials stay outside the browser. outboundByHost maps an exact hostname to a Worker service binding, so the request is routed through your Worker, which adds the Authorization header before fetching the real service. The hostname needs no public DNS, and because the token never enters the page, page JavaScript cannot read it.

A disconnect is not a close

browser.disconnect() drops one CDP connection and leaves a shared session alive for other clients. browser.close() terminates the browser for everyone, so one careless close in a pooled design is a cross-tenant incident, not just a cleanup bug.

Sandboxes Execute Commands With Their Own Boundaries

The invoice PDF is now downloaded. Extracting line items with pdftotext and normalizing them with a Python script needs a Linux process, and that is a different product boundary.

Sandboxes on Cloudflare is the umbrella for running code you did not write and do not trust. It offers two environments. A Container runs an image you provide in a Firecracker microVM with its own kernel and network; it can run any language, keep processes alive, and hold files on a disk. A Dynamic Worker runs JavaScript, Python, or WebAssembly against methods your Worker passes in; it cannot start child processes or load native add-ons. Both are reached through a Worker. At writing time the Sandboxes documentation marks the product as available on the Workers Paid plan, and Artifacts carries the same requirement, so do not assume a Free-plan path exists.

The boundary is the sandbox, not the process. A sandbox isolates your Worker and other sandboxes from the code. It does not isolate one process inside a sandbox from another, and it does not limit what the code does with anything you place inside.

One sandbox, one trust boundary

Every process shares the same Linux system, reads the same files, and sees the same localhost ports. In a deployed container, processes run with the capabilities of root, so a separate Linux user is not a security boundary. If two users share one sandbox, each can read the other's work.

The table compares the four execution surfaces you are likely to choose between, and the decision rule is cumulative.

BoundaryWorkerDynamic WorkerContainer sandboxBrowser Run session
Isolation unitRequest isolateV8 isolate per loaded moduleMicroVM with its own kernel and networkChrome process per session
Runs Linux binariesNoNo child processes or native add-onsYes, from your imageNo shell; page JavaScript only
Filesystem you controlNoneNone; values are passed inWritable disk for the life of the instanceNo workspace; cookies and storage only
Outbound defaultPublic Internet through fetchWorker network unless globalOutbound is nullBlocked unless enableInternet is trueUnrestricted unless guardrails are set
LifetimePer requestPer load or callDurable Object activity, then up to 6 hours idle60 seconds idle by default, up to 20 minutes
Billing unitRequests and CPURequests and CPUProvisioned memory and disk plus active CPUBrowser hours and concurrency
Best fitDeterministic HTTP and HTMLGenerated scripts against known methodsBuilds, tests, agents, previewsRendered pages, logins, PDFs

Use a Worker when the job is deterministic HTTP or HTML and needs neither rendering nor binaries. Add Browser Run when the page requires JavaScript, a login, or a real PDF render. Move to a container sandbox when the job needs a Linux toolchain, a writable disk, or a process that outlives one request. Use a Dynamic Worker when generated code only needs methods you define and you would rather not maintain an image. A browser plus a sandbox is normal; a browser plus a sandbox plus a repository is the full workspace pattern in this article.

A worked comparison makes the credential rule concrete. Suppose an agent must run npm install and then npm test. The network policy decides what a compromised dependency can do.

Network policyInstall worksWhat a compromised dependency can do
enableInternet: trueYesReads every environment variable, including any exported token, and POSTs it anywhere
enableInternet: false, no handlerNoNothing leaves, so the install cannot reach the registry either
Internet off plus a registry allowlistYesRequests reach the registry only; every other destination is refused
Allowlist plus method and body rulesYesGET and HEAD only; the Worker adds its credential after the request leaves

The handler, not the dependency, holds the credential. A compromised package can still misbehave inside the sandbox, but it cannot turn a readable token into an outbound message to an arbitrary host. Method and body rules close the remaining path: no request bodies on read routes, no writes at all.

// The container class, not the sandboxed code, decides what leaves
export class AgentContainer extends Container {
  enableInternet = false;

  static outbound = async (request: Request) => {
    if (request.method !== "GET" && request.method !== "HEAD") {
      return new Response("Method Not Allowed", { status: 405 });
    }
    return fetch(request);
  };
}
# Inside the sandbox: the same commands, no direct egress
npm install
npm test

Figure 3 traces a single job, including the two ways it commonly ends badly. The Durable Object is the identity and coordination layer; the container is the Linux instance; the outbound handler runs in your Worker.

Sandboxes Execute Commands With Their Own Boundaries
%%{init: {'theme':'base','themeCSS':'.edgeLabel .label text, .edgeLabel text, .edgeLabel span { fill:#132440 !important; color:#132440 !important; }','themeVariables': {'primaryColor':'#16476A','primaryTextColor':'#ffffff','primaryBorderColor':'#132440','secondaryColor':'#3B9797','secondaryTextColor':'#ffffff','secondaryBorderColor':'#132440','tertiaryColor':'#c4873b','tertiaryTextColor':'#132440','tertiaryBorderColor':'#132440','lineColor':'#5a6e82','textColor':'#132440','mainBkg':'#16476A','nodeBorder':'#132440','clusterBkg':'#eef3f7','clusterBorder':'#132440','edgeLabelBackground':'#ffffff','actorBkg':'#16476A','actorTextColor':'#ffffff','actorBorder':'#132440','activationBkgColor':'#3B9797','activationBorderColor':'#132440','signalColor':'#5a6e82','signalTextColor':'#132440','noteBkgColor':'#c4873b','noteTextColor':'#132440','noteBorderColor':'#132440','labelBoxBkgColor':'#a8dede','labelBoxBorderColor':'#132440','labelTextColor':'#132440','loopTextColor':'#132440','altBackground':'#f8f9fa','fontFamily':'DM Sans, sans-serif'}}}%%
sequenceDiagram
    participant W as Worker
    participant DO as Sandbox Durable Object
    participant VM as Container microVM
    participant API as Allowed API
    W->>DO: getByName(sandboxId)
    W->>DO: start image with enableInternet false
    DO->>VM: boot instance
    W->>DO: exec npm test
    DO->>VM: run command
    Note over DO,VM: every process shares root and the same files
    VM->>DO: HTTPS request to api.example
    DO->>W: interceptOutboundHttps handler
    W->>API: fetch with Authorization added
    API-->>W: 200 response
    W-->>VM: response body
    alt tests pass
        VM-->>W: exit 0
        W->>DO: snapshotContainer
    else instance stops first
        Note over DO,VM: no request within the inactivity window
        VM-->>VM: SIGTERM, then stop
        Note over W: uncommitted work is lost
    end
    W->>DO: destroy

Lifetime is the part teams underestimate. The Durable Object keeps its storage until your code deletes it, but the instance is a separate thing. It stays alive while the Durable Object is active, and afterwards for the inactivity timeout you set, up to six hours. Code running inside the instance does not count as activity, so a two-hour build with no incoming request dies when the timeout expires even though it is working hard.

Stopping is abrupt. Cloudflare sends SIGTERM when the timeout ends and then stops the instance shortly after, whether or not processes exit, so a handler is not a completion guarantee.

A deploy does not replace a running instance. destroy() is immediate, but start() throws while one is running, and the old image keeps serving until you stop it.

Artifacts Versions File Trees Through Git Interfaces

The extraction produced invoice.json, a screenshot, and a corrected CSV. The microVM that made them will stop, and its disk goes with it. What survives is what you file in the records office.

Artifacts is versioned storage that speaks Git. A repository is an isolated Git service with its own history, refs, remote URL, and tokens, living inside a namespace. Namespaces are created implicitly with the first repository. The namespace plus repository name is the stable address; the API also returns an opaque repository ID for logs.

Artifacts exposes each repository through three interfaces, and the split is the key design fact. The Workers binding and the REST API are the control plane: create, list, import, inspect, fork, delete, and mint tokens. The Git smart HTTP endpoint is the data plane: clone, fetch, pull, and push. A typical flow creates a repository, reads back its remote, mints a repository-scoped token, and hands both to a Git client. You do not create separate repositories per interface.

The Git endpoint is a normal smart HTTP remote of the form https://<ACCOUNT_ID>.artifacts.cloudflare.net/git/<namespace>/<repo>.git. Artifacts supports protocol v1 and v2 for clone and fetch, and v1 receive-pack for push; v2 push is not supported, which matters if you pin a Git client to protocol v2 everywhere.

A verifiable sequence proves the data plane, not just the API call. Create or fetch the repository, mint a short-lived token, push from the sandbox, then check the commit from a second client.

// Control plane: create the repository and mint a scoped token
const repo = await env.ARTIFACTS.create(sandboxId);
// For an existing repository: env.ARTIFACTS.get(sandboxId)
const token = await repo.createToken("write", 3600);
# Data plane: push from inside the sandbox
git clone "$REMOTE" work && cd work
git add invoice.json screenshot.png
git commit -m "Capture invoice 1001"
git push

# Verify from outside the sandbox
git ls-remote "$REMOTE"
git log --oneline -1

If the commit is visible from a second client, the data plane worked. If only the sandbox can see it, you committed to a local clone that was never pushed.

Figure 4 shows the assumption that makes this safe: only commits cross the boundary. The sandbox's working tree is not the record, the token is scoped to one repository, and the control plane is where authorization happens.

Artifacts control plane, data plane, and sandbox boundary The Worker control plane creates a repository and mints a repo-scoped token. The Git data plane accepts clone, fetch, and push over smart HTTP. The sandbox holds uncommitted edits on an instance disk. Only committed objects cross into the repository. Control plane Worker or REST API Create or fork repository Mint read or write token Authorize the session Delete repository Holds the only long-lived Cloudflare API credential Git data plane Smart HTTP remote clone and fetch, protocol v1 or v2 push, protocol v1 only repo-scoped token history, refs, commits Sandbox working tree Clone on instance disk Uncommitted edits Generated output files Ends when instance stops Not a record and not a backup of the disk create clone push Assumption: only committed objects cross. A container snapshot is not a commit and expires after 30 days.

Lifecycle rules follow from that picture. Repositories remain stored until you explicitly delete them; there is no automatic expiry. Storage is billed per gigabyte-month across all repositories, and replicas do not add storage charges. The current limits page caps a repository at 1 GB for repositories created on or after 2026-09-29, with 10 GB for older repositories, and caps a single push at 64 MiB, a single file at 32 MiB, and a push at 50,000 objects. Those numbers shape design: do not put a video asset in an agent repository and expect a single push to carry it.

Credentials, Network Access, Persistence, and Cleanup

The three products form a clean separation of planes. The Worker is the control plane: it authenticates the caller, chooses policy, and holds long-lived secrets. The browser session or sandbox is the execution plane: it receives authority for one task and should receive no credential that outlives the task. Artifacts and R2 are the record plane: they hold what must survive, with their own access rules.

Never place a long-lived token inside the execution plane. In the browser, use outboundByHost so the Worker adds the header after the request leaves. In a container, keep enableInternet false and use an outbound handler.

Add credentials only to HTTPS requests. A handler that appends a token to a plain HTTP request sends it across the Internet unencrypted. For Artifacts, mint a repository-scoped token per session with the shortest workable lifetime. The token format itself, art_v1_<40 hex>?expires=<unix_seconds>, carries an expiry, so you can check it rather than assume it.

A token in the URL is a token in the snapshot

An agent clones a private repository with a token embedded in the clone URL. Git writes that URL into .git/config, a test dependency reads it, and the token is posted to an attacker. Turning off Internet access blocks the post, but the token still sits in the snapshot; restore that snapshot twenty days later and the credential comes back with the files.

Scope decides the blast radius. A long-lived write token lets an attacker who already received it rewrite history. A 15-minute read token scoped to one repository limits the damage to a single repository and a single quarter hour.

Figure 5 contrasts the two designs as a failure path. The left side is the convenient version, the middle is the incident, and the right side is the containment design.

Credential leak path and containment design On the left, a token is placed in a clone URL and Internet access is enabled. In the middle, a test dependency reads the token from git config and sends it to an attacker. On the right, the Worker holds the credential, the sandbox has no Internet access, and a short-lived repository token limits the damage. Convenient design Token in clone URL Internet access enabled Write token valid for a day One sandbox for all users No snapshot hygiene Incident Dependency reads .git/config Token posted to attacker host Token still valid after the job Snapshot restores the token No record of what was read Contained design Worker holds the credential Internet off, allowlist only Repo token valid for 15 minutes One sandbox and repo per user Credentials never snapshotted leak contain Cleanup is part of the security model, not an afterthought. Close the session, destroy the instance, delete the snapshot and repo, and let the token expire.

Cleanup needs an explicit owner and a time constant for every layer:

  • Browser sessions. Call browser.close() for a dedicated session, or closeSession(sessionId) for a pooled one, in a finally block. An unclosed session bills until it idles out; the most common cause of higher-than-expected usage is a missing close on the error path. Idle default is 60 seconds, keep_alive can raise it to 20 minutes, and release rollouts also close sessions.
  • Sandbox instances. Call destroy() when the task is over. Otherwise the instance runs until the inactivity timeout, up to six hours, and you pay for memory and disk whether or not the code is doing anything. Do not treat SIGTERM as a chance to finish work; save the files you need before the instance stops.
  • Snapshots. Delete the snapshot reference when the workspace is finished. Snapshots expire 30 days after creation or the most recent restore, and restoring refreshes that clock. They do not include mounted directories.
  • Artifacts. Delete repositories explicitly when a session ends, or the storage remains on the bill indefinitely. Let tokens expire; never rely on a client forgetting one.
  • R2 mounts. Mounted bucket objects outlive every instance and are visible to any Worker with access. Apply bucket lifecycle rules if the artifacts are temporary.

Design around documented failure behavior rather than discovering it in production. A bad guardrail policy fails the session request with a 400. start() throws while an instance is already running, so a deploy does not change the image of a live sandbox.

Timeouts need re-arming after a restart. A restarted Durable Object loses the inactivity timeout it was given, so set it again in the constructor when the instance is already running. monitor() reports a stop only while the Durable Object is in memory, for up to 15 minutes, and a repository push above 64 MiB is rejected rather than split.

Design a Reproducible Document-Capture or Coding Workspace

The exercise below is design-only: it was not executed for this article, no Cloudflare resources were created, and no hosted validation was performed. It is written so that a reader with the required plan can run it and record their own results, and so that a reader without the plan can rehearse the Git and filesystem mechanics locally and label that rehearsal as simulated.

Guided exercise

Design a Reproducible Document-Capture or Coding Workspace

Status: design-only. No measured results are reported; every observation below is an expectation to verify.

Prerequisites and plan requirements. A Cloudflare account on the Workers Paid plan, because Artifacts and container sandboxes are documented as Paid-plan products at the time of writing. Browser Run enabled on the account. Node.js and Wrangler installed, and Docker running locally if you build a container image. A controlled fixture origin you own, serving one HTML invoice page whose total is rendered by JavaScript and one small PDF. Do not point the exercise at a third-party site.

Inputs.

  • Fixture page: https://fixture.example/invoice/1001
  • Session ID: cap-1001
  • Expected record: { "invoice_id": "1001", "total": "128.40", "currency": "USD" }

Keep the fixture deterministic: fixed totals, no dates that change per run.

Minimal setup. One Worker with the bindings below. The upstream credential is stored with wrangler secret put UPSTREAM_TOKEN so it lives in the Worker, not in the sandbox.

BindingNamePurpose
BrowserBROWSERLaunches the guarded session
Artifactslab namespaceCreates the repository and tokens
Containerdurable_object policyRuns the Linux steps
Serviceoutbound WorkerAdds the upstream credential
  1. Deploy the fixture origin and confirm it returns the same total in a normal browser with JavaScript enabled.
  2. Create the Worker and add the bindings. Deploy once to confirm the Worker starts.
  3. Start a guarded session with allowedDomains: ["fixture.example"], keep_alive: 120000, and outboundByHost mapping fixture.example to the outbound Worker.
  4. Navigate, wait for the total element, and capture a screenshot plus page.content(). Write the extracted record as invoice.json.
  5. Create the Artifacts repository with env.ARTIFACTS.create("cap-1001"), mint a write token with a 900-second lifetime, and pass an authenticated remote into the container.
  6. In the container, git clone, copy invoice.json and the screenshot into the working tree, git add, git commit, and git push.
  7. Verify from a second client with git ls-remote and git log --oneline -1. Record the commit hash.
  8. Run the job a second time with session ID cap-1002 and confirm it creates a separate repository rather than writing into the first.
  9. Close the session in a finally block and call destroy() on the container.

Expected observations. The session appears in listSessions() while it runs and disappears after close. The screenshot is a non-empty PNG. The repository has exactly one commit on the default branch, and a second client sees the same commit hash. The second run produces a second repository with no shared history. If any of these is false, stop and treat it as a failure rather than adjusting the assertion.

Failure checks. Remove fixture.example from the allowlist and confirm navigation is refused rather than silently rendering a partial page. Set enableInternet: true with no handler and try to install a package from an unlisted host; confirm it succeeds, which demonstrates why the default is off. Expire the repository token before pushing and confirm the push is rejected with an authentication error. Stop the container mid-run and confirm no commit exists, which demonstrates that the working tree was never the record.

Cost dimensions. Browser hours are billed beyond the included monthly allowance, and concurrent browsers are billed separately; at the pricing page's writing-time figures, additional browser time is 0.09 USD per hour and additional concurrency is 2.00 USD per browser after the included count. Containers bill provisioned memory and disk plus active CPU; a lite instance is 1/16 vCPU, 256 MiB of memory, and 2 GB of disk, which is enough for this exercise. Artifacts bills operations and GB-months, with billing for Artifacts operations and storage scheduled to begin on 2026-11-12 according to the pricing page. Egress from Containers has a separate included allotment. Re-check all of these before running; they are dated observations, not constants.

Cleanup. Close the browser session, destroy the container, delete any snapshot, delete both repositories, delete the Worker and the fixture origin, revoke the upstream token, and remove any R2 objects or mounts created for the exercise. Confirm in the dashboard that no session, instance, or repository remains.

Fixture-only rehearsal. Without a Paid plan, run steps 5 through 7 against a local bare Git repository and a local Playwright script, using a read-write token stand-in. Label the result simulated: it validates the Git and filesystem mechanics, not Cloudflare isolation, guardrails, or billing.

Check Workspace Isolation and Capture Reproducible Output Metadata

Use the following pass/fail checks before trusting a workspace design. Each one should produce evidence you can attach to a change record, not just a green checkmark.

  • Pass — browser boundary. The Worker holds every long-lived credential, the session has an explicit guardrail allowlist, and browser.close() or closeSession() appears in a finally block. Fail if any token is injected into page JavaScript or passed in a URL the page can read.
  • Pass — sandbox boundary. One sandbox per user or job, enableInternet false unless justified, and an outbound handler that restricts method, host, and body. Fail if two users share a sandbox name, or if the sandbox holds a token that outlives the task.
  • Pass — record boundary. The repository is created per session, the token is repo-scoped and short-lived, and the commit hash is recorded outside the sandbox. Fail if success is inferred from a file existing on the instance disk.
  • Pass — lifecycle. The inactivity timeout is set in the constructor as well as after start(), snapshots have an owner and a deletion date, and repositories are deleted at end of session. Fail if cleanup depends on SIGTERM or on a client remembering to disconnect.
  • Pass — metadata. Record the product names and versions you used, the date, the session ID, the commit hash, the guardrail policy, and the instance type. Without those, a rerun cannot distinguish a product change from a code change.

A short self-check, with explained answers:

  1. A page needs a login and JavaScript, and the job also needs pdftotext. One session or two? Two boundaries. Browser Run produces the rendered page or PDF; a container sandbox runs the binary. Trying to install pdftotext in a browser session is a category error, because a browser session has no shell or package manager.
  2. Why is enableInternet: false not sufficient on its own? It blocks direct egress, but anything the code can read inside the sandbox is still readable, and an outbound handler that forwards arbitrary requests recreates the path. The handler must restrict destination, method, and body, and credentials should be added there rather than stored inside.
  3. Why not use one Artifacts repository for every agent? Repository scope is the access and lifecycle boundary. A shared repository turns independent work into conflicts, makes a leaked write token affect every session, and makes deletion of one session's data impossible without touching the others.
  4. What survives a container stop? Mounted R2 objects, committed Artifacts content, and snapshots. Processes, memory, the writable disk, and files in /run do not. A snapshot restores files but not running processes.

Unresolved limitations and documentation caveats. Tested versions: none, because no lab was executed for this article; every operational claim is a documentation claim, not a measurement. Documentation was verified on 2026-11-05. The docs are internally inconsistent in two places worth checking at authoring time: the Puppeteer page updated 2026-10-30 names @cloudflare/puppeteer v1.1.0 as current, while the Guardrails page updated 2026-09-26 requires 1.4.0 or later, so verify the installed version with npm ls @cloudflare/puppeteer rather than trusting either line. The Browser Run limits page updated 2026-10-14 lists 200 concurrent browsers per account for Workers Paid, while the pricing page updated 2026-04-21 lists 10 included concurrent browsers and 2.00 USD per additional browser; these may be a ceiling and an allowance rather than the same quantity, but that reading is inference, not documented. Artifacts billing is scheduled to begin 2026-11-12, after this article's verification date, so its pricing is forward-looking. Product names, plan availability, limits, and prices should be re-checked before any lab, and all figures here are dated 2026-11-05.

Authoritative references, verified on 2026-11-05:

  • Browser Run overview, limits, and pricing: https://developers.cloudflare.com/browser-run/ , https://developers.cloudflare.com/browser-run/limits/ , https://developers.cloudflare.com/browser-run/pricing/
  • Browser sessions, reuse, guardrails, and outbound Workers: https://developers.cloudflare.com/browser-run/puppeteer/ , https://developers.cloudflare.com/browser-run/features/reuse-sessions/ , https://developers.cloudflare.com/browser-run/features/guardrails/ , https://developers.cloudflare.com/browser-run/features/outbound-workers/
  • Sandboxes overview, lifetime, security, network, and files: https://developers.cloudflare.com/sandbox/ , https://developers.cloudflare.com/sandbox/concepts/lifetime/ , https://developers.cloudflare.com/sandbox/concepts/security/ , https://developers.cloudflare.com/sandbox/network/ , https://developers.cloudflare.com/sandbox/files/
  • Containers pricing and limits: https://developers.cloudflare.com/containers/platform/pricing/ , https://developers.cloudflare.com/containers/platform/limits/
  • Artifacts overview, limits, pricing, authentication, and Git protocol: https://developers.cloudflare.com/artifacts/ , https://developers.cloudflare.com/artifacts/platform/limits/ , https://developers.cloudflare.com/artifacts/platform/pricing/ , https://developers.cloudflare.com/artifacts/guides/authentication/ , https://developers.cloudflare.com/artifacts/api/git-protocol/
  • Artifacts repository patterns and the Sandbox SDK integration example: https://developers.cloudflare.com/artifacts/concepts/best-practices/ , https://developers.cloudflare.com/artifacts/examples/sandbox-sdk-artifacts/