ResearchAGA-1111 min read

Read and write: how memory works in the brain, and how we engineer it into AI systems

By Luis Hasanaj · AI Gen AppsAugust 2026

Abstract

Memory is not a store but a read/write process — encode, consolidate, retrieve. This paper maps that architecture onto AI-native systems: the context window as working memory, vector and structured stores as long-term memory, embeddings as encoding, and retrieval as recall — and why designing memory first is what separates knowing a fact from having been trained on it.

The brain has no hard drive. Nothing in it works like a file written once and read back byte-for-byte; memory there is not a store but a process — a continuous cycle of writing and reading that reshapes what it touches every time. That distinction is not poetic. It is architectural, and getting it wrong is why so many AI systems either forget everything between turns or hallucinate facts they were never given. This paper is the companion to Brain blueprints of AI: where that one traced the whole history of intelligence, this one goes deep on a single faculty — memory — and how its read/write architecture maps onto the way we build AI-native systems.

The read/write memory loop
attendwritereadrecallNew experiencechannelWorking memoryagentConsolidatemodelLong-term memorystorageRetrieveengineGrounded responseendpoint

1. Memory is a read/write process, not a store

Biological memory runs in three movements: encoding turns an experience into a durable trace, consolidation stabilises that trace and files it against everything already known, and retrieval brings it back when a cue calls for it. The last movement is the surprising one. Retrieval is not playback; it is reconstruction. The brain rebuilds a memory from fragments each time it is recalled, which is why memories drift, and why a confident recollection can be wrong in specifics while right in gist.

An engineer should read that as a warning and a blueprint at once. A system that treats memory as reconstruction will, by default, confabulate — fill gaps with something plausible. The fix is not a better model; it is an architecture that grounds every reconstruction in a retrieved, verifiable record. Memory has to be read from somewhere real, not re-imagined.

2. Working memory is the context window

Working memory is the small, fast, volatile workspace where thinking actually happens. It holds only a handful of items at once — the classic estimate is famously low — and it is dominated by recency. In a transformer, the context window plays exactly this role: the attention mechanism is a working memory that weights what is currently in view, and what falls out of the window is, for that moment, simply gone.

Two consequences follow directly. First, working memory is the wrong place to keep anything you need to survive the turn — it is a scratchpad, not a record. Second, its capacity is a budget to be managed, not merely enlarged: stuffing a context window is the equivalent of trying to hold twelve things in mind at once, and attention degrades the same way ours does. The job of the rest of the architecture is to make sure the right few things are in that workspace at the right moment.

3. Long-term memory lives outside the weights

The durable store is not the model's parameters. Weights encode skill and generalisation — the slow-learned statistics of a domain — the way procedural and semantic knowledge is diffused across the neocortex. They are expensive to change, dangerous to change quickly, and the wrong place to put a fact that might be corrected tomorrow. Long-term memory in an AI-native system therefore lives in external, editable stores, split by the kind of memory they hold:

Memory typeIn the brainIn the system
EpisodicSpecific events, hippocampalVector store of embedded records and interactions
SemanticFacts and concepts, neocorticalStructured records, knowledge graph, tables
ProceduralSkills, basal gangliaTools, functions and workflows the agent can call

This separation is the single most useful idea in the paper. It is why retrieval fixes what fine-tuning cannot: a fact belongs in editable episodic or semantic memory, where it can be written once and corrected in place, not baked into weights where it can only be overwritten by more training. The same argument, from the representation side, runs through our transaction foundation model, which learns the statistics of transactions in its weights while the specific, queryable history stays in the store.

4. Writing: encoding and consolidation

Writing well is mostly about two decisions: how to encode, and what to keep.

Encoding is the translation of raw experience into a representation that can be matched later. In practice that is an embedding — a vector that places a record near others of similar meaning — which is exactly the encoding step our catalog enrichment pipeline performs before any of it becomes searchable. A memory encoded badly is a memory that can never be found, however faithfully it was stored.

Consolidation decides what survives. The brain does not persist everything; it replays and stabilises the salient, and lets the rest decay. A system needs the same discipline: write what is consequential, summarise what is bulky, deduplicate what is repetitive, and let low-value traces expire. Forgetting is not a failure of memory — it is what keeps retrieval sharp, the store affordable, and the signal from drowning in noise. An architecture with no forgetting policy is one whose recall gets slowly worse as it "remembers" more.

