honeyground / local brain

A LOCAL MEMORY FOR CODING AGENTS

A memory
of your own.

Your memory. Your stack.
Combine vector recall and graph connections. Change the engines, keep the knowledge.

Open source · Apache-2.0 · Free for everyone

FIG. 01 / THE MEMORY FIELD
SELECT A MEMORY TO RECALL↙
PRIVATE BY DEFAULT. USEFUL BY CONTEXT.SCROLL TO CONNECT ↓

A new session.
The same you.

A model brings intelligence. You bring the history. Local Brain connects your memory files, project docs and notes through adapters, so the context you built can return across sessions.

Agent alone

Agent + Local Brain

Session 01 → 05 · Starting context across sessions. Conceptual illustration, not a performance benchmark.

01

Keep what matters.

Decisions, notes, and lessons stay in your files. A local index connects the pieces.

NOTES → LOCAL INDEX
02

Recall in the moment.

Host hooks surface relevant memories as you type. Guidance returns before matching risky actions.

CONTEXT → ACTION
03

Learn what works.

Calibrate against your own corpus. Compare retrieval with grep and the agent working alone.

MEASURE → CALIBRATE

Memory, right when
it matters.

Three illustrative terminal scenes: automatic recall, an exact trigger phrase, and guidance before a risky action. Example memories, not a live agent.

agent sessionLOCAL BRAIN

Let’s continue the payments refactor.

Related memories, found automatically

memories / payments.md

Phase 2 stopped at the webhook retry. Tests live in tests/payments.

memories / idempotency.md

Every retry carries an idempotency key.

01

As you type

A host hook reads your prompt and attaches only memories above your corpus’s retrieval threshold.

02

Trigger phrase

Declare a phrase in a memory’s front matter. Type it to bring that context back directly, without a relevance score.

03

Before an action

Your guidance appears before push, rebase or migration. Discover rules from your own tool history.

brain rules --discover

And when the agent asks: twelve MCP tools.

recallrememberneighborsbrain_statusbrain_suggestbrain_feedbackreindextimelinebrain_analysebrain_viewmemory_historybrain_capabilities

Facts change.
Brain keeps the history.

An address, a preference or a technical decision can change. When your agent records a revision—what it replaces, when it takes effect, why, and the evidence—recall answers with the current fact, and every earlier version stays in history.

topic release · facet branch

recall("Where do releases ship from?")

  1. valid_from 2025-09-01
    release_branch

    Releases ship from the release branch.

    matched the questionreplaced
  2. valid_from 2026-06-15
    release_main_tags

    Releases ship from main, one tag per version.

    Reason
    Moved to trunk-based development
    Evidence
    Agreed in the June release review
    replacedin effect on that date
  3. valid_from 2026-11-01
    release_main_ci

    Releases ship from main; CI publishes each tag.

    Reason
    Publishing moved to CI
    Evidence
    Confirmed by the user on November 1
    current answer

The question matched the oldest wording. Recall followed both recorded replacements and answered with the current fact.

Every revision with its status, effective date, reason and evidence. Nothing was overwritten.

as_of returns the explicit record in effect on that date. It is effective-time history, not a replay of what the system knew back then.

Illustrative example records. Not a live agent.

memory_history returns the same chain by old or current name: revisions, dates, reasons, evidence and bounded diffs, plus snapshots of the file observed each time it was indexed.

recallview="history"as_ofmemory_history
01

No newest-wins.

When one fact has several active records that are not linked as revisions, Brain marks them disputed instead of picking the latest. Disputed facts stay available for explicit lookup and are kept out of automatic hook output.

disputed
02

Retire without deleting.

Retracting or archiving a fact is itself a revision, with a date and evidence. It leaves current answers without reviving an older version. The files remain in history; nothing is deleted automatically.

retracted · archived
03

Safe with many writers.

Updates through Brain need the SHA last read. A stale writer gets a conflict instead of overwriting, a repeated identical save is a no-op, and file replacement is atomic. recall and remember return JSON by default.

expected_sha · noop
04

