Skip to content

feat(sandbox): make snapshot sandbox vcpus/memory configurable via env var #715

Closed

Description

@dcramer

Problem

The snapshot build sandbox is created in packages/junior/src/chat/sandbox/runtime-dependency-snapshots.ts → createDependencySnapshot() without specifying vcpus:

await Sandbox.create({
  timeout: timeoutMs,
  runtime,
  ...(sandboxCredentials ?? {}),
  // no vcpus — falls back to Vercel's default
})

Some plugin dependency sets (e.g. heavy system packages, browser runtimes) may need more memory to build successfully. Vercel Sandbox allocates 2048 MB per vCPU, so 8 GB requires vcpus: 4 and 16 GB requires vcpus: 8.

Proposed fix

Add a SANDBOX_SNAPSHOT_VCPUS env var (following the existing pattern of SANDBOX_SNAPSHOT_FLOATING_MAX_AGE_MS and SANDBOX_SNAPSHOT_REBUILD_EPOCH in the same file):

function getSnapshotVcpus(): number | undefined {
  const raw = process.env.SANDBOX_SNAPSHOT_VCPUS;
  if (!raw?.trim()) return undefined;
  const parsed = Number.parseInt(raw, 10);
  return Number.isFinite(parsed) && parsed > 0 ? parsed : undefined;
}

Then pass it to Sandbox.create():

await Sandbox.create({
  timeout: timeoutMs,
  runtime,
  ...(sandboxCredentials ?? {}),
  ...(getSnapshotVcpus() !== undefined ? { vcpus: getSnapshotVcpus() } : {}),
})

This lets operators tune snapshot memory per-deploy via Vercel env vars without code changes.

Scope

  • Add getSnapshotVcpus() helper + wire into createDependencySnapshot()
  • Document SANDBOX_SNAPSHOT_VCPUS in the env var reference / docs
  • Confirm Vercel plan tier supports the requested vCPU count at call time (note: higher counts may require plan-tier access)

--

View Junior Session in Sentry

Activity

  1. added
    enhancement
    on Jul 1, 2026
  2. added 3 commits that reference this issue on Jul 10, 2026
    fcaf860
    3a515ad
    6f059e1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancement

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions