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
JavaScriptlangsmithsandboxSandbox
Class●Since v0.8

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.

Copy
class Sandbox

Example

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

Properties

property
created_at: string
property
dataplane_url: string
property
delete_after_stop_seconds: number
property
fs_capacity_bytes: number
property
id: string
property
idle_ttl_seconds: number
property
mem_bytes: number
property
name: string
property
snapshot_id: string
property
status: string

HTTP status for the response that caused the error

property
status_message: string
property
stopped_at: string
property
updated_at: string
property
vCpus: number

Number of vCPUs allocated.

Methods

method
captureSnapshot→ Promise<Snapshot>

Capture a snapshot from this sandbox.

method
delete→ APIPromise<Rsp>
method
read→ Promise<Uint8Array<ArrayBufferLike>>

Read a file from the sandbox.

method
reconnect→ Promise<CommandHandle>

Reconnect to this command from the last known offsets.

Returns a new CommandHandle that resumes output from where this one left off.

method
run→ Promise<CommandHandle>

Execute a command in the sandbox.

When wait is true (default) and no streaming callbacks are provided, tries WebSocket first and falls back to HTTP POST.

When wait is false or streaming callbacks are provided, uses WebSocket (required). Returns a CommandHandle for streaming output.

method
start→ APIPromise<SandboxResponse>

Start a stopped or failed sandbox. This endpoint is not idempotent.

method
stop→ APIPromise<void>

Stop a ready sandbox. This endpoint is not idempotent; the filesystem is preserved for later restart.

method
write→ Promise<void>

Write content to a file in the sandbox.

View source on GitHub