Agent memory
What an agent stores from earlier turns or runs and feeds back into later model calls: conversation history, summaries, saved tool results or retrieved notes.
A language model keeps nothing between calls. Each call sees only what is in its prompt. An agent seems to remember because the application saves parts of earlier turns and puts them back into the next prompt. Anthropic's guide to building agents lists memory, with retrieval and tools, as one of the augmentations of "the basic building block of agentic systems".
Memory comes in a few kinds:
- Conversation history: the last messages of a session, reloaded on the next turn.
- Summaries: older turns condensed into a short note to save space.
- Cached tool results: full outputs of earlier tool calls, kept outside the prompt and fetched again when needed.
- Long-term notes: facts saved across sessions and looked up by search, often in a vector storeVector store: A database that keeps embeddings (lists of numbers that stand for the meaning of text chunks) and returns the chunks whose embeddings are nearest to a query's..
Memory has limits. Everything reloaded uses space in the context windowContext window: The most text, counted in tokens, that a model can take into account in one call: system prompt, conversation, tool definitions and tool results, plus the answer it writes., so history is cut or summarised, and a summary loses detail. Memory is also stored data, and it often holds personal data, so it needs a retention period and a way to delete one person's records.
Example
On turn one a customer writes "My order 1182 hasn't arrived". On turn two they write "Can you cancel it instead?". Without memory the agent does not know what "it" means. With session memory, turn one's messages are loaded back into the prompt, and the agent cancels order 1182.
Common confusion
Memory is not learning. The model's weights do not change: the application chooses what to save and what to show again. Memory is not the context window either. The window is what one call can read. Memory is what is kept between calls and chosen to go back into it.
In L2M
An agent run with a session id keeps its conversation, stored per namespace and session id. Attach a Simple Memory node to the agent's memory port to give it its own namespace, a window (maxMessages, 20 by default) and the option to keep tool results (persistToolMessages, off by default). When a run has a session id, the session tool cache keeps full MCP tool outputs and gives the model session_cache_list and session_cache_get to fetch them again. Memory is kept until you set the optional AGENT_MEMORY_RETENTION_DAYS (data retention).
Further reading
- Building effective agents (Anthropic engineering, December 2024)