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
JavaScriptdeepagentsmiddlewarecreateMemoryMiddleware
Function●Since v1.5

createMemoryMiddleware

Create middleware for loading agent memory from AGENTS.md files.

Loads memory content from configured sources and injects into the system prompt. Supports multiple sources that are combined together.

Copy
createMemoryMiddleware(
  options: MemoryMiddlewareOptions
): AgentMiddleware<StateSchema<__type>, undefined, unknown, readonly ClientTool | ServerTool[]>

Parameters

NameTypeDescription
options*MemoryMiddlewareOptions

Configuration options

Example

Copy
const middleware = createMemoryMiddleware({
  backend: new FilesystemBackend({ rootDir: "/" }),
  sources: [
    "~/.deepagents/AGENTS.md",
    "./.deepagents/AGENTS.md",
  ],
});
View source on GitHub