5. Reading: cue-based retrieval

Reading is triggered by a cue. In the brain, a partial pattern completes into a full one — the property that modern Hopfield-style associative memories formalise, and the reason a smell can return a whole scene. In a system, the current context is embedded into a query, and nearest-neighbour search over the store returns the records whose meaning is closest. Those records are lifted into working memory, and the model reasons over the union of what is present and what was recalled.

This is the load-bearing move for correctness. Because generation is reconstructive, the antidote to hallucination is to make retrieval the source of truth: the model composes an answer from retrieved records rather than from the fog of its parameters. Our multimodal shopping assistant is this pattern in production — it answers from the retailer's real, retrieved catalog, so it can only recommend products that exist. Retrieval is what turns a fluent guesser into a system that can be held to a record.

6. The architecture, as one loop

The diagram above is these movements drawn as a system. A new experience is attended in working memory; the consequential part is written — encoded and consolidated — into long-term memory; a later cue reads the relevant past back; and the response is grounded in what was recalled together with what is currently in view. The invariant is that nothing reaches the output except through memory: there is no path from question to answer that skips the store, because a path that skipped it would be a path with nothing to be right about.

Read and write are not phases that take turns, either. They run continuously and at once — every interaction is simultaneously a read (to ground the current response) and a potential write (to record what just happened). The pipeline is a snapshot of a loop that never stops turning.

7. Governing what gets written

A memory you can write to is a memory that can be poisoned, and a memory you can read from is a surface that can leak. The moment memory becomes editable, it becomes something that has to be governed: what was written, by whom, from what source, and who is allowed to read it back. Provenance is not an add-on to a memory system; it is part of the record. This is the same discipline we set out in Governed autonomy — every write and every recall is an event on an audit trail, so the store is not only useful but accountable.

Governed correctly, memory is also the durable advantage. Weights are a commodity that everyone can rent; the proprietary, compounding store of what your operation has seen and decided is not. Memory is where a system stops being generic and starts being yours.

8. What this changes in practice

Design memory first, model second. The instinct to reach for a bigger model is usually the instinct to avoid designing the store — and it is the expensive way to solve a retrieval problem. Separate the three memories and give each the right home: skill in the weights, events in the vector store, facts in structured records, skills-as-actions in tools. Make writing deliberate and forgetting explicit. Make reading the source of truth for anything that must be correct. And keep a provenance record of both, because a memory that cannot say where it came from is a memory you cannot trust with real work.

The brain settled these trade-offs across a very long time. Building with them, rather than against them, is most of what it means to give a system a memory worth the name.

9. References

None of this is a claim of neuroscientific novelty; it is an engineering reading of settled ideas. The load-bearing sources, in the order an architect should trust them:

  1. G. A. Miller, The Magical Number Seven, Plus or Minus Two, 1956 — working-memory capacity.
  2. E. Tulving, Episodic and Semantic Memory, 1972 — the episodic/semantic distinction.
  3. J. L. McClelland, B. L. McClelland & R. C. O'Reilly, Why there are complementary learning systems in the hippocampus and neocortex, 1995 — consolidation and complementary stores.
  4. L. R. Squire & E. R. Kandel, Memory: From Mind to Molecules — encoding, consolidation and retrieval.
  5. A. Vaswani et al., Attention Is All You Need, 2017 — attention as a working-memory mechanism.
  6. P. Lewis et al., Retrieval-Augmented Generation for Knowledge-Intensive NLP Tasks, 2020 — grounding generation in a retrieved store.
  7. H. Ramsauer et al., Hopfield Networks is All You Need, 2020 — modern associative memory and cue-based completion.

This paper is part of our Research. It is the memory-focused companion to Brain blueprints of AI; related engineering runs through the retrieval thread, from the transaction foundation model to the shopping assistant, and the full library lives at Research.

Related research

  1. August 2026 · Research
    Brain blueprints of AI: how neuroscience shaped the architecture of modern intelligent systems
  2. April 2026 · Research
    Quantitative signal discovery: a closed-loop multi-agent architecture
  3. February 2026 · Research
    Governed autonomy: approval lanes and audit trails in agentic systems
More in Research