Article

Short-Term Context, Retrieval, and Long-Term Memory

Agents do not just need more context. They need clean separation between what the model sees now, what the system can fetch now, and what the system should still know later.

Short-term context, retrieval, and long-term memory are not the same thing.

That is the short answer.

If you want the operational version, use this:

Short-term context is what the model can work with in the current step. Retrieval is how the system brings in relevant information for that step. Long-term memory is what the system preserves so later steps do not start from scratch.

Those layers often get blurred together.

Teams say things like:

That language sounds reasonable.

It also creates bad systems.

The reason is simple. These three layers solve different problems.

If you collapse them into one vague concept, the agent gets harder to reason about, harder to debug, and easier to confuse.

A Running Example: A Billing Incident Agent

Suppose an operations agent is responsible for recurring failures in the nightly billing sync job.

The job fails on Tuesday.

The agent needs to:

  1. inspect the current failed run
  2. check logs and dependency health
  3. compare this failure to similar prior incidents
  4. decide whether to retry automatically or escalate
  5. preserve what was learned so the next run does not start blind

This is a good example because all three layers matter.

The agent needs a current working set, just as it does in The Sense-Think-Act Loop, but it also needs a way to pull in outside information and a way to preserve what should survive into later runs.

That is where the separation starts to matter.

Short-Term Context

Short-term context is the information the model can work with in the current step.

This is the immediate working set.

It may include:

In the billing incident example, short-term context might include:

This is not the whole system’s memory.

It is what the model can actively reason over now.

That matters because a model can only act on what is inside the current step. Even when Tool Use: How Agents Take Action is well designed, the model still needs the right working set before it can choose a safe tool call or form a correct argument.

So short-term context is about working visibility.

It answers:

It does not answer:

That is why a larger context window is helpful but incomplete. As Memory: Why Agents Need More Than Context Windows argues, capacity is not the same thing as continuity.

Retrieval

Retrieval is how the system brings in relevant information for the current step.

That information may come from:

The key point is that retrieval is a fetch mechanism.

It does not by itself create memory.

In the billing incident example, retrieval might bring in:

All of that is useful.

But none of it means the agent has memory in the stronger sense.

Why not?

Because retrieval answers:

It does not answer:

This is the easiest place for teams to get sloppy.

They add retrieval and then say the agent now “remembers.”

That is usually wrong.

Retrieval can help reconstruct context.

It can help recover background material.

It can sometimes fetch prior state.

But retrieval is still a read path, not a continuity policy.

If the agent retrieves the same noisy history every time and never writes back what mattered, it will keep reassembling the past instead of carrying the right state forward.

Long-Term Memory

Long-term memory is what the system preserves so later steps, later runs, or later sessions do not start from zero.

This is durable state.

It may include:

In the billing incident example, long-term memory might preserve:

This is the layer that gives the system continuity.

It is also the layer most likely to become messy if teams treat memory as “save more stuff.”

Good long-term memory is selective.

It preserves state that should still matter later.

Bad long-term memory becomes an unfiltered archive of everything, which creates stale state, weak retrieval, and contradictory behavior.

So the question is not whether the system can store data somewhere.

The real question is whether the system knows what deserves to survive and how that state should influence later runs.

The Three-Layer Context Model

The cleanest way to reason about this is to separate the runtime into three layers.

Call this The Three-Layer Context Model.

Layer 1: Working Context

What the model sees and reasons over in the current step.

This is immediate and temporary.

Layer 2: Retrieved Context

What the system can pull into the current step because it appears relevant.

This is dynamic and on-demand.

Layer 3: Durable Memory

What the system intentionally preserves so future steps can begin from prior learning instead of a fresh reconstruction.

This is persistent and selective.

That gives you a much cleaner architecture.

Instead of one blurred bucket called “memory,” you can ask three different questions:

  1. What must the model see right now?
  2. What can the system fetch if needed?
  3. What should still be true or available later?

