deep-memory-agent
Factory for building LangChain deepagents equipped with episodic, semantic, and procedural memory.
Memory is a small wiki of plain markdown files — readable, diffable, versionable with git — that the agent maintains itself: it records what happened, supersedes what is no longer true, and consolidates recurring patterns into durable knowledge.
The tree lives at the virtual path /memory/, served by a
deepagents backend. No tool in
this package touches the host filesystem directly, so the same agent runs
unchanged against a directory on disk, ephemeral thread state, or a remote store.
📖 Documentation: https://giurlanda.github.io/deep-memory-agent/
Installation
pip install deep-memory-agent
Quickstart
Two factories, one tree. The manager writes; the search agent cannot.
from deep_memory_agent import create_memory_manager_agent, create_memory_search_agent
manager = create_memory_manager_agent("claude-sonnet-5", memory_dir="./memory")
manager.invoke(
{
"messages": [
{
"role": "user",
"content": "Remember that I manage Python projects with uv.",
}
]
}
)
recall = create_memory_search_agent("claude-sonnet-5", memory_dir="./memory")
recall.invoke(
{"messages": [{"role": "user", "content": "Which package manager do I use?"}]}
)
Each factory takes either memory_dir — the default on-disk wiring — or a
ready-made backend. Exactly one of the two is required; passing both raises.
The memory tree
/memory/
├── index.md router for the whole tree
├── preferences.md how the user wants the agent to behave
├── episodic_memory/ what happened
│ ├── index.md
│ ├── events/YYYY-MM.md sharded by month
│ ├── feedbacks/YYYY-MM.md
│ └── errors/YYYY-MM.md
├── semantic_memory/ what is true
│ ├── index.md
│ ├── facts.md
│ └── rules.md
└── procedural_memory/ how things are done
├── index.md
└── <slug>.md one file per procedure
Every entry carries YAML frontmatter, so provenance travels with the content and a newer statement can explicitly retire an older one:
---
id: mem_2026-08-24_9f3a1c
created: 2026-08-24T10:15:00+00:00
type: semantic
category: facts
source: user_message
confidence: high
tags: [pricing, acme]
supersedes: mem_2026-06-01_4b2e77
summary: ACME moved to the Enterprise plan
---
ACME switched from the Team plan to Enterprise on 2026-08-24.
Three rules keep the tree from degenerating into an append-only log:
- Indexes are routers, never content — one line per file, so the agent can decide what to load without loading everything.
- Semantic memory is superseded, not appended — a changed fact produces a new entry that retires the old one, which stays on disk as history.
- Episodic memory is sharded by month — no single file outgrows the context window.
Consolidation
Episodic memory on its own is a log. consolidate_memory reads recent episodes
and promotes what has hardened into facts, rules or procedures. It is a plain
function, so it can be scheduled from ordinary code; the manager agent also
exposes it as the memory_consolidate tool.
from deep_memory_agent import build_memory_backend, consolidate_memory
result = consolidate_memory(build_memory_backend("./memory"), "claude-sonnet-5")
Episodes are never deleted: consolidation only adds durable knowledge and supersedes what it contradicts.
See examples/ for runnable scripts, or the docs.
Scope of this version
Memory is file-based and retrieval is lexical (case-insensitive substring over summary, body and tags). The structured frontmatter is what makes a stronger index — BM25, embeddings — addable later without changing the files themselves. Automatic decay, locking between concurrent writers and vector retrieval are out of scope; keeping a single writer over the tree is the manager agent's job.
Development
This project uses uv for dependency management.
uv sync --all-extras
uv run pytest
uv run ruff check .
uv run ruff format .
License
MIT — see LICENSE.
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deep_memory_agent-0.1.1.tar.gz.
File metadata
- Download URL: deep_memory_agent-0.1.1.tar.gz
- Upload date:
- Size: 148.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8038e2b8f464f9e9c45f47b00cf488233ba2e059646136ab484ac1be41e54ec
|
|
| MD5 |
40a5d0c77f4bba6e34ef74ec7afa8e28
|
|
| BLAKE2b-256 |
136d3a079bfb1311a8ce058c9b4fde27f273d244e0c70c2503985ec9bd33c3c3
|
Provenance
The following attestation bundles were made for deep_memory_agent-0.1.1.tar.gz:
Publisher:
publish.yml on giurlanda/deep-memory-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deep_memory_agent-0.1.1.tar.gz -
Subject digest:
e8038e2b8f464f9e9c45f47b00cf488233ba2e059646136ab484ac1be41e54ec - Sigstore transparency entry: 2581971578
- Sigstore integration time:
-
Permalink:
giurlanda/deep-memory-agent@7b2bd1a0bfd880d4144a1b258fcfe50069a27a3a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/giurlanda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b2bd1a0bfd880d4144a1b258fcfe50069a27a3a -
Trigger Event:
push
-
Statement type:
File details
Details for the file deep_memory_agent-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deep_memory_agent-0.1.1-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
67f2ca87f7df60c22bd792c058c6b5552192709a18ae2d2ac3f8e55c24b713ec
|
|
| MD5 |
1820306f1c059d02187580ca55e3bed3
|
|
| BLAKE2b-256 |
af2ee4d3181b5e138dbebc2954cfdb14aa4f9e86c2e24933431589ddbd87cf1f
|
Provenance
The following attestation bundles were made for deep_memory_agent-0.1.1-py3-none-any.whl:
Publisher:
publish.yml on giurlanda/deep-memory-agent
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
deep_memory_agent-0.1.1-py3-none-any.whl -
Subject digest:
67f2ca87f7df60c22bd792c058c6b5552192709a18ae2d2ac3f8e55c24b713ec - Sigstore transparency entry: 2581971585
- Sigstore integration time:
-
Permalink:
giurlanda/deep-memory-agent@7b2bd1a0bfd880d4144a1b258fcfe50069a27a3a -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/giurlanda
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@7b2bd1a0bfd880d4144a1b258fcfe50069a27a3a -
Trigger Event:
push
-
Statement type: