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
JavaScriptdeepagentsbrowserFilesystemMiddlewareOptions
Interface●Since v1.10

FilesystemMiddlewareOptions

Options for creating filesystem middleware.

Copy
interface FilesystemMiddlewareOptions

Properties

property
backend: AnyBackendProtocol | BackendFactory

Backend instance or factory (default: StateBackend)

property
customToolDescriptions: Partial<Record<"ls" | "read_file" | "write_file" | "edit_file" | "glob" | "grep" | "execute", string>> | null

Optional descriptions for built-in filesystem tools.

Keys correspond to FsToolName. Descriptions for tools that are not enabled by the tools allowlist are ignored because those tools are not exposed to the model.

property
humanMessageTokenLimitBeforeEvict: number | null

Optional token limit before evicting a HumanMessage to the filesystem (default: 50000 tokens, ~200KB)

property
permissions: FilesystemPermission[]

Filesystem permission rules enforced on every tool call.

Rules are evaluated in declaration order; first match wins; permissive default. Applies to ls, read_file, write_file, edit_file, glob, and grep.

Note on execute: permissions are not enforced on execute because shell commands can access any path regardless of path-based rules. Using permissions with an execution-capable backend (one where isSandboxBackend returns true) throws a ConfigurationError unless either:

  • execute is disabled via tools, or
  • the backend is a CompositeBackend and every permission path is scoped to a route prefix.

When omitted or empty, all filesystem operations are permitted.

property
systemPrompt: string | null

System prompt override. Set to null to disable. Defaults to ASYNC_TASK_SYSTEM_PROMPT.

property
tools: readonly "ls" | "read_file" | "write_file" | "edit_file" | "glob" | "grep" | "execute"[] | "all" | null

Allowlist of built-in filesystem tools to expose to the model.

  • undefined, null, and "all" preserve the default behavior: every filesystem tool is registered, subject to backend capability filtering.
  • Passing an array restricts the middleware to only those tool names.
  • read_file must be included in every explicit array because it is used by normal file-inspection flows and by large-result recovery guidance.
  • Backend capability checks still narrow the final visible tool set. For example, execute is removed when the resolved backend does not support command execution, even if it appears in this allowlist.
  • User-provided non-filesystem tools are not affected by this allowlist.

The generated filesystem system prompt is based on the tools that remain visible after this allowlist and backend capability filtering are applied.

Copy
createFilesystemMiddleware({
  tools: ["read_file", "ls", "glob", "grep"],
});
property
toolTokenLimitBeforeEvict: number | null

Optional token limit before evicting a tool result to the filesystem (default: 20000 tokens, ~80KB)

View source on GitHub