LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
LangSmith
  • Client
  • Run Trees
  • Traceable
  • Evaluation
  • Schemas
  • Langchain
  • Jest
  • Vitest
  • Wrappers
  • Anonymizer
  • Jestlike
  • Vercel
  • Anthropic
  • Sandbox
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

LangSmith
ClientRun TreesTraceableEvaluationSchemasLangchainJestVitestWrappersAnonymizerJestlikeVercelAnthropicSandbox
Language
Theme
JavaScriptlangsmithexperimentalsandbox
Module●Since v0.6

experimental/sandbox

LangSmith Sandbox Module.

This module provides sandboxed code execution capabilities through the LangSmith Sandbox API.

Copy
import { ... } from "langsmith/experimental/sandbox";

Example

Copy
import { SandboxClient } from "langsmith/experimental/sandbox";

// Uses LANGSMITH_ENDPOINT and LANGSMITH_API_KEY from environment
const client = new SandboxClient();

const sandbox = await client.createSandbox("python-sandbox");
try {
  const result = await sandbox.run("python --version");
  console.log(result.stdout);
} finally {
  await sandbox.delete();
}

Classes

class
CommandHandle

Async handle to a running command with streaming output and auto-reconnect.

Async iterable, yielding OutputChunk objects (stdout and stderr interleaved in arrival order). Access .result after iteration to get the full ExecutionResult.

Auto-reconnect behavior:

  • Server hot-reload (1001 Going Away): reconnect immediately
  • Network error / unexpected close: reconnect with exponential backoff
  • User called kill(): do NOT reconnect (propagate error)
class
LangSmithCommandTimeoutError

Raised when a command exceeds its timeout.

class
LangSmithDataplaneNotConfiguredError

Raised when dataplane_url is not available for the sandbox.

This occurs when the sandbox-router URL is not configured for the cluster.

class
LangSmithQuotaExceededError

Raised when organization quota limits are exceeded.

Users should contact support@langchain.dev to increase quotas.

class
LangSmithResourceAlreadyExistsError

Raised when creating a resource that already exists.

class
LangSmithResourceCreationError

Raised when resource provisioning fails (general-purpose).

class
LangSmithResourceInUseError

Raised when deleting a resource that is still in use.

class
LangSmithResourceNameConflictError

Raised when updating a resource name to one that already exists.

class
LangSmithResourceNotFoundError

Raised when a resource is not found.

class
LangSmithResourceTimeoutError

Raised when an operation times out.

class
LangSmithSandboxAPIError

Raised when the API endpoint returns an unexpected error.

For example, this is raised for wrong URL or path.

class
LangSmithSandboxAuthenticationError

Raised when authentication fails (invalid or missing API key).

class
LangSmithSandboxConnectionError

Raised when connection to the sandbox server fails.

class
LangSmithSandboxCreationError

Raised when sandbox creation fails.

class
LangSmithSandboxError

Base exception for sandbox client errors.

class
LangSmithSandboxNotReadyError

Raised when attempting to interact with a sandbox that is not ready.

class
LangSmithSandboxOperationError

Raised when a sandbox operation fails (run, read, write).

class
LangSmithSandboxServerReloadError

Raised when the sandbox server is reloading (close code 1001).

Subclass of connection error that signals immediate reconnect (no backoff).

class
LangSmithValidationError

Raised when request validation fails.

This includes:

  • Resource values exceeding server-defined limits (CPU, memory, storage)
  • Invalid resource units
  • Invalid name formats
  • Pool validation failures (e.g., template has volumes)
class
Sandbox

Represents an active sandbox for running commands and file operations.

This class is typically obtained from SandboxClient.createSandbox() and provides methods for command execution and file I/O within the sandbox environment.

class
SandboxClient

Client for interacting with the Sandbox Server API.

This client provides a simple interface for managing sandboxes and templates.

Interfaces

interface
CreatePoolOptions

Options for creating a pool.

interface
CreateSandboxOptions

Options for creating a sandbox.

interface
CreateTemplateOptions

Options for creating a template.

interface
CreateVolumeOptions

Options for creating a volume.

interface
ExecutionResult

Result of executing a command in a sandbox.

interface
OutputChunk

A single chunk of streaming output from command execution.

interface
Pool

Represents a Sandbox Pool for pre-provisioned sandboxes.

Pools pre-provision sandboxes from a template for faster startup.

interface
ResourceSpec

Resource specification for a sandbox.

interface
ResourceStatus

Lightweight provisioning status for any async-created resource.

interface
RunOptions

Options for running a command in a sandbox.

interface
SandboxClientConfig

Configuration options for the SandboxClient.

interface
SandboxData

Data representing a sandbox instance from the API.

interface
SandboxTemplate

Represents a SandboxTemplate.

Templates define the image, resource limits, and volume mounts for sandboxes.

interface
UpdatePoolOptions

Options for updating a pool.

interface
UpdateSandboxOptions

Options for updating a sandbox (name and/or TTL).

interface
UpdateTemplateOptions

Options for updating a template.

interface
UpdateVolumeOptions

Options for updating a volume.

interface
Volume

Represents a persistent volume.

interface
VolumeMountSpec

Specification for mounting a volume in a sandbox template.

interface
WaitForSandboxOptions

Options for waiting for a sandbox to become ready.

interface
WsMessage

Internal WebSocket message type from the server.

interface
WsRunOptions

Options for the low-level WebSocket stream functions.

View source on GitHub