# StateClaudeMemoryMiddleware

> **Class** in `langchain_anthropic`

📖 [View in docs](https://reference.langchain.com/python/langchain-anthropic/middleware/anthropic_tools/StateClaudeMemoryMiddleware)

State-based memory tool middleware.

Provides Anthropic's memory tool using LangGraph state for storage.
Files persist for the conversation thread.

Enforces `/memories` prefix and injects Anthropic's recommended system prompt.

## Signature

```python
StateClaudeMemoryMiddleware(
    self,
    *,
    allowed_path_prefixes: Sequence[str] | None = None,
    system_prompt: str = MEMORY_SYSTEM_PROMPT,
)
```

## Description

**Example:**

```python
from langchain.agents import create_agent
from langchain.agents.middleware import StateMemoryToolMiddleware

agent = create_agent(
    model=model,
    tools=[],
    middleware=[StateMemoryToolMiddleware()],
)
```

## Parameters

| Name | Type | Required | Description |
|------|------|----------|-------------|
| `allowed_path_prefixes` | `Sequence[str] \| None` | No | Optional list of allowed path prefixes.  Defaults to `['/memories']`. (default: `None`) |
| `system_prompt` | `str` | No | System prompt to inject.  Defaults to Anthropic's recommended memory prompt. (default: `MEMORY_SYSTEM_PROMPT`) |

## Extends

- `_StateClaudeFileToolMiddleware`

## Constructors

```python
__init__(
    self,
    *,
    allowed_path_prefixes: Sequence[str] | None = None,
    system_prompt: str = MEMORY_SYSTEM_PROMPT,
) -> None
```

| Name | Type |
|------|------|
| `allowed_path_prefixes` | `Sequence[str] \| None` |
| `system_prompt` | `str` |


---

[View source on GitHub](https://github.com/langchain-ai/langchain/blob/f0c5a28fa05adcda89aebcb449d897245ab21fa4/libs/partners/anthropic/langchain_anthropic/middleware/anthropic_tools.py#L611)