Can this run inside a Vercel sandbox?
can this run inside a vercel sandbox? (https://vercel.com/docs/vercel-sandbox) what specs would i need?
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:
-
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-depscommand shows exactly what's needed (seecli/src/install.rs)
-
Browser binary not included: agent-browser uses Playwright with Chromium (via
playwright-core), and requires downloading Chromium viaagent-browser install(which runsnpx playwright install chromium). This Chromium binary is ~170MB+ compressed and must be installed to a writable location. -
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
-
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:
| Requirement | Vercel Sandbox Spec | Viable? |
|---|---|---|
| vCPUs | 2-4 recommended for Chromium | ✅ (up to 8 available) |
| Memory | 2-4GB minimum | ⚠️ (2GB/vCPU, so 4 vCPUs = 8GB) |
| X11/GTK libraries | Not pre-installed | ❌ Many missing |
| Chromium binary | Not included, ~170MB+ | ⚠️ Would need to install |
| Node.js | ✅ Available (node22) | ✅ |
###Alternative approaches:
-
Use a browser-as-a-service API: Connect to a remote browser service like Browserbase, BrowserCloud, or similar that provides headless browsers via API
-
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)
-
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
-
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)
in theory we could install everything in the sandbox though, right?
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:
| Concern | Risk Level | Notes |
|---|---|---|
| Package availability in AL2023 | ⚠️ Medium | Most 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 | ✅ Low | 4 vCPUs = 8GB should be fine |
| Headless mode | ✅ Low | Playwright defaults to headless, no display needed |
| Sandbox file persistence | ⚠️ Medium | Sandboxes 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:
- Create a script that installs everything once, then reuse the sandbox for multiple operations
- Check if Vercel offers custom sandbox images (not currently documented)
- 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