one-brain: I Built a pgvector RAG That Remembers So I Don't Have To — Part 1
A controlled measurement of what a coding agent's memory actually buys: re-deriving what it already knew cost more than storing the entire accumulated corpus, and a quarter of it couldn't be recovered at any price.
Every session starts from zero. A coding agent re-reads the same files, re-derives the same infrastructure history, and wastes real minutes rebuilding conclusions it already reached last week — while you wait for it to catch back up to context it should already own. The failure isn’t just repetition, either: when the agent doesn’t know a fact, it doesn’t know it’s missing one, and it confidently proceeds on a wrong assumption until someone catches it. Worse still, a few of the facts it needs were never written down anywhere searchable — once the conversation that produced them ends, that knowledge is gone at any price. I built one-brain, a Postgres + pgvector retrieval system, to fix that — and this piece measures what it actually bought, from a controlled experiment, instead of asserting it.
This is Part 1, and it covers the retrieval half: what forgetting costs, and the design that fell out of measuring it — one shared store, vectors alongside keywords, entries capped small enough to be worth injecting. That gets you similar memories. What it can’t do is follow a thread: this outage was caused by that config change, which was decided in a conversation nobody wrote down. Part 2 covers the graph layer I’m building next, where memories link to each other and a question can walk those links instead of only landing near them.
Someone wrote the answer into a committed document. Every question here was recoverable — the cost is just the price of finding and reading the right file.
GLOBAL a standing rule true of every codebase (which shell, how to handle version control, when to commit) · PROJECT true of this codebase alone. Scope and cost don't correlate — tier 3's one global fact is also its cheapest.
Twelve facts, one honest question
The setup was simple: take twelve facts one-brain already held, and see what it would cost to rediscover each one from primary sources instead — the repository, git history, the web, nothing else. Independent agents did the digging, with every character read tallied as they worked. No memory tool, no shortcuts, no peeking at the answer.
The twelve split into three tiers, chosen before any measurement started. Tier one is what’s stated plainly in a committed document — cheap to recover, because someone already wrote it down. Tier two is infrastructure history that has to be synthesized across commits and docs rather than just read. Tier three is decisions and live-system state — the kind of thing nobody opens a design doc to record. The grid above shows all twelve; the cost climbs from tier to tier, and the top tier is where spending stops working entirely.
What you stop re-explaining
Some of what a memory system buys back has nothing to do with facts at all — it’s standing preferences. Around sixteen rules (which shell to use, which version-control tooling, when to commit and push, how to format output) otherwise get re-stated at the start of every session, or worse, never get re-stated and just get silently violated again. Re-typing them costs almost nothing — about 645 characters, roughly 160 tokens, genuinely trivial. The real cost isn’t tokens; it’s that the agent doesn’t know it’s wrong until you catch it, and every catch is your attention and a redo. Stored once and applied permanently, that failure mode disappears — not because it got cheaper to state, but because it stopped needing to be stated at all.
Three that vanished entirely
The nine recoverable facts share one thing in common: someone had written each of them into a committed document at some point, even if it took real digging to find. The three that came back empty share a different thing — they were never documents at all. A production incident’s root cause. A purchasing decision, and specifically why it deviated from the original plan. A local-environment diagnosis about which tool was causing an observed quirk. All three were decided or discovered in conversation, while doing the work, and never transcribed anywhere a later search could reach.
That’s not a documentation failure in the usual sense — the documentation that exists works exactly as intended, everywhere it was applied. It’s just that nobody opens a design doc to record why they picked one payment plan over another, or what actually caused an outage at 2am. A memory system captures that kind of thing as a byproduct of doing the work; documentation only ever captures what someone consciously decided to write down.
Took it as given that a persistent shared memory system was making sessions faster and less repetitive — it felt obviously true after weeks of using one.
That feeling wasn't backed by a single measurement. Nothing had ever counted what the alternative — rediscovering the same facts from scratch — actually cost.
A feeling this confident deserved a number, not another anecdote.
Storage costs less than remembering
Here’s the cleanest comparison in the whole experiment. Re-deriving the twelve facts cost about 102,900 characters — roughly 25,700 tokens — across fifty tool calls. The entire stored corpus behind those facts — every incident, every cost breakdown, every convention, accumulated over 101 days — comes to 46,064 characters, about 11,500 tokens. Rediscovering twelve facts costs roughly 2.2 times more than storing the whole twenty-two-entry corpus that answers them, and everything else besides. Remembering scales; re-deriving doesn’t.
Failure isn’t free
Rediscovery doesn’t just cost more when it works — it bills you even when it fails. About 22% of the cold-arm spend, roughly 5,600 tokens, went toward the three questions that came back empty. A memory system doesn’t have this failure mode: a lookup that finds nothing costs nothing to store in the first place. Rediscovery pays for its own misses; recall doesn’t.
The design this pointed to
None of this requires anything exotic, and the shape I settled on for one-brain is three deliberate pieces working together. Every agent session writes into, and reads from, one shared store rather than a private scratchpad. A retrieval path injects a small amount of relevant context automatically on every turn, so the agent doesn’t have to know to ask. And because what gets injected is only ever a short preview, a compression step caps how large any single entry is allowed to get on the way in.
Each of those three was a decision with an alternative I rejected, and the rest of this section is what the measurements pushed me toward on the two that turned out to matter most: how much to store per entry, and how to know whether any of it was working.
Cap what you store
The corpus in this experiment averaged about 2,094 characters per entry — but the hook that injects context only ever surfaces a roughly 250-character truncated preview per entry. That means most of what’s stored is never actually read unless something triggers a second, full lookup. The fix is structural, not behavioral: cap entries small on write — around 500 characters is a reasonable target — ideally by having a cheap model compress the entry down at write time. Do that, and the preview stops being a teaser for content that mostly goes unread; the preview becomes the payload. One thing worth watching for: a cap enforced by silent truncation looks identical to one enforced by compression from the outside — both just produce a shorter entry — so it’s worth actually checking which one you built.
Picking what does that compression took its own small experiment: twenty candidate models, the same five real entries, judged on three axes — factual accuracy, whether the note stayed actionable months later, and how well it worked as a search target — rather than one score. The winner was small, cheap, and fast: roughly thirty times cheaper than the mid-tier model it replaced, well under a second per call, never over the cap. The reason to mention it at all: one model tied the winner on the obvious metric, the fraction of identifiers preserved, while quietly inverting a fact — stating the opposite of the source, fluently, identifiers intact — and only a separate accuracy check caught it.
Instrument on day one
Retrieval systems are unusually easy to fool yourself about. When a lookup returns something useful, you notice and feel like the system is working. When it returns nothing — or returns the wrong thing — you often don’t notice at all, because absence doesn’t announce itself. The only fix is recording every retrieval as it happens: when it ran, what was asked, how many results came back, whether anything cleared a relevance threshold, and how much text was actually returned. None of that can be reconstructed after the fact from history that was never logged in the first place — it has to be built in from the start, not bolted on once you notice it’s missing.
That instrumentation went in, and within two days of live traffic it had already produced a real number: of 46 recall calls, 71.7% came back with at least one result. But instrumentation is necessary and not sufficient. Building it was right — it produced a number where there had been none. The first number it produced was still misread, confidently, for a full day, because two values that were never comparable were printed side by side and looked like they belonged together. The fix that mattered wasn’t making the number correct; it was changing the output so the comparison a reader naturally attempts is either valid or obviously invalid. A metric you cannot misread beats a metric that is merely accurate.
Compounding, stated calmly
The corpus only ever accrues forward. One of the purchasing decisions behind these numbers was 34 days old and already completely unrecoverable by the time anyone went looking for it. That’s not a reason to panic about the facts you haven’t captured yet — it’s just an observation about how the curve works. Starting later doesn’t cost you the capability; a memory system started today captures everything from today forward exactly as well as one started a year ago. What starting later costs you is the backlog, and that part of the cost is permanent — every day without a place to record things is a day that becomes as unrecoverable as the last one, quietly, whether or not anyone notices at the time.
A short note on method
This is a demonstration with real numbers, not a peer-reviewed study — twelve facts is a small sample. Character counts stand in for tokens at roughly four characters per token, which is a proxy, not an exact conversion. The cold-arm agents were competent but not exhaustive; a more persistent search might have recovered a little more, a less capable one less — though the three unrecoverable facts are robust to that, since the information is provably absent from the source material, not just hard to find. And this experiment itself says nothing about hit rate — recall was stateless when it ran, which is exactly the instrumentation gap the second design lesson above is about. Instrumentation shipped afterward, and a small later sample (46 calls over two days, not part of this controlled run) is what the previous section draws on; it only supports a “returned a result” rate, not a claim about retrieval quality, and should be treated as an early read, not a settled number. It also says nothing about per-person contribution — the system measured is single-identity, so every number here is about a shared corpus, not about who on a team contributed what.