← Wiki

Agent Memory Architecture

AI agents forget everything between sessions. Context windows are finite. RAG retrieves documents but doesn’t capture decisions, preferences, or evolving relationships. This is the core problem of agent memory, and several mature approaches now exist to solve it.

This post synthesizes patterns from five memory-focused systems I’ve built or studied: SGR Agents spec (the cognitive foundation), Moltis, OpenClaw Workspace Memory, MemPalace, and Solograph. Each takes a different approach. Together they map the full design space.


The Four Types of Memory

Every agent memory system worth studying converges on the same cognitive taxonomy, mirroring how human cognition organizes knowledge (Generative Agents, Stanford 2023). Names vary, but functions stay consistent:

1. Working Memory (short-term)

The agent’s scratchpad during a task: messages, intermediate results, current plan. Cleared or archived when the task completes.

Key insight: Working memory should be structured, not a raw conversation log. The SGR approach (reasoning/planning/function as explicit JSON fields) makes the agent’s thought process inspectable and debuggable. This aligns with harness engineering: agent logic should be transparent.

2. Semantic Memory (long-term facts)

Durable knowledge about the world, the user, the domain. Timeless or slowly changing. Retrieved by similarity or entity lookup.

Key insight: Structure beats embeddings for retrieval. MemPalace’s spatial hierarchy (wing > room > hall) improves recall by 34% over flat vector search. Solograph dropped embeddings for plain FTS5 (measured below). But a simple dict in the system prompt works fine to start (SGR v1 approach).

3. Episodic Memory (experience log)

What happened, when, in what order. Decision history, interaction logs, past results. Time-bound and growing. Context graphs call these “decision traces.”

Key insight: Episodic ≠ semantic. Episodic is time-ordered (event sequence), semantic is timeless (generalized fact). The OpenClaw ## Retain pattern extracts narrative facts from the raw log, tags with type + entities + confidence. Decision traces compound: each captured trajectory improves future retrieval.

4. Procedural Memory (how-to)

Methods, templates, algorithms, workflows. “How to do X” rather than “what X is.”

Key insight: Procedural memory is the most undervalued type. A well-defined workflow template multiplies consistency. CLI-first design makes procedural knowledge testable. Schemas first, logic second applies here too: define the procedure schema before implementing.


Three Operational Loops

Capture → Retrieve → Apply (Context Graphs pattern)

From Foundation Capital’s context graphs thesis:

  1. Capture — record agent decisions into a graph (what + why)
  2. Retrieve — before new task, search for similar precedents
  3. Apply — adapt found patterns to current situation

Each successful action improves future ones, creating a compound learning flywheel. Implemented in Solograph: session_search for precedent retrieval, kb_search for pattern matching, symbol_search for code that already exists.

Retain → Recall → Reflect (OpenClaw/Hindsight pattern)

Blending Letta/MemGPT control loop with Hindsight memory substrate:

  1. Retain — normalize raw logs into narrative, self-contained facts with type tags (W world, B experience, O opinion) and entity mentions (@Peter, @ProjectX)
  2. Recall — queries over derived index: lexical (FTS5), entity-centric, temporal, opinion-with-confidence
  3. Reflect — scheduled job that updates entity pages, adjusts opinion confidence based on reinforcement/contradiction, proposes edits to core memory

Opinion evolution: each belief has statement + confidence c ∈ [0,1] + evidence links. New facts update confidence by small deltas; big jumps require strong repeated contradiction.

Retrieve → Reflect → Plan (Generative Agents pattern)

Stanford’s Generative Agents introduced the three-layer cognitive architecture:

  1. Retrieve — score memories by recency × relevance × importance
  2. Reflect — periodically synthesize observations into higher-level insights (“What are the top 3 things I’ve learned about X?”)
  3. Plan — create day/hour plans grounded in reflections and current goals

This is the most research-validated loop. The paper showed it produces believable long-term agent behavior across 25 interacting agents.

Our own write path is new and still being broken in (November 2026): agents write decisions, findings and handoffs back through solograph’s capture tool, one append-only inbox note each, and a nightly job reads the usage logs for repeated and empty searches. See company-brain.


Forgetting: The Half-Life Problem

Not all memories should persist forever. Decisions expire as policies change, teams change, and context shifts. Context graphs call this the “half-life of decisions.”

