> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-5e9cc07a-preview-lsapi-1779323176-451247e.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Use remote sandboxes

> Run Deep Agents Code tool execution in LangSmith, Daytona, Modal, Runloop, or AgentCore sandboxes. Install provider extras, set credentials, and use flags and setup scripts.

Deep Agents Code uses the [sandbox as tool](/oss/python/deepagents/sandboxes#sandbox-as-tool-pattern) pattern: the `dcode` process (LLM loop, memory, tool dispatch) runs on your machine, but agent tool calls (`read_file`, `write_file`, `execute`, etc.) target the remote sandbox, not your local filesystem. To get files into the sandbox, use a [setup script](#setup-scripts) or the provider's file transfer APIs (see [Working with files](/oss/python/deepagents/sandboxes#working-with-files)).

For a deeper look at sandbox architecture, integration patterns, and security best practices, see [Sandboxes](/oss/python/deepagents/sandboxes).

<Steps>
  <Step title="Install provider dependency" icon="download">
    <Tabs>
      <Tab title="LangSmith">
        Included by default when installing `deepagents-code`. No extra installation needed.
      </Tab>

      <Tab title="Daytona">
        ```bash theme={null}
        uv tool install deepagents-code --with langchain-daytona
        ```
      </Tab>

      <Tab title="Modal">
        ```bash theme={null}
        uv tool install deepagents-code --with langchain-modal
        ```
      </Tab>

      <Tab title="Runloop">
        ```bash theme={null}
        uv tool install deepagents-code --with langchain-runloop
        ```
      </Tab>

      <Tab title="AgentCore">
        ```bash theme={null}
        uv tool install deepagents-code --with langchain-agentcore-codeinterpreter
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Set provider credentials" icon="key">
    <Tabs>
      <Tab title="LangSmith">
        ```bash theme={null}
        export LANGSMITH_API_KEY="your-key"
        ```
      </Tab>

      <Tab title="Daytona">
        ```bash theme={null}
        export DAYTONA_API_KEY="your-key"
        ```
      </Tab>

      <Tab title="Modal">
        ```bash theme={null}
        modal setup
        ```
      </Tab>

      <Tab title="Runloop">
        ```bash theme={null}
        export RUNLOOP_API_KEY="your-key"
        ```
      </Tab>

      <Tab title="AgentCore">
        ```bash theme={null}
        export AWS_ACCESS_KEY_ID="your-key"
        export AWS_SECRET_ACCESS_KEY="your-secret"
        export AWS_SESSION_TOKEN="session-token"
        export AWS_REGION="us-west-2"
        ```
      </Tab>
    </Tabs>
  </Step>

  <Step title="Run Deep Agents Code with a sandbox" icon="player-play">
    <Tabs>
      <Tab title="LangSmith">
        ```bash theme={null}
        dcode --sandbox langsmith
        ```
      </Tab>

      <Tab title="Daytona">
        ```bash theme={null}
        dcode --sandbox daytona
        ```
      </Tab>

      <Tab title="Modal">
        ```bash theme={null}
        dcode --sandbox modal
        ```
      </Tab>

      <Tab title="Runloop">
        ```bash theme={null}
        dcode --sandbox runloop
        ```
      </Tab>

      <Tab title="AgentCore">
        ```bash theme={null}
        dcode --sandbox agentcore
        ```
      </Tab>
    </Tabs>
  </Step>
</Steps>

## Sandbox flags and examples

| Flag                   | Description                                                                                                                             |
| ---------------------- | --------------------------------------------------------------------------------------------------------------------------------------- |
| `--sandbox TYPE`       | Sandbox provider to use: `langsmith`, `agentcore`, `modal`, `daytona`, or `runloop` (default: `none`)                                   |
| `--sandbox-id ID`      | Reuse an existing sandbox by ID instead of creating a new one. Skips creation and cleanup. Refer to your sandbox documentation for more |
| `--sandbox-setup PATH` | Path to a setup script to run inside the sandbox upon creation                                                                          |

Examples:

```bash theme={null}
# Create a new Daytona sandbox
dcode --sandbox daytona

# Reuse an existing sandbox (skips creation and cleanup)
dcode --sandbox runloop --sandbox-id dbx_abc123

# Run a setup script after sandbox creation
dcode --sandbox modal --sandbox-setup ./setup.sh
```

## Setup scripts

Use `--sandbox-setup` to run a shell script inside the sandbox after creation. This is useful for cloning repos, installing dependencies, and configuring environment variables.

```bash title="setup.sh" theme={null}
#!/bin/bash
set -e

# Clone repository using GitHub token
git clone https://x-access-token:${GITHUB_TOKEN}@github.com/username/repo.git $HOME/workspace
cd $HOME/workspace

# Make environment variables persistent
cat >> ~/.bashrc <<'EOF'
export GITHUB_TOKEN="${GITHUB_TOKEN}"
export OPENAI_API_KEY="${OPENAI_API_KEY}"
cd $HOME/workspace
EOF
source ~/.bashrc
```

Deep Agents Code expands `${VAR}` references in setup scripts using your local environment variables. Store secrets in a local `.env` file for the setup script to access.

<Warning>
  Sandboxes isolate code execution, but agents remain vulnerable to prompt injection with untrusted inputs. Use human-in-the-loop approval, short-lived secrets, and trusted setup scripts only. See [Security considerations](/oss/python/deepagents/sandboxes#security-considerations) for details.
</Warning>

***

<div className="source-links">
  <Callout icon="terminal-2">
    [Connect these docs](/use-these-docs) to Claude, VSCode, and more via MCP for real-time answers.
  </Callout>

  <Callout icon="edit">
    [Edit this page on GitHub](https://github.com/langchain-ai/docs/edit/main/src/oss/deepagents/code/remote-sandboxes.mdx) or [file an issue](https://github.com/langchain-ai/docs/issues/new/choose).
  </Callout>
</div>
