Memory Engineering as Data Modelling

James Phoenix
James Phoenix

Agent memory is not a feature. It is a data modelling problem with a lifecycle.


Definition

Memory engineering is the practice of designing how agents store, retrieve, expire, and act on information across interactions. It is what makes agents personal and smart. Combined with context engineering, it determines the ceiling of agent usefulness.

Mental Model

Think of agent memory like a database with TTLs, not a notebook.

Every memory has:

  • Schema: what shape is this memory? (user preference, task context, learned fact)
  • Scope: who does it apply to? (user-level, session-level, global)
  • TTL: when does it expire or get demoted? (session end, 7 days, never)
  • Retrieval path: how does the agent find it at inference time? (embedding lookup, key match, recency sort)

A notebook grows forever and becomes useless. A well-modelled memory system stays relevant because stale data expires and retrieval is intentional.

Core Insight: Memory Has a Lifecycle

Memories are not permanent. They follow a lifecycle:

Create → Store → Retrieve → Validate → Expire/Promote
  • Short-lived (session TTL): current task context, scratch state
  • Medium-lived (days/weeks TTL): recent preferences, project context
  • Long-lived (no TTL): stable user preferences, verified facts

Without TTL, memory systems accumulate noise. The agent starts hallucinating from outdated context. Designing the expiry policy is as important as designing the storage.

Leanpub Book

Read The Meta-Engineer

A practical book on building autonomous AI systems with Claude Code, context engineering, verification loops, and production harnesses.

Continuously updated
Claude Code + agentic systems
View Book

The Equation

Agent intelligence = Model capability + Context engineering + Memory engineering

Context engineering gets the right information into the prompt window. Memory engineering decides what information exists to pull from in the first place. Without memory, every conversation starts cold. Without context engineering, memories never reach the model. You need both.

Design Checklist

When building agent memory:

  1. Define your memory types (preferences, facts, task state, relationships)
  2. Assign TTLs per type (what expires, what persists)
  3. Choose storage (vector DB, key-value, graph, hybrid)
  4. Design retrieval (how does the right memory surface at the right time)
  5. Plan for conflicts (what happens when memories contradict each other)
  6. Build update/invalidation paths (corrections must propagate)

Gotchas

  • Treating memory as append-only. Without expiry, you poison your own context.
  • Over-indexing on vector search alone. Hybrid retrieval (keyword + semantic) covers more cases.
  • Ignoring the data modelling step. Jumping to “store embeddings” without defining schema, scope, and TTL leads to a system that retrieves noise.
  • Confusing memory with RAG. RAG retrieves from a static corpus. Memory is dynamic, user-specific, and mutable.

Related Concepts

Sources

  • Personal notes from Agentic Engineering session, 2026

Topics
Ai AgentsData EngineeringLong Running AgentsMemory SystemsType Safety

Newsletter

Become a better AI engineer

Weekly deep dives on production AI systems, context engineering, and the patterns that compound. No fluff, no tutorials. Just what works.

Join 306K+ developers. No spam. Unsubscribe anytime.


More Insights

Cover Image for When Parallelism Makes Tests Slower

When Parallelism Makes Tests Slower

*A thousand integration tests, sixteen cores, and not much faster. The fix was the easy part. The lasting lesson is that your test suite is the feedback loop your coding agents iterate against, and sc

James Phoenix
James Phoenix
Cover Image for The Five Levels Are Gated by Verification, Not Intelligence

The Five Levels Are Gated by Verification, Not Intelligence

Your autonomy level is a property of the repository, not the developer and not the model.

James Phoenix
James Phoenix