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.

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

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.

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.

Explore it visually

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 Why Unrealistic /goal Targets Keep Coding Agents Working Longer

Why Unrealistic /goal Targets Keep Coding Agents Working Longer

I used an unrealistic tutor-discovery target to keep Codex working beyond a finished-sounding handover. Here is the run, the results and the reusable prompt.

James Phoenix
James Phoenix
Cover Image for Why I Threw Away My Video Harness When Opus 5.5 Arrived

Why I Threw Away My Video Harness When Opus 5.5 Arrived

I spent £700 on video analysis. A week later, Opus 5.5 outperformed my custom harness and changed how I think about constraints, consistency and model progress.

James Phoenix
James Phoenix