LangChain Reference home pageLangChain ReferenceLangChain Reference
  • GitHub
  • Main Docs
Deep Agents
LangChain
LangGraph
Integrations
LangSmith
  • Overview
  • Agent
  • Middleware
  • Backends
  • Sandboxes
  • Skills
  • Subagents
  • 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

OverviewAgentMiddlewareBackendsSandboxesSkillsSubagentsTypes
Modal
Daytona
Deno
Node VFS
Sandbox Standard Tests
Vitest
Language
Theme
JavaScriptdeepagentsbackendsCompositeBackend
Class●Since v1.5

CompositeBackend

Copy
class CompositeBackend

Used in Docs

  • Backends
  • Going to production
  • Memory
  • Prebuilt middleware

Constructors

Properties

Methods

View source on GitHub
constructor
constructor→ CompositeBackend
property
id: string
property
routePrefixes: string[]
method
delete→ Promise<DeleteResult>

Delete a file or directory, routing to appropriate backend.

Parent and root deletions run sequentially across the base backend and any mounted routes below the requested path. A failure stops the fan-out so later backends are left untouched, but earlier deletions cannot be rolled back and are reported as potentially partial.

method
downloadFiles→ Promise<FileDownloadResponse[]>

Download multiple files, batching by backend for efficiency.

method
edit→ Promise<EditResult>

Edit a file, routing to appropriate backend.

method
execute→ Promise<ExecuteResponse>

Execute a command via the default backend. Execution is not path-specific, so it always delegates to the default backend.

method
glob→ Promise<GlobResult>

Structured glob matching returning FileInfo objects.

method
grep→ Promise<GrepResult>

Structured search results or error string for invalid input.

method
ls→ Promise<LsResult>

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

method
read→ Promise<ReadResult>

Read file content, routing to appropriate backend.

method
readRaw→ Promise<ReadRawResult>

Read file content as raw FileData.

method
resolveBackendForPath→ [BackendProtocolV2, string]

Returns the backend for path, with the matched prefix stripped from the returned path.

method
uploadFiles→ Promise<FileUploadResponse[]>

Upload multiple files, batching by backend for efficiency.

method
write→ Promise<WriteResult>

Write content to a file, routing to appropriate backend.

method
isInstance→ backend is CompositeBackend

Type guard — returns true if backend is a CompositeBackend.

Uses duck-typing on routePrefixes so it works across module boundaries where instanceof may fail.

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.