R002 · Agent architecture › Memory and context

The 5 layers of agent memory

Read the original

agent-architectureagent-memorycontext-engineeringself-improving-agentsagent-governance

TL;DR

An agent improves across sessions only if it has a memory system with write paths, read paths and housekeeping, not just a bigger context window. Virdi splits that system into five layers: working, episodic, semantic, procedural, and a meta-memory control plane. Her core claim: "Context engineering decides what the model sees in this turn. Memory decides whether your agent compounds or rots."

The post's real value is its list of failure modes. Teams log traces and never read them back when planning. They pile up facts without resolving entities or contradictions. They hard-code prompts and never learn from failures. Nothing garbage-collects any of it.

Source: LinkedIn post by Shivani Virdi, published 2026-11-02, with an infographic credited to blog.neosage.io. There are no outbound links. This summary is based on the full post text, the infographic and the top comments, all read on 2026-11-03.

How the layers connect

Each turn reads three stores at planning and writes back to them afterwardmemory layerruntime stepread at planning timewritten after the turnUser inputWorking memoryLLM planningTool executionResponseEpisodicAppend-only tracesRead: similarity, time, scopeWrite: new trace, syncSemanticEntity store, typed factsRead: entity ID or similarityWrite: extraction job, asyncProceduralVersioned skill registryRead: task type or patternWrite: reflection, async batchMeta-memory: offline control plane under all four layersArchive, dedupe, deprecate, decay; runs on a schedule or when memory thresholds trip
agent memory stack · read and write paths per turn

Only the episodic write sits on the request path. Semantic extraction and procedural reflection run asynchronously, so facts and procedures trail the episodes they're distilled from. Every turn also pays for three planning-time reads. The post frames this as "episodes become facts and procedures; meta-memory keeps all of them clean."

Layers and how each one fails

Every layer fails the same way: the store exists, but the operation that keeps it useful is missing.

LayerWhat it holdsRead at planning byMissing op the post calls outSymptom
WorkingTurn buffer, tool calls, intermediate reasoning; capped by the context window; reset at session endAlready in contextA compaction policy (truncation, summarization, hierarchical pruning each lose different things)Dropped critical state or a blown token budget
EpisodicAppend-only, time-indexed traces of calls, results, errors, user stateSimilarity, time window, user scopeRetrieval at planning time (traces are logged only for debugging)Every session behaves like the first
SemanticEntity store: users, accounts, documents with typed attributesEntity ID or similarityDeduplication, entity resolution, contradiction handling during extractionRetrieval serves contradictory facts
ProceduralVersioned skill registry for recurring task patternsTask type or input patternA reflection loop that rewrites procedures from failures, plus versioningThe same mistakes repeat across sessions
MetaRetention, decay, compression and forgetting policies over the other fourNot read; runs offline, on a schedule or memory thresholdsArchive, dedupe, deprecate unused proceduresUnbounded growth, slower retrieval, stale entries win

The infographic maps each layer to a brain region (prefrontal cortex, hippocampus, anterior temporal lobe, basal ganglia with cerebellum, anterior prefrontal cortex). The mapping is a mnemonic, not a design argument.

What the model leaves out

The stack has write paths and garbage collection, but nothing that judges whether a write was correct or allowed. The strongest comments all point at that gap.

The post also doesn't cover cost and latency. It names three planning-time reads per turn and a synchronous trace append, but gives no budget for retrieval latency, extraction cost or storage growth.

Review checklist for an agent architecture

This is R002 in the research index, filed under Agent architecture › Memory and context.

Connections

See R002 on the knowledge map

Part of the Research notes on nowucca.com. Figures and claims are the source's own unless the summary says otherwise.