Approaches to Forgetting

System Mechanism
MemPalace Knowledge graph with valid_from / ended dates. kg.invalidate() marks facts as expired
OpenClaw Opinion confidence decay. Contradicting evidence reduces c score. Reflect job proposes removal
Moltis Session auto-cleanup by age/count limits. Embedding cache LRU eviction
Generative Agents Recency score decays exponentially. Old memories naturally rank lower in retrieval
SuCo Summarize-Condense-Distill: compress old memories into summaries, discard originals

Key insight: Active forgetting > passive accumulation. Without decay, memory becomes noise. The simplest implementation: valid_from/ended timestamps on every fact, with periodic cleanup. Agent self-discipline applies here. Thresholds and limits prevent memory bloat.


Trust Hierarchy: Not All Memory is Equal

A common failure mode: the agent “remembers something” but you can’t tell if it’s trustworthy. Memory systems that treat everything as equal (recent chat, old decisions, daily notes, canonical specs) produce agents that confidently cite stale or wrong information.

The Zero Harness approach introduces an explicit trust hierarchy for memory:

Layer Trust Level Example Update Frequency
Source of truth Canonical source_of_truth.md, schemas, configs Rarely, deliberately
Handoff High handoff.md (current state, decisions, blockers) Every session end
Daily notes Medium Daily log, task notes, runtime snapshots Daily
Memory entries Variable Structured facts, observations Ongoing
Chat history Low Raw conversation, ephemeral context Per session

Source of truth > volume. The agent knowing which file is canonical matters more than remembering everything. When memory contradicts source of truth, source of truth wins.

Handoff as save game. Not abstract “long-term memory” but a short, living file that captures: what’s happening now, what decisions were made, what’s broken, what’s left to do, which files are load-bearing. Like a game save point. OpenClaw’s ## Retain section, GSD-2’s .gsd/STATE.md, and Claude Code’s session summaries all implement this pattern.

Memory should help act, not just recall. Useful memory units aren’t just facts but actionable artifacts: task notes, daily plans, fixed decisions, integration statuses, runtime snapshots, environment self-maps. Good agent memory is an operational surface you act from, not a museum of recollections.

This connects to harness engineering: the harness defines which artifacts are source of truth (CLAUDE.md, schemas, tests), and the memory system respects that hierarchy.


Lexical-First Retrieval

Most agent memory systems default to vector/semantic search. In practice, engineering queries are exact and operational: “what did we decide about heartbeat?”, “where is the runtime snapshot?”, “which cron is failing?”, “what file is canonical?”

For these, lexical search (BM25/FTS5) outperforms embeddings:

Practical stack as systems commonly layer it, ordered by reliability (the author’s own measured choice is only the first layer, see below):

  1. Lexical first (BM25 / FTS5): exact names, identifiers, operational queries
  2. Graph queries (Cypher / FalkorDB; others use it, the author dropped it): relationships, dependencies, cross-references
  3. Vector search (embeddings; others use it, the author dropped it): conceptual similarity, fuzzy matching
  4. LLM reranking: optional final pass for relevance scoring

The author’s own Solograph dropped its graph (Oct 2026) and its vectors (26 Oct 2026; measured: 0/39 session recall, 14 s cold) for SQLite FTS5 plus files. For this use, lexical search is the measured choice.

Multiple systems converge on this independently: Moltis uses hybrid (FTS5 + vector + optional LLM reranking), MemPalace found structural filtering beats raw embeddings by 34%, and most code-graph MCP servers now run on SQLite FTS5, embeddings optional.

Measured: what Solograph removed

Solograph began with three of these layers: FTS5, a FalkorDB graph queried in Cypher, MLX embeddings. In October 2026 each was tested against known answers.

Both went, and the install shrank from 862 MB to 89 MB. What stayed is what Grep cannot do: symbol and package search across 70 repositories, the knowledge base, the session archive.

Key insight: don’t start with “semantic magic.” Start with the simplest retrieval that handles your actual queries, and measure each layer you add against it. A stale index fails silently.


Minimal memory holds up (Nov 2026)

Three November 2026 sources point the same way: the simple layer carries most of the load. Each one has a limit, and the limits matter as much as the headlines.

