Vercel - Sandbox - Python - AI coding agents
4 min lectura

Vercel Sandbox Python 1.0: test agent-written PRs in isolation

Vercel Sandbox Python 1.0 stabilizes an isolated test workflow for agent-written PRs. A pytest example, setup, access, costs and limits.

Vercel Sandbox Python 1.0: test agent-written PRs in isolation

Your coding agent opens a Python pull request. Before running its tests on your laptop or a server that holds live credentials, you want to execute the branch in a disposable environment. On November 16, 2026, Vercel released version 1.0 of its Python SDK for Sandbox. It stabilizes the API for creating an isolated environment, running commands and cleaning up with a context manager.

Vercel's announcement says Python now has feature parity with the TypeScript SDK, supports synchronous and AnyIO-based asynchronous use, and changes command input and output to bytes compared with 0.x. That matters if your coding agent or CI tool is already written in Python. I did not run a real Vercel Sandbox because no Vercel project is linked here; the example below follows Vercel's published code, not an account-level test.

When isolation earns its cost

Sandbox is useful when an agent's output, a pull-request branch or a user upload may execute code. Vercel describes an isolated microVM with its own filesystem. That reduces the chance that an untrusted test mutates your laptop or accidentally depends on local packages. The environment can still have its own network and permissions: never send production secrets into it and do not treat isolation as permission to run arbitrary code without review.

If you only run known tests on a trusted repository, your current CI may already do the job. A fresh sandbox is easier to justify when inputs vary or come from less trusted sources and each run needs its own disposable environment.

Small test: run a PR branch

Install the 1.x package in a Python project and configure authentication. Vercel recommends OIDC: for local development, use vercel link and vercel env pull. On Vercel deployments, authentication is automatic; external CI can use documented access tokens. Keep local environment files out of Git.

uv add 'vercel-sandbox>=1.0'
vercel link
vercel env pull

Save the following as check_pr.py and replace the repository URL and branch with ones you control. async with cleans up the sandbox when the block exits, including after a test failure. check=True makes a failing test visible to your review process instead of silently carrying on.

import asyncio
from vercel import sandbox
from vercel.sandbox import GitSource

async def main():
    async with sandbox.create_sandbox(
        source=GitSource(
            url="https://github.com/your-team/your-repo.git",
            revision="your-pr-branch",
        )
    ) as box:
        await box.run_command("uv", ["run", "pytest", "-q"], check=True)

asyncio.run(main())

Run uv run check_pr.py. Expect the process to finish cleanly when tests pass and to raise an error when they fail. This assumes the repo has pytest configured and the sandbox runtime can install its dependencies. For a private repo, choose the documented Git authentication method first; do not hardcode a Git token or paste it into the agent prompt.

Four checks before automating every PR

  1. Use one known passing branch and one failing branch. Confirm that your agent receives the correct result and the sandbox closes.
  2. Verify that you are not copying .env files, repository secrets or customer data into the sandbox. Filesystem isolation cannot protect a secret you explicitly provide.
  3. Set time and run-frequency limits. A sandbox per editor keystroke is rarely useful; one queued check per PR with stale runs cancelled is easier to control.
  4. If you are upgrading from 0.x, review the breaking changes. Vercel specifically warns that command input and output switched to bytes, which can break code expecting strings.

Access and cost

Vercel's current pricing page lists 5 hours of active CPU, 420 GB-hours of provisioned memory and 5,000 creations per month as included amounts for the displayed Sandbox tier, with concurrency limits and further usage charges. Active CPU hours are not the same as wall-clock hours; provisioned memory can accrue while a sandbox exists. Check your team's plan and budget before allowing an agent to launch many runs. I have not measured a real account's bill.

This week's decision is to run one simple PR branch in Sandbox and record time, memory and outcome before migrating a whole workflow. If your existing CI already isolates code and controls spend, compare both paths using the same PR.

Comentarios

Aún no hay comentarios. Sé el primero.

Deja un comentario