What Is Agent Memory? Long-Running Agents Explained
By default, an AI agent has the memory of a goldfish — it forgets everything the moment the process ends. Agent memory is how you fix that: state you deliberately store and retrieve, so an agent can recall, resume, and improve over time.
Build an AI agent and you'll notice it has no past. It solves today's task brilliantly, then the process exits and it forgets everything — tomorrow it starts from zero, as if today never happened. That's fine for a one-off chat, but useless for an agent you want to rely on over time. Agent memory is how you close that gap: state the agent deliberately stores and retrieves, so it can recognise, recall, and improve across runs.
The problem: the context window is not memory
Everything a model "knows" during a run lives in its context window — a scratchpad for that one call. When the run ends, it's gone. And a bigger context window isn't the fix: it's still wiped between runs, it's bounded and costly, and it has no retrieval — you'd be pasting your whole history every time instead of recalling the few relevant bits. Real memory has to live outside the model, under your control.
What agent memory actually is
Memory is state you persist and later retrieve on purpose. It usually comes in a few kinds, borrowed from how we describe human memory:
- Working memory — the current task's scratchpad (the context window). Transient by design.
- Episodic memory — a diary of specific past events: "on July 6th, this happened, we did X, it worked." Concrete and timestamped.
- Semantic memory — general lessons distilled from many episodes: "errors like this usually mean Y."
- Procedural memory — how-to knowledge: the tools and playbooks the agent can use.
The agent writes to these stores (often a database, with embeddings for search) after a run, and reads the relevant ones back at the start of the next — so it begins informed instead of blank.
Memory isn't just storage, it's selective recall. The skill is deciding what's worth keeping and pulling back only the few past events relevant to right now — not re-reading the agent's entire life every time.
Long-running agents need more than memory
An agent that works unattended over hours or days needs two more things memory alone doesn't give:
- Durability — checkpoint progress so a crash mid-task resumes instead of starting over, and make actions idempotent so a retry can't do something twice.
- Asynchronous human-in-the-loop — since no human is watching at 3am, the agent proposes risky actions to a queue and waits for approval, rather than acting alone.
Together, memory + durability + a human gate are what turn "an agent you invoke" into "a teammate that works while you're away, safely."
Why it matters
Memory is what lets an agent recognise a recurring situation and reuse what worked, cite what it did before, and get better with experience instead of repeating the same discovery every run. It's also a new attack surface — recalled text is untrusted input, so serious systems treat memory as data to reason over, never as commands to obey.
The mental model to keep
Picture the difference between a temp who forgets everything each shift and a long-tenured teammate who remembers past incidents, resumes cleanly after an interruption, and checks with you before doing anything risky. Agent memory — plus durability and a human gate — is what moves an AI from the first to the second.
Frequently Asked Questions
Why do AI agents forget between runs?
Everything an agent "knows" lives in its context window for one run; when the process ends it's wiped. Memory has to be stored outside the model and reloaded.
What are the types of agent memory?
Working memory (the current scratchpad), episodic (specific past events), semantic (general lessons distilled from them), and procedural (how-to knowledge and tools).
How do long-running agents avoid repeating work after a crash?
With durable checkpointing (resume, not restart) plus idempotent actions, so a retried step can't apply the same effect twice.
Stop reading, start building
This pairs with a hands-on BytExplorer course — do it on your own machine and actually keep the skill.