Agent Memory Architecture: Storage, Retrieval, and Control

An AI agent's memory spans working memory in the context window, external retrieval stores, episodic logs, and shared records. Here is how these layers fit together, when each applies, and how to keep the explicit project record that runtime memory cannot supply.

Updated 5 min read

An AI agent's memory is not one thing. It spans the context window that holds the current conversation, external databases the agent can query, logs of past episodes, and shared records that multiple agents read. Each layer serves a different purpose, has different limits, and is managed differently. Understanding which layer to use for which kind of information is the foundation of a reliable agent system.

Most discussions of agent memory focus on the technical layers — context windows, vector stores, key-value caches. What those layers do not reliably hold is the explicit, structured record of a project in motion: agreed decisions, active tasks, standing rules, and where things stand. A tool like fenbs fills that role: it is the project record layer that sits alongside the runtime memory architecture.

The four memory types

Agent memory research identifies four types, borrowed loosely from cognitive science. Each maps to a different use in AI systems:

  • **Working memory**: what the agent is actively reasoning over right now. In practice, the context window.
  • **Episodic memory**: records of specific past experiences — what happened in a previous session, what the agent tried and what the outcome was.
  • **Semantic memory**: general facts, knowledge, and relationships that do not belong to a specific episode — a domain vocabulary, a product catalog, a policy document.
  • **Procedural memory**: how to do things — the agent's skills, tool instructions, and behavioral patterns.

Working memory — the context window

The context window is an agent's working memory. Everything the agent needs for the current reasoning step must fit here: the conversation so far, the system prompt, any retrieved documents, tool results, and the user's message. The model can only "see" what is in the context window.

Context windows have grown significantly — modern models support hundreds of thousands of tokens — but size alone does not solve the problem. A large context still has limits, and a full context slows down inference. The useful principle is load what is needed, not everything that exists. That means having good retrieval from other layers.

What should always be in the context window at session start: the agent's role and constraints (system prompt), the most relevant current task, standing rules, and where things were left. These prime the agent before it takes any action.

External memory — retrieval and storage

External memory stores information outside the model and retrieves it on demand. Three patterns are common:

External memory patterns for agents
PatternWhat it storesHow it is retrievedBest for
Vector storeDocument chunks as embeddings.Semantic similarity search at query time.Large, relatively static document collections.
Key-value storeStructured facts with explicit keys.Exact lookup by key.Session state, user preferences, fast lookups.
Relational databaseStructured records with relationships.Queries on fields and relationships.Transactional data, reporting, complex relationships.
Explicit project recordDecisions, rules, tasks, progress, lessons.MCP tool call at session start.Project governance and handoff between sessions and agents.

The explicit project record is often the missing layer. Vector stores retrieve relevant passages; they do not reliably answer "what did the team decide?" or "what is the current task status?" A structured record with explicit decisions and tasks fills that gap. The agent memory vs RAG article covers the distinction in more depth.

How fenbs helps

The explicit project record layer

fenbs is the explicit project record in the memory hierarchy: decisions, rules, active tasks, Lessons, and Where we left off — stored outside any session, read at the start of each one. It does not replace a vector store or a database; it sits alongside them as the layer that holds what the team agreed on and what is happening right now. Create a free account and connect your AI from Integrations.

Create a free account

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

Episodic memory — recording what happened

Episodic memory records specific past events: a session log, the steps an agent took on a task, the outcome of a tool call. This is the layer that lets an agent or a team ask "what did we try?" and "did it work?"

Raw logs are one form of episodic memory, but they are often too detailed for a session's context window. The useful version is a distilled record: the task, what was attempted, what succeeded, what failed, and the next step. This is precisely what "Where we left off" captures in a project record.

For multi-session projects, episodic memory prevents repeated work. If an agent tried approach A and it failed, the next session should know that before it tries again. Recording failure modes as Lessons turns episodic memory into something the next agent can actually use.

Shared memory for multi-agent systems

When multiple agents work on the same project — different specialists, parallel tasks, or successive sessions — shared memory becomes essential. Without it, agents repeat each other's work, contradict each other's decisions, or lose track of what has already been tried.

Shared memory should have clear ownership rules: which agents can write, which can only read, and which writes require a human to sign off. In most project contexts, people decide and agents record — assistants can propose, but a person confirms decisions before they become standing rules.

In fenbs, Decisions and rules appear first in the AI context every connected agent reads. A rule recorded once applies to every agent on the project. Agents can record a person's decision but cannot decide themselves — that separation keeps the project's governance from drifting as agents change. The agent memory MCP article explains how agents access shared memory over MCP.

How to do this with fenbs

  1. Create a free account and add your project. Write the decisions and rules that every agent session should follow as Decisions and rules in fenbs.
  2. Use your existing vector store, database, or key-value store for the runtime memory the agent needs during a session.
  3. Connect your AI apps to fenbs over MCP from Integrations. At the start of each session, ask the agent to read the project context: rules, active tasks, and Where we left off.
  4. After each session, ask the agent to save a distilled progress note: what was done, what was checked, what comes next. This is the episodic record for the next session.
  5. When the project teaches something worth keeping, record it as a Lesson. When a decision is made or changed, update the Decisions record. Over time, the project record becomes the most reliable part of the memory architecture.

The what is agent memory article covers the foundational concepts. The how to build agent memory article goes into implementation details for specific storage patterns. The agent harness topic hub collects the full library of related guides.

Questions people ask.

What are the main types of agent memory?

Working memory (the active context window), episodic memory (records of past sessions and outcomes), semantic memory (general facts and documents), and procedural memory (skills and behavioral patterns). An explicit project record — decisions, rules, tasks, and progress — is often the missing layer in practice.

What is the difference between agent memory and RAG?

RAG retrieves relevant passages from documents using similarity search. Agent memory is broader: it includes the context window, retrieval stores, session logs, and the explicit project record. RAG is one part of the memory architecture, not all of it.

How do multiple agents share memory without contradicting each other?

Through a shared record with clear ownership rules: which agents can write, which can only read, and which writes require a human to confirm. Decisions that apply to all agents should be explicit and stored where every agent reads them at session start.

What should an agent load into its context window at session start?

At minimum: the agent's role and constraints, standing rules, the most relevant current task and its plan, and where things were left at the end of the last session. This primes the agent with the context it needs before it takes any action.

More in Agent harness (for developers)

All Agent harness (for developers) articles

Start with one thing.

Free for one person · No credit card · Works with Claude, ChatGPT, Cursor and more

There is nothing to set up first. Write one line and you’ve started.