← Building Memory for AI Coding Agents
06 / 06 Technical field note

The Science Behind It

How Borg's memory design maps cognitive science, record linkage, bitemporal modeling, and long-context attention research into a practical agent-memory system.

AI AgentsCognitive ScienceData ModelingLLM Engineering

This series has mostly talked about mechanisms: the pipeline, the single database, supersession, the benchmark. This final post is about where those mechanisms come from. Borg’s own framing is that its architecture is not an aesthetic choice but a response to how memory fails in LLM systems, grounded in cognitive science, information retrieval, temporal data management, and database design. None of the core ideas were invented from scratch. That grounding is the reason the design holds together rather than being a pile of features.

It helps to start with what Borg is reacting against.

Two approaches that don’t hold up

Naive RAG is the first. Vector search over raw conversation logs works fine in a demo and degrades sharply once conversations pile up across weeks and projects. Chunks are noisy, context-dependent, and go stale. The “we use Redis” chunk becomes harmful the moment the team moves to Postgres, and without supersession, decay, or trust signals, retrieval turns into contamination while the model stays confident.

Summarization chains are the second, and they fail the opposite way. Periodically summarizing the summaries is lossy compression that compounds. After a few passes you have clean, generic prose that sounds helpful but has shed the specific facts, edge cases, and decision rationale that matter during real work. The system gets more fluent and less useful.

Borg’s design is a direct answer to both failure modes, and four research ideas do most of that work.

Tulving: episodic and semantic memory are different things

Endel Tulving’s distinction, now foundational in cognitive psychology, separates episodic memory (the record of specific events, what happened and when) from semantic memory (general knowledge abstracted away from any single event).

Borg takes this literally. Conversations are episodic memory, the immutable evidence layer. Extracted facts are semantic memory, distilled and typed, each carrying provenance back to the episode it came from. The offline pipeline turns raw episodes into structured facts, procedures, and entities, which gives the system something it can compare, supersede, and rank, instead of treating an old conversation chunk as permanent truth. This split is also what makes the pipeline’s intent classification possible: there are genuinely different kinds of memory to choose between, so a debug task can lean episodic while an architecture task leans semantic.

Fellegi-Sunter: deciding when two records are the same entity

When you extract entities from conversation, you constantly face the question: is this “the webhook gateway” the same one from three sessions ago, or a different thing with a similar name? This is record linkage, and the Fellegi-Sunter model is its classic statistical framework, a principled way to score whether two records refer to the same real-world entity.

Borg’s three-pass resolution is built on that idea, with a deliberate bias: when resolution is uncertain, it keeps two references separate rather than merging the wrong things. The reasoning is asymmetric risk. A false merge poisons every downstream fact that touches the entity. A temporary split is inconvenient but recoverable. You can merge entities manually later; you can never safely un-merge them. The thresholds make this concrete, with a high semantic bar for an automatic match and a small ambiguity gap that flags uncertain cases for human review instead of guessing.

Bitemporal data: the model behind supersession

The temporal facts from post four aren’t a novel invention either. Bitemporal modeling is a mature database discipline that tracks two independent time axes, when something was true in the world and when the system recorded it. It’s how compliance and financial systems have answered “what did we believe on this date, and when did that change” for decades.

Supersession is bitemporal modeling applied to agent memory. Facts carry valid time and recording time, and move through a lifecycle of observed, current, superseded, or archived rather than flipping between true and false. Borrowing a discipline this well-worn is a feature, not a shortcut: the hard edge cases were solved long before Borg existed.

Lost in the Middle: why scoping and budgets matter

The “Lost in the Middle” research showed that long-context language models attend well to the start and end of their context and systematically neglect the middle. Dilute useful context with unrelated material and the model does worse, even when the right answer is technically present.

Borg’s response is to treat context as a scarce runtime resource rather than an infinite dump target. Memory is scoped by namespace before retrieval, so unrelated projects never crowd the window, and configurable per-namespace token budgets cap how much gets injected. Faceted retrieval across entities, facts, procedures, and snapshots, ranked under that budget, decides what earns a place. The benchmark backs this up: Borg’s advantage came with token counts comparable to RAG’s, so the win was what got included, not how much.

Why grounding matters

You could build a memory system by intuition, bolting on whatever seems helpful. The result tends to be brittle, because intuition doesn’t tell you where the edge cases are.

Borg’s bet is the opposite, and it states the bet directly: the systems that win at AI memory will treat it as data engineering, not vector search with better marketing. The episodic-semantic split, the record-linkage math, the bitemporal lifecycle, and the attention research are load-bearing, not decoration. Each is a place where a known, studied problem already had a known, studied answer, and the work was applying it correctly rather than rediscovering it the hard way.

That’s the whole series. Memory for a coding agent isn’t a search problem, it’s a compilation problem, and compiling well means standing on a few decades of work from people who figured out the hard parts first.


Part 6 of a 6-part series on building memory for AI coding agents. Thanks for reading.

Architecture depth + engineering leadership

Building platforms enterprises trust at scale.