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
JavaScriptdeepagentsbrowserStateBackend
Class●Since v1.10

StateBackend

Copy
class StateBackend

Used in Docs

  • Backends
  • Going to production
  • Memory
  • Prebuilt middleware

Constructors

Methods

View source on GitHub
deprecatedconstructor
constructor→ StateBackend
method
delete→ DeleteResult

Delete a file or directory from state.

Removes the exact file path plus every nested key under it.

method
downloadFiles→ FileDownloadResponse[]

Download multiple files.

method
edit→ EditResult

Edit a file by replacing string occurrences. Returns EditResult with filesUpdate and occurrences.

method
glob→ GlobResult

Structured glob matching returning FileInfo objects.

method
grep→ GrepResult

Search file contents for a literal text pattern. Binary files are skipped.

method
ls→ LsResult

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

method
read→ ReadResult

Read file content.

Text files are paginated by line offset/limit. Binary files return full Uint8Array content (offset/limit ignored).

method
readRaw→ ReadRawResult

Read file content as raw FileData.

method
uploadFiles→ FileUploadResponse[] & __type

Upload multiple files.

Note: Since LangGraph state must be updated via Command objects, the caller must apply filesUpdate via Command after calling this method.

method
write→ WriteResult

Write content to a file, creating it or overwriting it if it already exists. Returns WriteResult with filesUpdate to update LangGraph state.

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.