The agent records. Brain resolves.

Existing notes start untracked, not certified current. Brain does not infer contradictions on its own: the writing agent confirms the change and records the relation. No personal note is silently rewritten.

supersedes · valid_from

One memory.
Your choice of engines.

The core stays the same. Hosts, AI engines, sources, databases and schedulers plug in around it. Vector search and graph traversal work together — Qdrant + Neo4j is a combined setup, not an either/or choice.

Vector database

Qdrant

Similarity search

Chroma · pgvector · Milvus

Graph database

Neo4j

Connected context

Memgraph
01Agent host
Claude Code · Codex · Any MCP client
02AI engine · optional
Gemini · OpenAI · Anthropic · Google EmbeddingGemma (local) · OpenAI-compatible servers (including local Ollama), or no AI engine
03Data sources
Memory files · project docs · Obsidian / wikis · any folder brain add
04Vector database
Built-in local copy (SQLite, default) · Qdrant · Chroma · pgvector · Milvus
05Graph database
Built-in local copy (SQLite, default) · Neo4j · Memgraph
06Scheduler
launchd · cron

Swap the databases.
Keep your data.

Memories remain plain Markdown files. The built-in local copy is canonical; dedicated databases are serving indexes. Switching means syncing, not re-embedding. A ledger sends only changes. Before sync, or if a database is unavailable, the local copy answers.

Ask both stores the same questions and verify matching answers. Move your memory between machines with brain export / brain import.

brain stores --checkbrain exportbrain import

MEASURED · AUTHOR’S CORPUS · 2026-10-07

Similarity search · Qdrant

188ms→12ms

All-document, one-hop neighbors · Neo4j

3.4s→0.48s

1,909 documents · 9,590 chunks · 3,376 links. Matching answers on every compared query. These are corpus-specific measurements, not promised speeds for your setup.

README ↗
127.0.0.1

Bring up both databases with Docker.

Install by role with pinned images. Ports bind only to 127.0.0.1. Data lives in ordinary folders under the brain home, not Docker volumes, and survives reinstalling. Database usage reporting is disabled and verified by measurement.

./install.sh --stores dockerbrain stores --docker

More of its numbers.
More of you.

Your notes, feedback and tool history shape how memory returns. Local Brain measures and adjusts from your evidence, with checks before changes—not a promise that every session performs better.

YOUR DATA↻

Interactive illustration of the adaptation loop. Select a step. No live learning, personal data or performance measurements in this demo.

Start with your corpus.

The hook threshold is your corpus’s noise floor × a margin learned from your samples. Short prompts (the shortest 30% of yours), filename-prefix types and corpus language are measured from your data.

brain calibrate

Update only with evidence.

The margin starts at 1.35 with broad uncertainty. Each calibration resamples your data 200 times; a one-dimensional Kalman filter weights the observation by confidence. Until three rounds of new evidence accumulate, it only measures. A regression guard rejects worse thresholds. If the corpus is too small to measure, it stays quiet rather than guessing.

brain calibrate

Your feedback changes the next ranking.

Mark a memory useful, wrong or stale. That feedback changes its next ranking; negative feedback also lowers its semantic priority and how readily the hook lets it through. It is a retrieval preference, not a factual retraction. Send it through the CLI or the brain_feedback MCP tool.

brain feedback <name> useful|wrong|stale

Rules grow out of your work.

No rules ship by default. Discovery finds candidates in your tool history; --auto promotes candidates that pass the threshold. The wording lives in your memory files. Edit the memory, change the guidance.

brain rules --discover
brain rules --auto

Automatic personalisation is built in. Corpus calibration, learned vocabulary, feedback-based ranking and a background policy-selection loop are part of Brain. Serving advanced candidate policies remains opt-in.

Find what deserves a place.

detect finds memory candidates with evidence; --add registers them. suggest proposes cleanup for stale, orphaned or duplicate memories.

brain detect --add · brain suggest

You own the numbers.

Who sets a number? You, your data, your host or engine, then the method. A value measured on someone else’s notes is not your optimum. Compare your own points in time with score --history and --axes.