Those are not the same design problem.

They lead to different choices about prompt assembly, storage, retrieval, state updates, and debugging.

What Breaks When Teams Blur Them Together

When these layers get mixed together, the system usually fails in predictable ways.

Everything Gets Stuffed Into the Prompt

Teams try to solve continuity by dumping more history into the current step.

That increases noise, cost, and confusion.

It does not produce clean durable state.

Retrieval Becomes a Substitute for Memory

The system keeps fetching old information but never decides what should persist as actual working knowledge.

So each run has to rediscover the same lessons.

Memory Turns Into a Junk Drawer

If every tool result, every message, and every intermediate thought is treated as memory, later runs inherit clutter instead of clarity.

That leads to stale facts, contradictory state, and weak trust.

Debugging Gets Harder

When the agent behaves oddly, nobody can answer a simple question:

Was the failure caused by bad current context, bad retrieval, or bad stored memory?

If those layers are collapsed, the failure surface becomes vague.

The Agent Loses Behavioral Discipline

Agents become inconsistent because they do not clearly separate:

That kind of blur is exactly what makes agent systems feel unpredictable.

How the Layers Work Together in a Real Agent Loop

In a healthy runtime, these layers reinforce each other instead of competing.

Go back to the billing incident.

The loop might work like this:

  1. the runtime assembles the current working context for the failed job
  2. the agent uses tools to inspect logs, service health, and deployment history
  3. retrieval brings in the runbook and the most relevant similar incidents
  4. the model reasons over that combined context and chooses the safest next action
  5. the runtime executes the action or requests approval
  6. the system writes back only the durable outcome that should matter later

That final step is important.

Not everything from the run belongs in long-term memory.

The agent should not persist every log line or every temporary thought.

It should preserve things like:

This is also why memory design sits downstream of both planning and action. Planning and Task Decomposition shapes what the agent is trying to accomplish across steps. Tool use determines how it can inspect and change the environment. Memory decides what survives after those steps complete.

A Practical Rule for Writing Memory

If you want a simple rule, use this:

Write to long-term memory only when losing that state would make a later run repeat work, miss a durable fact, or break continuity.

That is a much better rule than:

save whatever might be useful someday

The second rule creates clutter.

The first rule creates continuity.

Short-Term Context, Retrieval, and Memory Are Complements

The point is not to pick one of these layers.

Reliable agents need all three.

Short-term context helps the model think clearly in the current step.

Retrieval helps the system pull in the right information when needed.

Long-term memory helps later steps start from preserved useful state.

That is the real distinction.

Short-term context supports the present.

Retrieval supports access.

Long-term memory supports continuity.

Once those roles are separated, the system gets much easier to design and much easier to debug.

FAQ

Is chat history the same thing as memory?

Not by itself.

Chat history can be part of short-term context, and pieces of it may be retrievable later, but that does not automatically make it useful long-term memory. Memory requires some selective preservation of state that should still matter later.

Is retrieval the same thing as memory?

No.

Retrieval is how the system fetches information for the current step. Memory is what the system intentionally preserves across time. Retrieval can access memory stores, but it is still a different function.

Does a larger context window reduce the need for memory?

It can reduce pressure in the current step.

It does not remove the need for continuity across sessions, retries, or long-running work. Bigger windows improve working capacity. They do not replace durable state design.

Does long-term memory mean saving everything forever?

No.

That usually makes the system worse. Good memory is selective, current enough to trust, and tied to later decisions that actually need it.

Where do semantic and episodic memory fit?

They usually sit inside the long-term memory layer.

Semantic memory is durable knowledge or facts the agent should be able to use later. Episodic memory is memory of prior events, attempts, and outcomes. They matter, but only after the more basic layer distinction is clear.

What is the easiest mistake to avoid?

Do not use one word, “memory,” to describe three different things.

If you separate what the model sees now, what the system can fetch now, and what the system should still know later, most design decisions get clearer fast.