Skip to main content
Sandbox environments let you run code in isolated, temporary containers. Use Git as your source of truth instead of provider-specific storage, such as volumes. Git gives you version history, branches, and portability across sandbox providers. Generate an authenticated Git URL with the Code Storage SDK. Use the URL to clone the repository in your sandbox. Use this guide to connect a sandbox provider. To isolate agent writes and keep durable state, see Store Session State.
Note: Use a shallow, single-branch clone to reduce the clone time. This clone omits the commit history and other branches:

Quick start

Generate an authenticated Git URL and use it inside any sandbox:

Confine a sandbox to one session branch

Give the agent two short-lived URLs. Use a read-only normal URL for fetches. Use an ephemeral URL for pushes. Use refPolicies to confine it to one branch.
Set the normal URL as the fetch URL and the ephemeral URL as the push URL before the agent starts. Pass the base commit SHA as BASE_SHA. Pass sessionBranch as SESSION_BRANCH.
The sandbox keeps one origin with separate URLs for fetches and pushes. A stray git push origin main goes to the ephemeral namespace. The sandbox has no credential that can write to a normal branch. The policy permits fast-forward pushes to this session branch only. It rejects all other pushes. See Store Session State for the branch layout, and Ref Policies for the refPolicies rules. Modal provides serverless cloud functions with persistent volumes. Clone repositories into volumes, run code, and push changes back.

E2B

E2B provides cloud sandboxes for AI agents. Clone repositories, execute code, and push results back to Code Storage.

Daytona

Daytona provides secure sandboxes for AI agents. Use Daytona’s built-in Git API to clone repositories. Run commands and push changes back.

Provider resilience

Many teams use multiple sandbox providers to improve resilience. Git keeps your code portable across providers. If one provider has an outage or no capacity, start a sandbox elsewhere. Then clone the same repository:
Your code stays safe in Code Storage regardless of which sandbox runs it.

Security considerations

  • Short TTLs: Use the shortest TTL practical for your use case. Sandbox sessions are typically short-lived.
  • Minimal permissions: Grant git:read only unless the sandbox needs to push changes.
  • Agent state: Store experimental or untrusted work on ephemeral branches. See Store Session State.
  • Audit commits: Review sandbox changes before you merge them into protected branches.