MIRIX-2.0 (arXiv 2611.12068, 9 Nov 2026) is the counterweight: six typed memory agents, a provenance hypergraph and a background consolidation pass. Its abstract claims the top score on four of five QA benchmarks, 91.4% on LoCoMo and 72.6% on LongMemEval-S, 14.3 points above the strongest baseline. BRIDGE’s argument is that benchmarks like these cannot tell such designs apart, so I read that lead as unproven for agent work.

Where we sit. The brain is files plus SQLite FTS5 BM25 (see company-brain and project-solograph), with no extraction layer. It is not BRIDGE: BRIDGE adds cosine, which we removed on measurement, and writes a note per block with an LLM, which we do not. What carries over is the argument that retrieval is not the bottleneck, and BRIDGE’s finding that a retrieved rule goes unused unless it is put in front of the reader. That is why brain_start and the session-start hint put the map in context instead of waiting for a search. LEDGER is the comparison for our weak spot, notes going stale. We keep the source of each note and check notes against reality weekly with /solo:dream, but a person applies the fix. LEDGER does that mechanically: source and validity period are stored, and a rule picks the current value. We have no such rule, and its own 4 stale answers all came from updates the extractor missed, which is the same failure we would have.


Progressive Context Loading

All five systems converge on the same context engineering pattern: don’t load everything, load progressively.

Layer What When Size
L0 Identity / role Always ~50 tokens
L1 Core facts / preferences Always ~100-200 tokens
L2 Topic-relevant facts On demand Variable
L3 Deep search results Explicit query Variable

This is context engineering in practice: treating the context window as a memory budget. Harness keeps L0-L1 stable and tested; L2-L3 are dynamic.


Storage Architecture Comparison

System Storage Search Embeddings Scale
SGR v1 Python dict (in-memory) None None <100 facts
Moltis SQLite + FTS5 Hybrid (vector + keyword) + LLM reranking Local GGUF / OpenAI / Ollama <5K chunks
OpenClaw Markdown + SQLite index FTS5 + optional embeddings Optional <10K facts
MemPalace ChromaDB + SQLite KG Spatial filtering + vector Local 22K+ memories
Solograph SQLite FTS5 + markdown files BM25 over KB, sessions, symbols None (removed Oct 2026) 68 projects, ~85,900 symbols (18 Nov 2026)

Solograph as a Full Memory System

Solograph covers all four types above with SQLite files and no embeddings, over git-backed markdown the index can rebuild from anytime (local-first). What separates it from standard RAG patterns is freshness, not structure: every index checks its source files before answering, so there is no reindex step to forget. Five read tools provide the interface, plus brain_start and capture when the KB is run as a brain.


Practical Recommendations

Starting Simple (SGR v1 approach)

If you’re building your first agent, start with dict-based memory in the system prompt. No database, no embeddings. Three categories: semantic, procedural, rules. Load at init, don’t mutate during session. This alone gets you far. Schemas first: define the memory structure before adding persistence.

Adding Persistence (Moltis/OpenClaw approach)

When you need cross-session recall: Markdown files as source of truth + SQLite/FTS5 derived index. Rebuild index from Markdown anytime. Add vector search when FTS5 isn’t enough. Keep the ## Retain discipline for extracting structured facts. Local-first, offline-first.

Scaling Up (MemPalace approach; Solograph stays lexical)

For multi-agent systems with rich history: ChromaDB with a spatial hierarchy (MemPalace), or FTS5 across every store (what Solograph does). A knowledge graph for entity relationships is an option others use, not one the author kept. Session search for full audit trail. Progressive context loading (L0-L3). Active forgetting with temporal validity. Small bets: try one memory type first, add others incrementally.

The Compound Learning Goal

The ultimate goal isn’t remembering but compounding. Every decision trace should make the next decision better. This requires:


Research & References

Papers

Industry

Tools & Systems

Knowledge Patterns

Related Wiki Pages


Synthesized from: SGR Agents Spec v1 (Sep 2025), OpenClaw Workspace Memory Research (Feb 2026), Moltis Memory System (Mar 2026), MemPalace (Apr 2026), Solograph (measured review, Oct 2026), Foundation Capital Context Graphs (Jan 2026), and 7 research papers.

Sources

Related