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
JavaScriptdeepagentsbackendsStateBackend
Classā—Since v1.4

StateBackend

Copy
class StateBackend

Used in Docs

  • Agent Client Protocol (ACP)
  • Backends
  • Context engineering in Deep Agents
  • Going to production
  • Memory

Constructors

Methods

View source on GitHub
constructor
constructor
method
downloadFiles→ MaybePromise<FileDownloadResponse[]>
method
edit→ Promise<EditResult>
method
glob→ Promise<GlobResult>
method
grep→ Promise<GrepResult>
method
ls→ Promise<LsResult>
method
read→ Promise<ReadResult>
method
readRaw→ Promise<ReadRawResult>
method
uploadFiles→ MaybePromise<FileUploadResponse[]>
method
write→ Promise<WriteResult>

Backend that stores files in agent state (ephemeral).

Uses LangGraph's state management and checkpointing. Files persist within a conversation thread but not across threads. State is automatically checkpointed after each agent step.

Special handling: Since LangGraph state must be updated via Command objects (not direct mutation), operations return filesUpdate in WriteResult/EditResult for the middleware to apply via Command.

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

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.

Memory-conscious: releases intermediate references early so the GC can reclaim buffers before the next large allocation is made.

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

Search for a literal text pattern in files using grep.

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.

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).

Read file content as raw FileData.

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

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

Create a new file with content.

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