Designing Short-Term and Long-Term Memory
This lesson describes memory types and architectures, which let agents work coherently within a task and personalize their behaviour across sessions, and the decisions about what to keep, for how long, where, and which agents may read or write it.
Learning outcomes
After completing this lesson, you will be able to:
- Describe short-term memory and how it is held.
- Distinguish semantic, episodic and procedural long-term memory.
- Compare shared conversations, structured hand-offs and shared stores for context sharing.
Short-term memory
Short-term memory is the working context of a run or conversation: the messages, tool results and intermediate state that the model sees in its context window. It is held in the conversation (for example, a Foundry Agent Service conversation object or an Agent Framework session) and in workflow state. Its main constraint is the context window, which is why short-term memory needs compaction for long tasks.
Long-term memory
Long-term memory persists information across sessions. Common types are semantic memory (facts and preferences, such as a user's preferred language), episodic memory (summaries of past interactions) and procedural memory (how to perform recurring tasks). Long-term memory is stored outside the model, usually with embeddings for retrieval, and retrieved into the context when relevant.
Foundry Agent Service provides managed memory stores (preview) that extract user profile and chat summary memories from conversations, scope them per user and support time-to-live settings. Custom implementations use Azure Cosmos DB or Azure AI Search with vector search.
The following diagram shows both kinds of memory feeding an agent's context.

Semantic, episodic or procedural memory?
Context sharing between agents
Agents in a team share context in three main ways. A shared conversation gives every agent the full history, which is simple but expensive and can expose data an agent should not see. A shared state object (a blackboard) holds structured fields such as the customer ID, intent, verified facts and open questions, which agents read and update. Explicit hand-off messages pass only what the next agent needs. Structured state and explicit messages scale better and support least privilege.
The following table summarizes the memory tiers.
| Tier | Lifetime | Typical store | Shared with |
|---|---|---|---|
| Working context | One model call or run | Context window | One agent |
| Session and workflow state | One conversation or workflow | Conversation objects, checkpoints | Agents in the workflow |
| Long-term memory | Months, with retention rules | Memory store, Cosmos DB, AI Search | Agents serving the same user |
Ways to share context
A returning customer
A retail assistant uses a triage agent and three specialists. Customers must not repeat their order number after a hand-off, and the assistant should remember each customer's preferred delivery option across visits. Customers can ask the company to delete their data.
Within a session, a shared state object holds the order number and intent, so specialists read it after a hand-off. Across sessions, a long-term memory store scoped per customer holds the delivery preference, with a retention period and a deletion process. Passing the full transcript to every specialist would also avoid repetition but costs more tokens and does not provide cross-session memory.
What should agents share with each other instead of full transcripts?
Show answer
Structured state, which is smaller, unambiguous and contains only what the next agent needs.
Exam Tips
Remember for the exam
- Short-term memory lives in the context and workflow state; long-term memory lives in a store.
- Share structured state, not full transcripts, between agents.
- Long-term memory needs per-user scope, retention and deletion.