Skip to content

Run shell commands in Vercel Sandboxes - #2301

Draft
fazxes wants to merge 2 commits into
fazxes/sandbox-provider-clifrom
fazxes/add-shell-runners
Draft

fazxes wants to merge 2 commits into
fazxes/sandbox-provider-clifrom
fazxes/add-shell-runners

Conversation

@fazxes

@fazxes fazxes commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • With experimental.sandbox_execution on, the shell tool takes a runner option, and rules in ~/.fx/sandbox/config.json can place commands in a Vercel Sandbox or in a throwaway isolated one.
  • The first remote command asks for the Vercel team and project in the same chat and saves the choice.
  • A built-in runner talks to the Vercel API directly, so remote runs no longer need the Vercel CLI or the vercel.sh script.
  • Remote runs upload tracked and unignored files plus include paths, stream output, and bring changed files back, keeping the local copy when both sides changed it.
  • Isolated runs use a new sandbox with no network by default, save their outputs in fx's state folder, and delete the sandbox when they end.
  • A stopped or expired sandbox session is resumed once, and a command that may have started is never sent twice.
  • Session approvals name where a command runs and which Vercel project it uses, so approving a local command never approves the remote one.
  • A third-party runner can replace the built-in one through provider in the config.
  • fx no longer sweeps old sandboxes at startup.

Notes for review

  • Removed assertions: the placement-identity tests from Run placed shell commands through a sandbox provider CLI #2153 now expect the destination in the identity (the Vercel project, setup, or provider). The tests of the old fake sandbox CLI moved to the fake Vercel API in runner.test.ts and sandbox-provider.test.ts, with a matching check for each old claim.
  • Sleeps: the runner's watch loop checks the stop flag and the time-extension clock every 10 ms, and a failed reattach waits 1 s before it tries again. The test sleeps pace the fake API's fault input or bound a wait on state.
  • Concurrency: the runner adds a watch thread beside each stream. A ThreadSanitizer run of every test under src/core/runner reports nothing there. The leak and races it reports elsewhere are also in the latest TSan run on main.
  • Fuzzing: each new decoder of Vercel data has a vercel_* target with saved inputs. Ten ran for 60 seconds each without a failure, and the rest run in the nightly job.
  • Models: the startup sweep is gone, so mutation-no-sweep is replaced by mutation-skip-cleanup, which checks IsolatedCleanedUp with the cleanup that now runs before an isolated create.

Docs: vercel-labs/fx-web#368

Stacked on #2153.

- With experimental.sandbox_execution on, the shell tool takes a runner option, and rules in ~/.fx/sandbox/config.json can place commands in a Vercel Sandbox or in a throwaway isolated one.
- The first remote command asks for the Vercel team and project in the same chat and saves the choice.
- A built-in runner talks to the Vercel API directly, so remote runs no longer need the Vercel CLI or the vercel.sh script.
- Remote runs upload tracked and unignored files plus include paths, stream output, and bring changed files back, keeping the local copy when both sides changed it.
- Isolated runs use a new sandbox with no network by default, save their outputs in fx's state folder, and delete the sandbox when they end.
- A stopped or expired sandbox session is resumed once, and a command that may have started is never sent twice.
- Session approvals name where a command runs and which Vercel project it uses, so approving a local command never approves the remote one.
- A third-party runner can replace the built-in one through provider in the config.
- fx no longer sweeps old sandboxes at startup.
@fazxes fazxes added the type: feature Adds a new user-facing capability label Nov 25, 2026
@vercel-internal-security-reviewer

Copy link
Copy Markdown

Security review details

- Import each vercel_* fuzz target's file in fuzz_targets.zig, as the fuzz registry test expects.
- Keep the shell tool's description out of libfx's native addons by gating the runner projection on builtin_tools.
- Report a stop during a stalled upload as a stop, not a transport failure.
- Log runner output and sandbox cleanup that fx drops, and say why the remaining ignored errors are safe.
- Read the test server's request count under its lock, so tests do not race the server thread.
- Restore the exact empty env check and IsolatedCleanedUp in the sandbox model's design config.

This branch has not been deployed

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

Labels

type: feature Adds a new user-facing capability

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant