AI Agents Made Simple reached #1 in Software Development, Software Engineering and Software Design Tools on Amazon.com's Kindle Store. A decision guide to building AI agents that work: 28 chapters, 148 illustrations, no code. Get the book on Amazon → 🧠 Agent Memory Techniques Learn every agent memory technique for LLM agents. ⭐ If you find this useful, please star the repo so more learners can discover it. 🧭 New…
AI Agents Made Simple reached #1 in Software Development, Software Engineering and Software Design Tools on Amazon.com’s Kindle Store.
A decision guide to building AI agents that work: 28 chapters, 148 illustrations, no code. Get the book on Amazon →
🧠 Agent Memory Techniques
Learn every agent memory technique for LLM agents.
⭐ If you find this useful, please star the repo so more learners can discover it.
🧭 New here? Start with 01 Conversation Buffer Memory or pick a Learning Path. Prefer a visual? See the Decision Tree below. 30 runnable Jupyter notebooks covering conversation buffers, vector stores, knowledge graphs, episodic and semantic memory, working memory, MemGPT, Mem0, Letta, Zep, Graphiti, LoCoMo benchmarks, and production memory patterns.
Join over 50,000 readers getting clear AI tutorials every week.Subscribers also get early access and a 33% discount on my book.
💡 Why Agent Memory Matters
💡 Quick Answer (for search engines and skimmers)
Agent memory is the set of techniques that let an LLM-based agent (a system built around a Large Language Model) remember information across turns, sessions, and tasks. Without memory, an agent re-derives context every time and cannot personalize, learn, or maintain coherence over long interactions. This repository documents 30 distinct memory techniques, grouped into six families: short-term context management, long-term storage, cognitive architectures, retrieval and multi-agent patterns, batteries-included frameworks, and production deployment patterns.
Think about a friend who forgets every conversation you’ve ever had. Every morning you’re strangers again. That’s what most AI agents are like today.
Every AI agent eventually hits the same wall: it forgets.
In 2026, AI agents are everywhere. But most of them still forget what you told them yesterday. Without strong memory, an agent can’t keep context across conversations. It can’t learn from past chats. It can’t build a lasting relationship with you.
The landscape is shifting fast:
Anthropic’s 7 Layers of Memory (March 2026): from conversation context to cross-project knowledge, defining the memory hierarchy for Claude Code
Mem0: managed memory layer gaining rapid adoption for personalized AI
Letta (MemGPT): self-editing memory with inner/outer monologue architecture
Zep: temporal knowledge graphs for long-term agent memory
30 techniques grouped by what you are building. Pick the group that matches your goal, then open the technique inside it.
Quick text version:
Need to manage the current chat? Start with 01-05 (short-term memory).
Need to persist across sessions? Start with 06 Vector Store or 21 Cross-Session Memory.
Building a cognitive architecture with multiple stores? See 12-19.
Using a framework? Go straight to 24 Graphiti, 25 Mem0, 26 Letta, or 27 Zep.
Evaluating or shipping to production? See 28-30.
Still not sure? Start with 01 Conversation Buffer. Almost every other technique builds on it.
📐 Compare Techniques at a Glance
Looking to filter by constraint (persistence, retrieval style, token cost, best-for use case)? See the side-by-side comparison matrix covering all 30 techniques in one table.
💡 Prefer not to install anything? Every notebook renders on GitHub directly. Click a technique in the table above to read it in your browser. Or use the Colab badges to run it in the cloud.
# Clone the repository
git clone https://github.com/NirDiamant/Agent_Memory_Techniques.git
cd Agent_Memory_Techniques
# Create a virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Set up your API keys
cp .env.example .env
# Edit .env with your OPENAI_API_KEY and/or ANTHROPIC_API_KEY
# Launch Jupyter and start with the first technique
jupyter notebook all_techniques/01_conversation_buffer_memory/
The notebooks call gpt-5.4-mini (notebook 05 uses gpt-5.4) and claude-sonnet-5. Each notebook names its model once near the top (MODEL or CHAT_MODEL), so a model change is a one-line edit.
What was tested on Python 3.11 (October 2026):
Run end to end against the OpenAI API: 04, 05, 09-15, 17-22, 25, 26 and 29.
Run end to end against a local mock of the Anthropic Messages API: the Claude notebooks 01, 02, 03, 06, 07, 08, 16, 23, 28 and 30. No Anthropic credit was available, so their code and requests are checked but Claude’s answers are not.
Only parsed: 24 (needs Neo4j) and 27 (needs a Zep API key).
📁 Project Structure
Agent_Memory_Techniques/
├── README.md # You are here
├── ROADMAP.md # Current state and what's next
├── LICENSE # Apache 2.0
├── CITATION.cff # How to cite this work
├── requirements.txt # Python dependencies
├── .env.example # API key template
├── llms.txt # LLM-discoverability index
│
├── all_techniques/ # 30 technique folders, each with notebook + README
│ ├── 01_conversation_buffer_memory/
│ ├── 02_sliding_window_memory/
│ ├── ...
│ └── 30_production_memory_patterns/
│
├── docs/ # Project documentation
│ ├── architecture.md # Memory system design patterns
│ ├── comparison.md # Side-by-side comparison of all 30 techniques
│ ├── glossary.md # Key terms and definitions
│ ├── learning_path.md # Detailed learning path guide
│ ├── topics.md # Keyword index
│ ├── roadmap.md # Original planning archive
│ ├── FAQ.md # Frequently asked questions
│ └── CONTENT_STANDARDS.md # Writing-style rules
│
├── .github/ # GitHub community files
│ ├── CONTRIBUTING.md # How to contribute
│ ├── CODE_OF_CONDUCT.md # Community guidelines
│ ├── SECURITY.md # Security policy
│ ├── FUNDING.yml # Sponsorship config
│ ├── ISSUE_TEMPLATE/ # Issue templates
│ ├── pull_request_template.md # PR template
│ └── workflows/ # CI workflows
│
├── utils/ # Shared helpers and validators
│ ├── helpers.py # Env loading, LLM clients, cosine, tokens
│ ├── validate_cells.py # Notebook cell-structure validator
│ └── validate_style.py # Prose-style validator
│
├── tests/ # pytest smoke tests
├── data/ # Small sample datasets
└── images/ # Diagrams and visuals
📚 More from DiamantAI
RAG Made Simple - Amazon Bestseller in Generative AI · 1,500+ readers · ⭐ 4.6
AI Agents Made Simple - the decision guide to building agents that work: 28 chapters on what each pattern does, what breaks, what it costs, and when it is overkill. No code.
We welcome contributions. You can fill in a notebook, fix a bug, improve the docs, or propose a new technique. Every contribution helps the next reader.
More techniques we haven’t covered yet (propose one via an issue)
Architecture diagrams (Mermaid or ASCII)
More memory benchmarks and evaluation metrics
Integration examples for new frameworks
💖 Sponsors
Supporting this project helps keep educational AI content free and open. If your company uses agent memory in production, consider sponsoring to get your logo below.
🔗 Related Work
This repo is part of a bigger collection of AI technique tutorials.
This repository is a practical reference for agent memory in Large Language Model (LLM) applications. For the full keyword index covering short-term, long-term, cognitive architectures, retrieval, frameworks, evaluation, and production patterns, see docs/topics.md.
⚠️ Disclaimer
This repository is for educational purposes. The code here shows how agent memory techniques work. It is not production-ready software. Do not use it as-is for handling regulated data, medical decisions, legal advice, or any high-stakes application without a careful review. The authors accept no responsibility for how you use this material.
📄 License
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
📖 Citation
If you use this repository in your research or teaching, please cite:
@misc{diamant2026agentmemory,
title={Agent Memory Techniques: A Cookbook for LLM Agent Memory},
author={Nir Diamant},
year={2026},
url={https://github.com/NirDiamant/Agent_Memory_Techniques}
}
Built with care by Nir Diamant, making advanced AI accessible to everyone.
评论