Lesson 4 of 4 Context Management and Agent Memory

Securing Memory and Managing Its Compliance and Lifecycle

This lesson covers how long-term memory, which stores personal data about users and their past interactions, is secured, how compliance obligations are met, how memory ages, where it is stored and how sessions are managed.

Learning outcomes

After completing this lesson, you will be able to:

  • Scope memory by identifiers from the authenticated identity.
  • Meet privacy obligations, such as deletion requests, across every store.
  • Define retention, time-to-live and consolidation rules.

Security

Memory is scoped by user and tenant identifiers that come from the authenticated identity, not from anything the user or model supplies, so that one user cannot retrieve another's memories by asking. The store is protected with Microsoft Entra ID and RBAC, private endpoints and encryption at rest (with customer-managed keys where required). Content is screened before storage: secrets, payment data and other sensitive categories are filtered or redacted, and content from untrusted sources is not stored as fact without validation.

True or false

Securing memory

Exam skills 2.2.2

Check how a memory store is secured.

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

Compliance

Privacy regulations such as the GDPR require a lawful basis or consent for processing, data minimization, transparency about what is stored and the ability to access, correct and delete a person's data. A compliant memory design therefore records the purpose of each memory type, shows users what is remembered (where appropriate), supports deletion on request across every tier (memory store, caches, logs and replay captures) and keeps data in the required region.

Select all that apply

A compliant memory design

Exam skills 2.2.2

Pick the features a memory design needs to meet privacy regulations such as the GDPR.

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

Lifecycle, storage and session management

Lifecycle rules define retention periods per memory type, time-to-live for low-value memories, consolidation of duplicates and decay or re-validation of old facts. Storage follows the tiers described in the architecture module: Foundry memory stores, Cosmos DB or AI Search for long-term memory, and Redis or conversation objects for sessions. Session management assigns a conversation identifier, binds it to the authenticated user, expires idle sessions and cleans up their temporary data.

The following table summarizes typical policies.

ConcernTypical policy
ScopeUser and tenant IDs from the token; never from prompt content
Sensitive dataRedact secrets and payment data before storage
RetentionPer memory type, for example 90 days for chat summaries
DeletionOn request, across memory, caches, logs and replay captures
SessionsIdle expiry, bound to the authenticated user
Match the pairs

Memory policies

Exam skills 2.2.2

Match each memory concern with its typical policy.

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

A deletion request

A customer of a European retailer asks for all personal data held by the shopping assistant to be deleted. The assistant uses a memory store, a semantic cache in API Management and trace content capture in Application Insights.

Deletion must cover every store: the customer's memories (deleted by user scope), cached responses keyed by that customer, and traces with captured content (purged or allowed to expire under a retention period that meets the regulation). A design that keeps personal data out of shared caches and limits content capture makes such requests far easier to fulfil.

Check yourself

Where should the user ID that scopes memory come from?

Show answer

From the authenticated token, never from the prompt, which a user could manipulate.

Exam Tips

Remember for the exam

  • Scope memory with IDs from the authenticated token, never from the prompt.
  • Deletion requests must reach memory, caches, logs and replay captures.
  • Set retention and TTL per memory type.