Managed Deep Agents is in beta on LangSmith Cloud and Bring Your Own Cloud (BYOC). Use Managed Deep Agents CLI and SDK v0.10 or later for BYOC.
sandbox/. To provision a snapshot, add sandbox/setup.sh or build from sandbox/Dockerfile. Use only one of these files.
Configure a sandbox
Use a sandbox when the agent needs to write files, run code, or execute shell commands.mda init scaffolds a sandbox declaration. Managed Deep Agents enables the sandbox only while the sandbox/ directory is present.
mda init does not create setup.sh. Add that file yourself if the snapshot should install packages, clone a tree, or otherwise change the image.
Managed Deep Agents uses LangSmith Sandboxes for this backend. Reuse is thread-scoped. Once a thread binds to a sandbox, Managed Deep Agents does not replace it. If that sandbox is deleted or replaced externally, later sandbox operations fail with SandboxMissingError. Start a new thread for a new workspace.
Declare the sandbox with defineSandbox:
sandbox/index.ts
Resolve options for each run
A sandbox resolver selects creation options and a proxy configuration from the current run’s runtime. Use it when runs share a compiled graph but need different sandbox resources.Sandbox
resolve requires managed-deepagents>=0.10.7.resolve on the run’s first sandbox use, including its first model call to determine whether to offer execute. It caches the result for that run, not in the compiled graph. Schema and state inspection do not call the resolver. The sandbox itself opens only when an operation needs it.
This example adds resources when the run context sets large. Otherwise, it keeps the declared options. Declare large in the agent’s context schema.
sandbox/index.ts
null to disable the sandbox for that run. Set defaultTimeout and apiKey on the declaring defineSandbox, not the returned definition. A returned proxyConfig replaces the declared proxy configuration rather than merging its rules.
Other returned options override declared options by key. A returned definition cannot declare another resolve or add user-owned connection references to its proxy. Keep those references on the outer declaration. When the resolver disables the sandbox, the model has no execute tool, and filesystem operations use run state instead.
Creation options do not resize or replace a thread’s existing sandbox. When later runs select different resources, Managed Deep Agents reuses the existing sandbox and logs a warning. Start a new thread to use new creation options. Changing mounts selects a separate sandbox binding.
When a project has sandbox/setup.sh, a returned bake base must match the declared base. Omit the bake base to use the baked recipe snapshot. A different base fails the run instead of skipping the setup script.
Configure the sandbox proxy
The sandbox proxy injects headers into matching outbound requests and controls which destinations the sandbox can reach. The proxy runs outside the sandbox, so sandbox code can call authenticated APIs without handling the credentials. For example, to call the OpenAI API from the sandbox, storeOPENAI_API_KEY in your LangSmith workspace secrets and configure this proxy rule:
sandbox/index.ts
Use connections in proxy headers
Use Connections in sandboxes to authenticate CLI commands and API requests. For example, to call the GitHub API from the sandbox as the current user, create thegithub connection first, then configure the proxy:
sandbox/index.ts
bearer(ref) or basic(username, ref). Omit the header’s type for connection values. Managed Deep Agents sets it to opaque.
Provision a snapshot
Ifsandbox/setup.sh exists, mda deploy and mda dev run the script once and save the resulting environment as a snapshot. Modifications from that run, such as cloned repositories and installed packages, persist in the snapshot. New threads clone that snapshot instead of running setup.sh. The snapshot is reused until setup.sh changes, at which point it is rebuilt.
The script runs with bash -e. A non-zero exit fails the snapshot and the deploy or mda dev session. LangSmith does not update the live deployment to the failed snapshot. Any previously successful snapshot continues to serve.
sandbox/setup.sh
.env values that deploy forwards are available as environment variables when setup.sh runs, for example a token used to clone a private repo. Thread sandboxes that clone the snapshot do not inherit those variables. Do not write secrets onto the filesystem while setup.sh runs; anything on disk is part of every thread’s image.
Editing setup.sh and redeploying does not wipe /workspace on live threads. Those boxes keep the files they already have. A new thread clones the new snapshot.
Build from a Dockerfile
sandbox/Dockerfile builds the snapshot used by new thread sandboxes. Use it instead of setup.sh when you need Docker build steps or files copied into the image.
Sandbox Dockerfile builds and private
FROM images require Managed Deep Agents CLI v0.10.7 or later. Use managed-deepagents>=0.10.7 for the declarations below.sandbox/Dockerfile
mda deploy or mda dev to build the recipe. Managed Deep Agents uploads the sandbox/ build context to a temporary LangSmith builder, builds the image, and captures a snapshot. You do not need a local Docker daemon or a registry to publish the built image.
The Dockerfile is the whole recipe. It cannot coexist with sandbox/setup.sh or an explicit snapshot or Docker image bake base. Put setup commands in RUN instructions and select the base with FROM.
Prepare the build context
COPY and ADD paths are relative to sandbox/, not the project root. Put any required files under that directory.
- Ignore files: Use
sandbox/.dockerignoreto exclude files from the upload and recipe digest. If present,sandbox/Dockerfile.dockerignoretakes precedence. - Environment files: Managed Deep Agents excludes
.envfiles and the selected environment file from the upload. Do not put other secrets in the build context or Dockerfile. - Upload size: The default limit is 200 MiB of context file contents. Set
MDA_SANDBOX_MAX_UPLOAD_MBto change the limit in whole MiB. - Filesystem capacity: If you set
fs_capacity_bytesin Python orfsCapacityBytesin TypeScript, use an integer literal or a top-level constant. This sizes the built snapshot.
Pull a private base image
Aregistry declaration authenticates pulls for private FROM images. Set the base in the Dockerfile, not in the sandbox declaration:
sandbox/Dockerfile
sandbox/index.ts
GHCR_TOKEN in the project .env or process environment. Managed Deep Agents sends the credential to the temporary builder’s Docker configuration, not as a build argument or command-line value. It deletes the builder after the build. The credential is not part of the exported image or forwarded to the running Agent Server. Dockerfile builds do not create a deployment-owned Host registry.
Choose a bake base
With no bake base, LangSmith’s default sandbox template is the starting point. To start from something else, set exactly one of these:sandbox/index.ts
registry. Managed Deep Agents creates or updates a deployment-owned Host registry at bake time. Only the variable name is compiled; the credential value does not enter the build or the snapshot.
Name the password in passwordEnv:
sandbox/index.ts
GHCR_TOKEN in the project .env or the process environment. After bake, Managed Deep Agents does not forward that value to the running Agent Server.
How the agent uses the sandbox
The agent uses built-in filesystem tools such asls, read_file, write_file, edit_file, delete, glob, and grep, and runs shell commands with execute. Use instructions to specify where the agent should work and what it must not modify.
Read and write sandbox files from code
Authored tools and middleware reach the sandbox filesystem throughruntime.backend. Use it when your own code needs a file, rather than prompting the agent to fetch one for you.
runtime.backend requires managed-deepagents>=0.8.0.runtime parameter to receive the typed surface:
tools/report.ts
/workspace/report.txt see their own copy. The backend resolves lazily, and a tool that never touches it never provisions a sandbox.
Available operations
Every method returns a promise.
Arguments and return types come from the Deep Agents backend contract. See Backends.
Transfer binary files
upload_files and download_files move raw bytes, so they suit images, archives, and any other file that text operations would corrupt. Download returns the bytes for each requested path:
tools/checksum.ts
path and error, and a download also carries content. On failure, error is one of file_not_found, permission_denied, is_directory, or invalid_path, and the downloaded content is empty. Check error rather than assuming the transfer succeeded.
Limits
runtime.backend covers the sandbox only. It has no route to Context Hub, so skills, instructions, and memory are not reachable through it.
Without a sandbox, runtime.backend is undefined. Guard on it before every call, because a project can remove sandbox/ after the tool ships.
delete, uploadFiles, and downloadFiles depend on the installed backend and throw when it does not implement them. A root glob returns an error instead of provisioning a sandbox.
Disable the sandbox
Delete thesandbox/ directory to opt out, such as for an agent that only needs its prompt, memory, and tools.
For existing deployments, deleting the deployment with mda delete also deletes the managed sandboxes associated with it, the {deployment}--setup-* recipe snapshots, and the deployment-owned registry when one exists.
Deployment
Managed Deep Agents owns sandbox naming, recipe bake, reuse, recovery, and cleanup. Each durable thread gets its own sandbox, cloned from the current recipe snapshot. For platform-level lifecycle details, see Sandboxes.When to use a sandbox
For more information, see Project structure. For a project that publishes a larger sandbox snapshot before deploy, see the design agent template.
Connect these docs to your agent of choice via MCP for real-time answers.

