Evolution-first memory framework for AI agents — memories that grow, mature, and fade
Project description
ksteam-memoir
Evolution-first memory framework for AI agents.
You are not a database. Your memories shouldn't be one either.
Most memory frameworks answer one question: "What stored fact is most similar to this query?" Memoir answers a different question: "What does this moment remind you of?"
Memories don't live in vector space. They live in time — they're born, revisited, forgotten, reawakened. Memoir models this.
The Three Ideas
-
Memory breathes. A memory not revisited for weeks quietly dims. One repeatedly triggered brightens. This is lifecycle, not caching.
-
Association, not retrieval. When a conversation slides into a topic, related domains should light up through curated concept-to-memory mappings — closer to human spreading activation than vector similarity.
-
Continue, don't fragment. New memories prefer extending existing files over creating new ones. A memory reads like a journal, not a pile of sticky notes.
These are not academic. They emerged from a personal AI memory system that has been running daily since May 13, 2026 — accumulating real memories, hitting real scaling pains, and evolving real solutions. Every design decision has a scar behind it.
What You Can Build With Memoir
- Personal AI companions — agents that remember you across sessions: preferences, shared history, inside jokes. Not a fresh start every time.
- Role-playing characters — NPCs or story agents with persistent personality layers, evolving relationships, and selective memory.
- Long-running coding assistants — remembers your codebase conventions, past architectural decisions, and why that one module is "don't touch."
- Research / reading companions — tracks what you've read, what ideas connect, what questions remain open.
- Multi-agent collaboration — each agent with its own memory store, sharing curated snapshots rather than raw context dumps.
Anywhere continuity matters and context windows aren't enough.
Integrating Memoir
Memoir is a library, not a product. ~15 lines of glue code and your AI has continuous memory.
from memoir.config import MemoirConfig
from memoir.core.loader import build_load_plan, render_context
from memoir.core.weight import mark_triggered
config = MemoirConfig.from_yaml("./my-memories/memoirs.yaml")
def context_for(user_input: str) -> str:
plan = build_load_plan(config.store_path, config, conversation_text=user_input)
for f in plan.files:
mark_triggered(config.store_path / f) # triggers boost weight over time
return render_context(plan, config.store_path)
Paste the output into your AI's system prompt. Works with OpenAI, DeepSeek, Claude API, or any custom client.
Full guide with chat API, Claude Code hooks, and append/search examples: INTEGRATION.md
Quick Start
pip install ksteam-memoir
memoir init --dir ./my-agent-memory
memoir create --title "Functional Programming" --domain code --tags "fp,patterns"
memoir search "immutability"
memoir trigger "I prefer pure functions"
memoir load --topics "code,philosophy" --trigger "functional programming"
memoir maintain --dry-run
memoir status
How It Works
Memory Files
Plain Markdown with YAML frontmatter. Nothing proprietary. Open in any editor.
---
name: functional-programming
weight: 4
tags: [code, fp, patterns]
domain: code
description: Why I prefer pure functions
created: 2026-05-20T12:00:00
---
# Functional Programming
Pure functions are easier to test and reason about.
## Log
- **2026-06-01** — encountered a case where recursion was cleaner than reduce.
Four-Layer Loading
When conversation starts, memoir determines what to load:
| Layer | Source | What |
|---|---|---|
| 1. Always | Core identity + w=5 | Never trimmed, always present |
| 2. Trigger Cascade | Curated concept→file tables | Keyword-activated associations |
| 2.5 FTS5 Fallback | SQLite full-text index | Semantic safety net when triggers miss |
| 3. Domain | Active domain indexes | Topic-relevant memory sets |
| 4. Weight | High-weight files | Proactive loading for warm memories |
Weight Lifecycle
Weights are not static:
- Active judgment — you decide a memory matters more (or less)
- Time decay — untouched for 60 days → weight drops. w=5 is immune
- Trigger boost — at 5, 15, 30 triggers → weight bumps by 1
Trigger Cascade (The Differentiator)
Not vector search. Curated association tables:
| #Concept | Keywords | → Files |
|---|---|---|
| fp | pure, immutab, side effect | code/functional-style.md |
| naming | rename, variable, function | code/naming-things.md |
When input contains "pure function" → #fp lights up → code/functional-style.md loads. Simple, inspectable, debuggable.
FTS5 Search Index
Built on SQLite FTS5 (zero extra dependencies). Supports full-text search with BM25 ranking, weight-range filtering, and tag intersection. Keyword triggers are the primary retrieval path; FTS5 catches what keywords miss.
memoir index # build/rebuild index
memoir search "clarity depth" # uses FTS5 when index available
memoir fts5-search "function" --weight-min 4 --tags "code,fp"
Compared to...
| Mem0 | ReMe | SMF | memoir | |
|---|---|---|---|---|
| Retrieval | Vector embedding | Markdown links | Filesystem | Trigger cascade + FTS5 |
| Lifecycle | Static | Static | Static | Weight evolution |
| Creation | Append-only | New files | New files | Continue-prior |
| Infrastructure | Vector DB | Files | Files | Files + YAML + SQLite |
| Philosophy | Retrieval-first | Retrieval-first | Structure-first | Evolution-first |
Philosophy
This framework was not designed on a whiteboard. It was not derived from a paper. It grew from a real system that a real person and a real AI used every day — arguing, joking, forgetting, remembering. The fog metaphor, the four-layer loading, the continue-prior instinct — all of it was discovered in the using before it was written in the spec.
It started with a drunk night on May 13, 2026. By May 20, it was on PyPI.
Read the full specification at specs/MEMOIR-SPEC.md.
License
MIT
Project details
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 ksteam_memoir-0.1.3.tar.gz.
File metadata
- Download URL: ksteam_memoir-0.1.3.tar.gz
- Upload date:
- Size: 39.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6f89883fcc91756600eb2c543070ab2c5b6f717e2d9a616e45fe0d252cfa597
|
|
| MD5 |
260e39d469ea070288d38b72143a839e
|
|
| BLAKE2b-256 |
5d1227b3e4781d5b143fa66f69cf5421a81eb1f7472646397b8c9ab0a10a7563
|
File details
Details for the file ksteam_memoir-0.1.3-py3-none-any.whl.
File metadata
- Download URL: ksteam_memoir-0.1.3-py3-none-any.whl
- Upload date:
- Size: 26.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.10
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e0c3e195e9906a7b88e3bef748ead776b35b0b8bea36b025ffb0c3ab71b10898
|
|
| MD5 |
5a158396bba819119089ced4348babb3
|
|
| BLAKE2b-256 |
222491fcd63702d56a2a9d1659dea073cfd2f592ff3f304fa222bc39f5a3df93
|