Skip to content

Bound sandbox resources and lifetime to cut provisioned-memory cost - #44

Merged
paulieb89 merged 1 commit into
mainfrom
perf/sandbox-resource-timeout-caps
Jul 16, 2026
Merged

Bound sandbox resources and lifetime to cut provisioned-memory cost#44
paulieb89 merged 1 commit into
mainfrom
perf/sandbox-resource-timeout-caps

Conversation

@paulieb89

Copy link
Copy Markdown
Contributor

Problem

evolve was the 2nd-heaviest project on Sandbox Provisioned Memory (95.6 GB-Hrs/cycle, 25.3%) — high for an agent doing small file-edit tasks. Root cause (confirmed against the Vercel Sandbox SDK docs): eve's sandbox timeout is a wall-clock ceiling (default 30 min), not idle. eve never calls extendTimeout, so a VM bills provisioned memory for the whole 30-min window regardless of activity — a 2-min task still holds its sandbox ~30 min. eve also sets no resources, so each sandbox takes the platform default (≥2048 MB/vCPU).

Fix

In agent/sandbox.ts, pin vcpus: 1 (2048 MB) and timeout: 15 min, guarded to hosted Vercel only (process.env.VERCEL) so local eve dev keeps eve's default docker/bash backend and never provisions a real hosted sandbox. Both values are env-tunable (EVOLVE_SANDBOX_VCPUS, EVOLVE_SANDBOX_TIMEOUT_MS) — limits can change without a code edit.

Safety

  • Multi-turn sessions survive a stopped/timed-out VM via persistent: true + resume (filesystem restored on next command).
  • Only exposure: a single sandbox command longer than 15 min — evolve's commands run well under a minute; 15 min also keeps headroom for start_background jobs.
  • Existing revalidationKey + git config safe.directory bootstrap (issue [agent] Sandbox repository checkout fails: dubious ownership in /workspace #3) untouched.

Test

  • npm run typecheck clean
  • npm run build succeeds (local build takes the default-backend branch)
  • Runtime validation post-merge: dispatch a build-heavy + start_background task, confirm completion + no OOM at 2 GB, and confirm sandbox.vcpus/memory = 1 / 2048.

Permissions untouched — agent capabilities unchanged.

eve defaults the Vercel sandbox to a 30-minute wall-clock timeout and no
resource cap. The timeout is not idle-based (confirmed against the Vercel
Sandbox SDK docs): a VM bills provisioned memory for the full window
regardless of activity, so a 2-minute task still holds its sandbox for
~30 minutes. evolve was the 2nd-heaviest project on Sandbox Provisioned
Memory (95.6 GB-Hrs/cycle).

Pin vcpus: 1 (2048 MB) and timeout: 15 min, guarded to hosted Vercel only
so local `eve dev` keeps the default docker/bash backend. Both are
env-tunable (EVOLVE_SANDBOX_VCPUS / EVOLVE_SANDBOX_TIMEOUT_MS). Sessions
survive a stopped VM via persistent + resume; the only exposure is a
single sandbox command longer than the timeout, and evolve's commands run
well under a minute (15 min also leaves headroom for start_background).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@vercel

vercel Bot commented Jul 16, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
evolve Ready Ready Preview, Comment Jul 16, 2026 4:01pm

Request Review

@paulieb89
paulieb89 merged commit db72ddb into main Jul 16, 2026
3 checks passed

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 10a8cf2f9c

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread agent/sandbox.ts
Comment on lines +22 to +24
backend: vercel({
timeout: SANDBOX_TIMEOUT_MS,
resources: { vcpus: SANDBOX_VCPUS },

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reapply sandbox caps on resumed sessions

For conversations whose persistent Vercel sandbox already exists before this deploy, these vercel() create options are never applied: Eve's Vercel backend forwards them only to fresh Sandbox.create, while the resume path uses Sandbox.get and only updates tags. Those ongoing sessions therefore keep the old 30-minute/default-resource settings, and later env-only limit changes have the same problem, so the cost cap won't cover resumed production work unless the caps are also applied via onSession({ use })/sandbox.update or the old sessions are forced to recreate.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant