Memory and Conversation History

A conversation that never forgets eventually overflows, so managing what history an agent carries forward — and how it remembers across sessions — is one of the defining problems of context engineering.

Every multi-turn interaction accumulates history, and history is context that grows without bound. Ten turns in, the transcript is manageable; a hundred turns in, it no longer fits, or it fits but drowns the current task in stale detail. Meanwhile, useful things a user told the agent last week are gone entirely unless you did something to keep them. Managing this — what to carry forward within a conversation, and what to remember across conversations — is a core context-engineering skill. This fifth post in the series covers conversation history and memory.

The two problems: too much and too little

History poses opposite failures at once. Too much: raw transcripts grow past the budget, and long histories bury the current turn’s relevant content in the low-attention middle, degrading responses. Too little: a stateless agent that only sees the current turn cannot follow references (“do that again for the other account”), and an agent that forgets everything between sessions cannot build on what it learned about a user. Good memory management threads between these — keeping enough to stay coherent, dropping enough to stay focused.

It helps to separate the timescales:

They call for different techniques, so treat them separately.

Managing short-term history

Within a single conversation, the job is to keep the working context coherent without letting it grow unbounded. A few strategies, often combined:

The aim is a working context that stays roughly bounded turn over turn: recent turns in full, older material compressed, critical facts pinned, noise trimmed.

Long-term memory across sessions

Long-term memory is a different mechanism. Because it must persist beyond the window and beyond a single session, it lives in external storage and is retrieved into context when relevant — which makes it, structurally, a retrieval problem (previous post) applied to the agent’s own history. The loop:

The design questions mirror retrieval’s. What is worth writing (durable and useful, not every passing remark)? When to write (avoid storing noise)? How to retrieve (surface what is relevant to now, not everything ever stored)? And crucially, how much to inject — long-term memories compete for the same budget as everything else, so bring in the few that matter, not the whole store.

Memory is lossy on purpose

The instinct to “just remember everything” fails for the same reasons stuffing the context fails: unbounded memory overflows, and undistilled memory is noise. Good memory is lossy by design — it keeps the signal (the decision, the preference, the fact) and discards the rest (the exact wording, the small talk, the intermediate steps). Deciding what to forget is as much a part of the discipline as deciding what to keep. An agent that remembers the three things that matter about a user will out-perform one that retains a verbatim log it cannot effectively search or fit.

Tie it back to the budget

Everything here serves the budget mindset from earlier in the series. History and memory are two more claimants on the fixed window, and both grow. Left unmanaged, they are the claimants most likely to quietly consume the budget until the current task is starved. Managing them — recency windows, summarization, pinned facts, distilled long-term memories retrieved sparingly — is how a long-running or returning agent keeps a focused, affordable, high-quality context instead of an ever-growing transcript. The next post takes the compaction techniques these strategies lean on and treats them directly.

Key takeaways

Further reading

Sources & References

Why long histories degrade responses