---
title: "Persistent memory"
description: "Carry selected, namespace-scoped context across deep-agent runs."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.cortavyn.org/llms.txt
> Use this file to discover all available pages before exploring further.

# Persistent memory

`DeepMemory` loads a string into the initial system context and exposes memory tools to the agent. It is for durable facts, preferences, or compact working knowledge—not for complete transcripts or unrestricted file storage.

```java
var memory = new FileDeepMemory(memoryRoot);
var agent = DeepAgent.builder(model)
    .memory(memory, "customer-42")
    .build();
```

The namespace separates independent memory scopes. `FileDeepMemory` stores each namespace in a local Markdown file and accepts only letters, numbers, dots, underscores, and hyphens in its name. Its writes are atomic, making it a practical option for a local deployment with a deliberately selected private directory.

The agent receives loaded memory before the user request and may use `write_memory`, which is approval-protected by default. For shared, encrypted, audited, or multi-tenant deployments, implement `DeepMemory` against the application's own persistence and authorization layer.

Keep memory concise. It consumes model context on every run; retain authoritative or large source material in a workspace, MCP resource, or application retrieval system instead.

Source: https://docs.cortavyn.org/deep-agent/persistent-memory/index.mdx
