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:

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
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.

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


Part of the field guide

This is one of my field notes in Context Engineering, a plain-English guide to deciding what a model sees. The terms behind it are defined in the Context Engineering Dictionary.

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 The First Agents Were Human

The First Agents Were Human

SEOs were running agent harnesses a decade before the word existed. The executors were people, the prompts were briefs, and the eval suite was an editor with a checklist.

James Phoenix
James Phoenix
Cover Image for Hosted Builds Are the Wrong Abstraction for Agentic Coding

Hosted Builds Are the Wrong Abstraction for Agentic Coding

Once agents increase commit throughput, the expensive part is no longer writing code. It is repeatedly verifying, building, and deploying it. So the build system has to move closer to controlled hardware, while the hosted platform becomes a dumb artifact receiver.

James Phoenix
James Phoenix