brain score --history · brain score --axes

Take your memory with you.

Export and import move your memory. Calibration values are deliberately excluded: the new corpus should be measured again.

brain export · brain import

Look inside.
Measure everything.

01

Calibrated to your corpus

Retrieval thresholds are measured on your documents. A Kalman filter learns the safety margin as feedback accumulates.

Kalman
02

A comparison, not a promise

Compare accuracy, recall, text read and speed against grep and an agent alone. Every test runs the controls first.

brain score --compare
03

Private at the core

Lexical search opens no sockets. AI engines are opt-in. Secret-shaped values are masked before they can become context.

brain privacy
04

Twelve tools. Updated context.

On macOS and Linux, the MCP server reloads changed code and configuration before the next request. Reconnect clients to refresh cached tool descriptions. On Windows, restart the MCP client.

MCP
05

A small, inspectable core

Zero third-party dependencies in the core. Python 3.8+ standard library. Add engines and dedicated databases only when you need them.

Python 3.8+
06

See how it is doing

An HTML dashboard shows status and performance comparisons. Six interface languages. Your memories travel with export and import.

Your language, passed to your host.

MCP initialization, recall/remember descriptions and hook context share one language preference. Explicit conversation requests come first, then response_language and other configured preferences, then the latest message’s language. auto follows the conversation. This instructs the host; it does not guarantee its reply. Original text and quotations keep their language.

brain dashboard · response_language

EVENT-DRIVEN INDEXING

Twenty sessions open.
One quiet worker.

A session start indexes nothing by itself. It checks for events that need work—a changed source, pending work, a moved repository, a ruler that no longer fits the corpus—and only then starts one detached worker, which does that work once for every open session.

Before · per session

≈1min

Now · all twenty together

≈1s

CPU time for twenty sessions opening together when nothing changed, as stated in the Local Brain README. Previously each session ran a full index and recalibration.

Long documents, all the way through.

Indexing no longer stops at twelve chunks. Completed chunks survive interruption; the next build fills the gaps. Only changed chunks need re-embedding.

brain vec build

Earlier work, remembered.
This task, finished.

Cosmos Orbit is an open-source local companion for Claude Code and Codex CLI. Local Brain supplies relevant knowledge from earlier work; Orbit tracks what the current task still needs to finish. Either one also works on its own.

Memory from earlier work

Local Brain

  • Brings back decisions, lessons and guidance from earlier sessions.
  • Follows recorded revisions to the current version of a fact.
  • Keeps your memory in plain Markdown files on your machine.

Keeps the current task on course

Cosmos Orbit

  • Carries the original goal, your corrections and next steps through compaction and session handoffs.
  • Runs completion checks and an independent review before marking work verified.
  • Picks up unfinished work from a durable task ledger and checkpoints.

The next session
starts here.

Open source. Apache-2.0. Free for everyone.
Read the code, make it yours, build on it.

01

Start entirely local

Clone, then install recall hooks and the action guard. Or give SETUP-PROMPT.md to your agent and let it guide installation.

TERMINAL / PYTHON 3.8+
git clone https://github.com/honeyground-org/local-brain ~/tools/local-brain
cd ~/tools/local-brain && ./install.sh --with-hook --with-guard
02

Connect both databases

Optional: install Qdrant for vectors and Neo4j for graph connections together with Docker. An existing install can use brain stores --docker.

TERMINAL / PYTHON 3.8+
./install.sh --all --stores docker
03

Choose an embedding engine

Optional: run Google embeddinggemma-300m on your computer. Prepare the separate Python runtime, start its local service and place its manifest in the Brain home, then select it explicitly below. Brain calls it directly; failure does not fall back to a paid provider or silently change your engine. The core stays standard-library Python.

Prepare the local runtime ↗
TERMINAL / PYTHON 3.8+
brain engines --set embed=embeddinggemma --model google/embeddinggemma-300m --base-url http://127.0.0.1:18081/v1
brain vec build
brain vec calibrate