← Back to Journal

One Brain, Many AgentsA reviewed memory shared by Claude Code, Codex and my other agents

I use several AI agents every day. For months each of them started every session knowing nothing about me. This is how I fixed that with one small, user-owned knowledge base — and the numbers after four months of real use.

Three panels: scattered notes, one shared knowledge base, several agents querying it
01 Each agent starts without context02 A reviewed shared brain03 Authorized access across agents

The problem is not model intelligence

My daily setup is Claude Code for implementation, Codex for review and acceptance checks, an orchestrator agent that runs scheduled jobs, and a chat bot on my phone. Each one is capable. None of them remembered that I had already decided which search engine to use, why a refactor was rejected last month, or that I want options presented as exactly five one-line choices.

Built-in "memory" features did not solve it. They are per-tool, they store whatever the chat happened to contain, and I could not audit or correct them. What I wanted was closer to a team wiki: one place, owned by me, that every agent reads from — and that no agent can quietly pollute.

The architecture is deliberately boring

The whole brain is a folder of Markdown files plus about 1,100 lines of Node.js. Its only runtime dependencies are the MCP SDK and zod.

Hybrid search, with recency set to zero

Search is a weighted mix: keyword overlap ×2, lexical similarity ×6, vector similarity ×12, knowledge-graph proximity ×3 and source trust ×2, plus small title and path boosts. Vectors come from bge-m3 running locally in Ollama, so nothing leaves the machine. If Ollama is down, a circuit breaker drops the vector term after three failures for 60 seconds and search keeps working on the other signals.

The weight I am proudest of is the one set to zero: recency. A file's modified time is not the date a decision became valid. Instead, notes carry explicit validFrom / validUntil dates and supersedes / contradictedBy links, and agents can ask for temporal=current or a historical asOf date. "Newest file wins" caused real wrong answers before this.

Agents can propose, never publish

This is the part that made the brain trustworthy. brain_remember never edits the wiki. It drops a candidate into an inbox. A separate review step then decides:

Across more than 1,100 recorded review decisions: 345 auto-approved, 408 approved by a person, 169 rejected, 100 merged into existing notes, 83 turned into updates, and 5 deleted. Roughly one candidate in seven was rejected — exactly the noise that would otherwise have become "memory."

I am honest about the limit: the rules about what may be stored are routing policy for the agents, not file-level permission isolation. The filter enforces the dangerous categories in code; the rest relies on the agents following instructions and on review.

Answers must admit when they don't know

Every search returns an evidence label. insufficient means the agent must say there is no record instead of guessing. conflicting means it must show both sources and let me choose. retrieved means "candidate only" — the agent has to open the full note with brain_get before relying on a specific claim.

Deciding "was anything actually found?" turned out to be subtle. A hybrid total score always produces a winner, because ranking is relative. So the gate uses the absolute vector score: a hit counts if the top similarity is at least 0.55, or at least 0.50 with a clear lead over the runner-up. In my logs, real hits sit around 0.60–0.73 and misses around 0.45–0.47.

The numbers after four months

Mistakes that taught me the most

My "semantic" search had no vectors. A function named semanticScore() was doing string overlap. The embedding model was configured but never called. Measuring fixed it: on a test query, content vectors scored 0.568 for the right note versus 0.469 for a distractor, while title-only vectors could barely separate them (0.433 vs 0.370). Embed the content, not just the titles.

I blamed the wrong thing for token cost. I assumed having many MCP servers connected was expensive. Measuring one 82k-token session showed messages were about 73% of it, while fixed overhead (tools, skills, memory, system prompt) was about 22k and paid once. Deferred tool definitions did not count at all. The real cost was oversized search replies that got re-read every turn. Trimming one search response from over 9,000 bytes to about 1,560 (and the default result count from 8 to 4) did more than disconnecting anything. Separate "paid every turn" from "paid once."

The review queue silently filled up. The code that explained an approval and the code that granted it used different confidence thresholds, so qualifying items were held forever with a plausible-looking reason.

The safety filter rejected good notes. It matched words like "session" in the file name rather than the content, so legitimate know-how about session handling was stuck. Filters need tests on false positives, not just false negatives.

The pipeline captured heartbeats, not knowledge. Early on, agents logged that they had run, not what they had learned. The rule now: after solving and verifying a real problem, submit the root cause, the verified fix, the failed attempts and the source — never the whole conversation.

If you want to build one

  1. Start with Markdown and one MCP server. Every agent you add later gets the brain for free.
  2. Make writes go through review. An agent that can write straight into memory will eventually write something wrong with full confidence.
  3. Track validity explicitly; never let file dates decide which decision is current.
  4. Return an evidence label with every answer, and make "no record" an acceptable answer.
  5. Log misses. The 8.8% of empty searches is my best list of what to write next.

None of this needs a vector database, a cloud account or a framework. It needs a boundary: the person owns the memory, agents borrow it.

Shared MemoryMCPClaude CodeCodexKnowledge Management