Skip to content
brainctl

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 brainctl
Quick start
  • Remembers 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.

python
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")
mcp · pip install 'brainctl[mcp]'
{
  "mcpServers": {
    "brainctl": { "command": "brainctl-mcp" }
  }
}
shell
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.

deploy-bot · brain.dbreal output, trimmed
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.

  1. 01

    Worthiness gate

    Scores how surprising a write is. Low scores are skipped, middling ones are stored without indexing.

    write_tier
  2. 02

    Pattern separation

    Compares the write with its nearest neighbour and takes one of three branches.

    • reinforcea duplicate
    • distinct_froma near miss, linked
    • newstored
    pattern_separation
  3. 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
  4. 04

    brain.db

    Memories, events, entities and a knowledge graph in one SQLite file. Every memory carries valid_from and valid_to.

    memory history
  5. 05

    Dream cycle

    Offline replay strengthens co-active edges, prunes dead ones and writes bridge insights.

    dream_cycle

And a read

  1. FTS5 + sqlite-vec
  2. RRF fusion
  3. Intent rerank
  4. Familiarity gate
  5. answerable or abstain

Benchmarks

Committed baselines at default settings. CI fails on a retrieval drop over 2%.

SuiteMetricResultnSource
LongMemEvalhit@1 · hit@5 · MRR0.865 · 0.979 · 0.913289longmemeval.json
LoCoMohit@1 · hit@5 · MRR0.375 · 0.613 · 0.4791,982locomo.json
AbstentionAUROC · precision · recall0.996 · 1.00 · 0.6930memory_abstention.json
Dedupexact dupes caught · false merges1.00 · 0.0032memory_dedup.json
Temporallatest P@1 · stale in top 51.00 · 0.0015memory_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.