2.9.0 · MIT · Python 3.11+
Long-term memory for AI agents.
brainctl lets an agent remember what it learned between sessions. It runs on your machine in one SQLite file, with no server, no API keys and no LLM calls.
For developers building agents in Python, or in Claude Desktop, Cursor or VS Code over MCP.
pip install brainctlRemembers across sessions
Facts, decisions and hand-off notes stay in brain.db, so the next run starts where the last one stopped.
Keeps one current copy
Repeated writes merge instead of piling up. When a fact changes, the new one replaces it and the old one stays in history.
Knows when it doesn’t know
A search can come back as not answerable instead of the closest wrong memory, so the agent asks rather than guesses.
Get started
Install it, then call it from Python, wire it into an MCP client, or use the shell. brain.db is created on first use.
from agentmemory import Brain
brain = Brain(agent_id="deploy-bot")
brain.remember("Prod DB is read-only on Fridays",
category="convention")
brain.search("can I migrate prod today"){
"mcpServers": {
"brainctl": { "command": "brainctl-mcp" }
}
}brainctl -a deploy-bot memory add \ "Prod DB is read-only on Fridays" -c convention brainctl -a deploy-bot search \ "can I migrate prod today" --abstain
The MCP server exposes 100 tools: core calls by name, 27 brain subsystems behind dispatchers. Add the config to Claude Desktop, Cursor or VS Code.
See it work
A real session against 2.9.0, trimmed: a fact changes, a duplicate arrives, and two questions come in.
$ brainctl memory add "Staging deploys run from the release/ branch via make ship" -c convention { "ok": true, "memory_id": 2, "write_tier": "full" } # the fact changes $ brainctl memory add "Staging deploys run from main via make ship-staging" -c convention --supersedes 2 { "memory_id": 3, "superseded": { "id": 2, "retired": true, "incumbent_tier": "ESTABLISHED" } } # another agent writes the same thing $ brainctl memory add "Staging deploys run from main via make ship-staging" -c convention { "deduplicated": true, "reinforced_memory_id": 3, "pattern_separation": { "decision": "reinforce", "similarity": 1.0 } } $ brainctl search "how do staging deploys run" --abstain { "answerable": true, "familiarity": 0.8638, "memories": [{ "id": 3, "content": "Staging deploys run from main via make ship-staging" }] } $ brainctl search "who owns the billing service" --abstain { "answerable": false, "familiarity": 0.0, "memories": [] }
Under the hood: a write
Each step reports back in the JSON the call returns.
- 01
Worthiness gate
Scores how surprising a write is. Low scores are skipped, middling ones are stored without indexing.
write_tier - 02
Pattern separation
Compares the write with its nearest neighbour and takes one of three branches.
reinforcea duplicatedistinct_froma near miss, linkednewstored
pattern_separation - 03
Supersede
A replaced fact with PII under 0.40 is retired and its validity closed. An entrenched one stays and has to win on recall.
superseded - 04
brain.db
Memories, events, entities and a knowledge graph in one SQLite file. Every memory carries valid_from and valid_to.
memory history - 05
Dream cycle
Offline replay strengthens co-active edges, prunes dead ones and writes bridge insights.
dream_cycle
And a read
- FTS5 + sqlite-vec
- RRF fusion
- Intent rerank
- Familiarity gate
answerableor abstain
Benchmarks
Committed baselines at default settings. CI fails on a retrieval drop over 2%.
| Suite | Metric | Result | n | Source |
|---|---|---|---|---|
| LongMemEval | hit@1 · hit@5 · MRR | 0.865 · 0.979 · 0.913 | 289 | longmemeval.json |
| LoCoMo | hit@1 · hit@5 · MRR | 0.375 · 0.613 · 0.479 | 1,982 | locomo.json |
| Abstention | AUROC · precision · recall | 0.996 · 1.00 · 0.69 | 30 | memory_abstention.json |
| Dedup | exact dupes caught · false merges | 1.00 · 0.00 | 32 | memory_dedup.json |
| Temporal | latest P@1 · stale in top 5 | 1.00 · 0.00 | 15 | memory_temporal.json |
Files live in tests/bench/baselines. Dedup counts exact and surface duplicates; paraphrases are not merged. Per-category results, method and caveats are on Benchmarks.