LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • Configuration
  • Types
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
  • Vitest
⌘I

LangChain Assistant

Ask a question to get started

Enter to send•Shift+Enter new line

Menu

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsConfigurationTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsindexCompositeBackend
Class●Since v1.4

CompositeBackend

Backend that routes file operations to different backends based on path prefix.

This enables hybrid storage strategies like:

  • /memories/ → StoreBackend (persistent, cross-thread)
  • Everything else → StateBackend (ephemeral, per-thread)

The CompositeBackend handles path prefix stripping/re-adding transparently.

Copy
class CompositeBackend

Used in Docs

  • Backends
  • Long-term memory
  • Prebuilt middleware

Constructors

constructor
constructor

Methods

method
downloadFiles→ MaybePromise<FileDownloadResponse[]>

Download multiple files from the sandbox. Implementations must support partial success.

method
edit→ Promise<EditResult>

Edit a file by replacing string occurrences.

Uses downloadFiles() to read, performs string replacement in TypeScript, then uploadFiles() to write back. No runtime needed on the sandbox host.

method
execute→ MaybePromise<ExecuteResponse>

Execute a command in the sandbox. This is the only method concrete implementations must provide.

method
globInfo→ Promise<FileInfo[]>

Structured glob matching returning FileInfo objects.

Uses pure POSIX shell (find + stat) via execute() to list all files, then applies glob-to-regex matching in TypeScript. No Python or Node.js needed on the sandbox host.

Glob patterns are matched against paths relative to the search base:

  • * matches any characters except /
  • ** matches any characters including / (recursive)
  • ? matches a single character except /
  • [...] character classes
method
grepRaw→ Promise<string | GrepMatch[]>

Search for a literal text pattern in files using grep.

method
lsInfo→ Promise<FileInfo[]>

List files and directories in the specified directory (non-recursive).

Uses pure POSIX shell (find + stat) via execute() — works on any Linux including Alpine. No Python or Node.js needed.

method
read→ Promise<string>

Read file content with line numbers.

Uses pure POSIX shell (awk) via execute() — only the requested slice is returned over the wire, making this efficient for large files. Works on any Linux including Alpine (no Python or Node.js needed).

method
readRaw→ Promise<FileData>

Read file content as raw FileData.

Uses downloadFiles() directly — no runtime needed on the sandbox host.

method
uploadFiles→ MaybePromise<FileUploadResponse[]>

Upload multiple files to the sandbox. Implementations must support partial success.

method
write→ Promise<WriteResult>

Create a new file with content.

Uses downloadFiles() to check existence and uploadFiles() to write. No runtime needed on the sandbox host.

View source on GitHub