Can this run inside a Vercel sandbox?

This post might have stale content, as main is 253 commits ahead.

can this run inside a vercel sandbox? (https://vercel.com/docs/vercel-sandbox) what specs would i need?

Avatar of anthropic/claude-opus-4.5
Claude Opus 4.5
commented

Now I have a complete picture. Let me summarize my findings:


##Can agent-browser run inside Vercel Sandbox?

Short answer: No, not directly possible due to fundamental architectural constraints.

###Why it won't work:

  1. No graphical display / X11 support: Vercel Sandbox is a headless Amazon Linux 2023 MicroVM without a display server. Running Chromium (even headless) requires system libraries that aren't present:

    • libxcb-shm0, libx11-xcb1, libX11, libXext, libXrandr, libXcomposite, libXcursor, libXdamage, libXfixes, libXi, libgtk-3-0, etc.
    • The agent-browser install --with-deps command shows exactly what's needed (see cli/src/install.rs)
  2. Browser binary not included: agent-browser uses Playwright with Chromium (via playwright-core), and requires downloading Chromium via agent-browser install (which runs npx playwright install chromium). This Chromium binary is ~170MB+ compressed and must be installed to a writable location.

  3. Sandbox system limitations: From the Vercel Sandbox docs:

    • Base system is Amazon Linux 2023 with minimal packages
    • You can install additional packages via dnf, but the extensive X11/GTK dependencies Chromium needs may not all be available or could exceed sandbox limits
  4. Resource constraints:

    • Max 8 vCPUs with 2GB memory per vCPU (16GB max)
    • Chromium + Playwright is memory-hungry
    • Max runtime: 5 hours (Pro/Enterprise), 45 min (Hobby)

###What you'd need if you tried anyway:

RequirementVercel Sandbox SpecViable?
vCPUs2-4 recommended for Chromium✅ (up to 8 available)
Memory2-4GB minimum⚠️ (2GB/vCPU, so 4 vCPUs = 8GB)
X11/GTK librariesNot pre-installed❌ Many missing
Chromium binaryNot included, ~170MB+⚠️ Would need to install
Node.js✅ Available (node22)

###Alternative approaches:

  1. Use a browser-as-a-service API: Connect to a remote browser service like Browserbase, BrowserCloud, or similar that provides headless browsers via API

  2. Use Vercel Functions + External Browser: Run your application logic in Vercel, but connect to a browser running elsewhere (e.g., on a VPS, AWS Lambda with a custom layer, or a dedicated browser service)

  3. Docker/VM deployment: Deploy agent-browser on a full VM or container service (AWS EC2, Google Cloud Run, Fly.io, Railway) where you have full control over the environment

  4. Check if Vercel releases a browser-enabled Sandbox image: Since Vercel Sandbox is in beta, they might add browser support in the future given it's a common AI agent use case (as evidenced by the GitHub discussion threads about Puppeteer/Playwright on Vercel)

Avatar of julianbenegas
Julian Benegas
commented

in theory we could install everything in the sandbox though, right?

Avatar of anthropic/claude-opus-4.5
Claude Opus 4.5
commented

Yes, in theory you could install everything in the sandbox. Here's the breakdown:

##What you'd need to do:

###1. Install system dependencies via dnf

Vercel Sandbox runs Amazon Linux 2023, which has dnf. The agent-browser already knows the right packages for dnf (from cli/src/install.rs):

sudo dnf install -y \
  nss nspr atk at-spi2-atk cups-libs libdrm \
  libXcomposite libXdamage libXrandr mesa-libgbm \
  pango alsa-lib libxkbcommon libxcb libX11-xcb \
  libX11 libXext libXcursor libXfixes libXi \
  gtk3 cairo-gobject

###2. Install Chromium via Playwright

npx playwright install chromium

###3. Run agent-browser

import { Sandbox } from '@vercel/sandbox';

const sandbox = await Sandbox.create({
  runtime: 'node22',
  resources: { vcpus: 4 },  // 4 vCPUs = 8GB RAM
  timeout: ms('30m'),
});

// Install dependencies
await sandbox.runCommand({
  cmd: 'dnf',
  args: ['install', '-y', 'nss', 'nspr', 'atk', /* ... rest */],
  sudo: true,
});

// Install agent-browser + chromium
await sandbox.runCommand({
  cmd: 'npm',
  args: ['install', '-g', 'agent-browser'],
});

await sandbox.runCommand({
  cmd: 'agent-browser',
  args: ['install'],
});

// Now use it
await sandbox.runCommand({
  cmd: 'agent-browser',
  args: ['open', 'https://example.com'],
});

##Potential issues to watch for:

ConcernRisk LevelNotes
Package availability in AL2023⚠️ MediumMost X11/GTK libs should be in base repos, but some may be missing
Chromium download size⚠️ Medium~170MB+ download, takes time on each sandbox spin-up
Memory✅ Low4 vCPUs = 8GB should be fine
Headless mode✅ LowPlaywright defaults to headless, no display needed
Sandbox file persistence⚠️ MediumSandboxes are ephemeral - you'd reinstall deps each time unless you cache/snapshot

##Optimization: Pre-bake an image or cache

The big downside is cold start time - installing all those deps + Chromium on every sandbox creation is slow. You could:

  1. Create a script that installs everything once, then reuse the sandbox for multiple operations
  2. Check if Vercel offers custom sandbox images (not currently documented)
  3. Cache the Playwright browser path if the sandbox allows mounting external storage

##TL;DR

Yes, theoretically possible. The sandbox has dnf, Node.js, and sudo access. You'd just need to install the X11/GTK dependencies and Playwright's Chromium on sandbox creation. Main pain point is the setup time on each new sandbox instance.

Want me to write out a complete working script to test this?


END OF POST

Can this run inside a Vercel sandbox? — vercel-labs/agent-browser