Lesson 4 of 4 Agent Boundaries, Communication and Memory Design

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.

Short-term and long-term memory. Short-term memory is the current session: messages, temporary variables and tool results in the context. Long-term memory persists across sessions, outside the model, usually with embeddings for retrieval: semantic memory holds facts and preferences, episodic memory summaries of past interactions and procedural memory how to perform recurring tasks. Relevant memories are retrieved into the context when needed. Foundry Agent Service provides managed memory stores, scoped per user with time-to-live.
Long-term memory lives outside the model and is retrieved when relevant.
Sort into groups

Semantic, episodic or procedural memory?

Exam skills 1.1.7

Classify each item an assistant might remember across sessions.

Log in to try this activity Interactive activities are free with an account.

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.

TierLifetimeTypical storeShared with
Working contextOne model call or runContext windowOne agent
Session and workflow stateOne conversation or workflowConversation objects, checkpointsAgents in the workflow
Long-term memoryMonths, with retention rulesMemory store, Cosmos DB, AI SearchAgents serving the same user
Match the pairs

Ways to share context

Exam skills 1.1.7

Match each context-sharing approach with its main property.

Log in to try this activity Interactive activities are free with an account.
Worked example

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.

Check yourself

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.