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

Chat LangChain

What can I help with?

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
  • Customize Deep Agents
  • Going to production
  • Memory
  • Prebuilt middleware

Constructors

Properties

Methods

View source on GitHub
deprecatedconstructor
constructorโ†’ StateBackend
property
backendKind: "state"

Class identity discriminant for StateBackend.isInstance.

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.

method
isInstanceโ†’ backend is StateBackend

Duck-typed so this survives the plain-object copies adaptBackendProtocol makes โ€” a class check wouldn't.

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.