Welcome back to the Harness Engineering series — a 10-part journey from raw language model to production-ready agentic system.
Made by builders.
For builders.
In Part 6, we closed on a limitation the previous four components can't solve on their own: the agent forgets.
Once a session ends — or the context window fills up mid-task — everything the agent learned, discovered, or decided vanishes.
Next time the user comes back, the agent greets them like a stranger.
Next time the token budget runs out, earlier turns get truncated away, and the agent's earlier reasoning is just gone.
That's the gap this article closes.
The Memory Layer is how the harness gives the agent persistence — inside a task, and across sessions.
What's ahead: Part 1: The Raw Model Problem Part 2: Defining the Harness — The Six Components Part 3: The Control Loop Part 4: The Tool Layer Part 5: Context Engineering Part 6: The Filesystem & Environment The Memory Layer ← You are here Part 8: Observability Part 9: The Harness Architecture Part 10: Decomposing Claude Code By the end of this article, you'll know what a Memory Layer actually is, why short-term and long-term memory are two different systems (not one with a dial), and the three design decisions — flavor, write triggers, and bounded retrieval — that separate a real memory system from a naive one.
Let's get started. 📚 Want to go deeper than the articles?
While you follow along with this series, I've put together two hands-on resources that go further than any single article can: Build a Harness from Scratch — Udemy Course — A self-paced course where I walk you through building a production-grade agentic harness from the ground up, in code.
Harness Engineering for AI Agents — Live Maven Workshop — A live, cohort-based workshop for builders who want direct feedback, Q&A, and to work through the material with peers.
Both are optional — the series stands on its own.
But if you want the full studio-quality version, that's where it lives.
What The Memory Layer Is The Memory Layer is state that persists beyond a single model call.
That's the one-line definition.
But memory in an agent isn't one thing — it's two things, and the difference between them is critical enough to name upfront.
Short-Term Memory Short-term memory is state within a task.
It's the conversation history so far, intermediate scratchpads the agent has scribbled on, tool results from calls it's already made, files it's read or written during this session.
It's everything the agent has generated or observed since the current task began, and it's what lets the agent stay coherent from one Loop iteration to the next.
If you asked the agent "what did we just try?" — the answer lives in short-term memory.
Long-Term Memory Long-term memory is state across tasks.
It's the stuff the agent should remember beyond the end of a session — things about the user, the codebase, its own past behavior, patterns it learned last week that are still relevant this week.
It's what lets the agent stop feeling like a stranger every time you come back to it.
If you asked the agent "what did we decide last time?" — the answer, if there is one, lives in long-term memory.
These two flavors have very different lifecycles, very different budgets, and — importantly — very different designs.
A single "memory system" that tries to do both usually does neither well.
Why The Memory Layer Exists Because the model itself remembers nothing.
We've noted this in every previous article, but it's worth restating in this specific frame: without an explicit memory layer in the harness, every interaction starts cold.
The model has no idea what happened in this conversation five turns ago (unless the harness resent those turns).
It has no idea what happened in the last conversation you had with it.
It doesn't remember the user's name, the codebase's conventions, or the mistake it made yesterday that you patiently corrected.
Anything that feels like "the agent is learning over time" — any