FilesystemClaudeMemoryMiddleware Class — langchain Architecture
Architecture documentation for the FilesystemClaudeMemoryMiddleware class in anthropic_tools.py from the langchain codebase.
Entity Profile
Dependency Diagram
graph TD ea9f4384_ef45_0e91_f871_a1488eb4a931["FilesystemClaudeMemoryMiddleware"] 8fe6cc85_9f97_b147_028a_db962cd6b744["_FilesystemClaudeFileToolMiddleware"] ea9f4384_ef45_0e91_f871_a1488eb4a931 -->|extends| 8fe6cc85_9f97_b147_028a_db962cd6b744 5f8ab4b6_f98f_f653_1208_76332f94ecba["anthropic_tools.py"] ea9f4384_ef45_0e91_f871_a1488eb4a931 -->|defined in| 5f8ab4b6_f98f_f653_1208_76332f94ecba 1b545cf3_a29f_df13_1602_524fd8fc19b8["__init__()"] ea9f4384_ef45_0e91_f871_a1488eb4a931 -->|method| 1b545cf3_a29f_df13_1602_524fd8fc19b8
Relationship Graph
Source Code
libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py lines 1110–1161
class FilesystemClaudeMemoryMiddleware(_FilesystemClaudeFileToolMiddleware):
"""Filesystem-based memory tool middleware.
Provides Anthropic's memory tool using local filesystem for storage.
User handles persistence via volumes, git, or other mechanisms.
Enforces `/memories` prefix and injects Anthropic's recommended system
prompt.
Example:
```python
from langchain.agents import create_agent
from langchain.agents.middleware import FilesystemMemoryToolMiddleware
agent = create_agent(
model=model,
tools=[],
middleware=[FilesystemMemoryToolMiddleware(root_path="/workspace")],
)
```
"""
def __init__(
self,
*,
root_path: str,
allowed_prefixes: list[str] | None = None,
max_file_size_mb: int = 10,
system_prompt: str = MEMORY_SYSTEM_PROMPT,
) -> None:
"""Initialize the memory middleware.
Args:
root_path: Root directory for file operations.
allowed_prefixes: Optional list of allowed virtual path prefixes.
Defaults to `['/memories']`.
max_file_size_mb: Maximum file size in MB
Defaults to `10`.
system_prompt: System prompt to inject.
Defaults to Anthropic's recommended memory prompt.
"""
super().__init__(
tool_type=MEMORY_TOOL_TYPE,
tool_name=MEMORY_TOOL_NAME,
root_path=root_path,
allowed_prefixes=allowed_prefixes or ["/memories"],
max_file_size_mb=max_file_size_mb,
system_prompt=system_prompt,
)
Source
Frequently Asked Questions
What is the FilesystemClaudeMemoryMiddleware class?
FilesystemClaudeMemoryMiddleware is a class in the langchain codebase, defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py.
Where is FilesystemClaudeMemoryMiddleware defined?
FilesystemClaudeMemoryMiddleware is defined in libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py at line 1110.
What does FilesystemClaudeMemoryMiddleware extend?
FilesystemClaudeMemoryMiddleware extends _FilesystemClaudeFileToolMiddleware.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free