Join our Newsletter — 33% off our NHI Course
Home› FAQ› Foundations & NHI Taxonomy› What is the difference between session memory and…
Foundations & NHI Taxonomy

What is the difference between session memory and model context?

← Back to all FAQ
By NHI Mgmt Group Editorial Team Updated November 25, 2026 Domain: Foundations & NHI Taxonomy

Session memory is the per-user conversation state retained across turns within one authenticated session. Model context is the information currently supplied to the model for inference, which may include recent messages, retrieved documents and tool outputs; context can be rebuilt each turn, while session memory persists outside the prompt and must be access-controlled separately.

Session memory versus model context: what changes operationally?

Session memory is state that lives outside the prompt and can persist across turns within one authenticated session. Model context is the working set fed into inference on a given turn, so it can include recent messages, retrieved documents, and tool outputs even when no long-lived session state is retained.

The practical difference is that memory governs continuity, while context governs what the model can actually “see” right now. In other words, session memory can survive prompt reconstruction, but model context is rebuilt each turn from the inputs and retrievals you choose to supply.

That distinction matters because a system can have rich context without any durable memory, or durable memory with very little current context. The first changes response quality and continuity; the second changes whether prior user state, preferences, or decisions are still available after the prompt is regenerated.

Why the difference matters for access control and leakage

Because session memory exists outside the prompt, it is not just an inference concern, it is a data-handling concern. Anything placed there may become available across turns, so it needs explicit scope, expiry, isolation, and access checks rather than being treated as ordinary transient prompt text.

Model context is easier to inspect in the moment, but it can still leak sensitive material if retrieved documents or tool outputs are over-broad. The risk is different: context leakage usually happens through what is assembled for a turn, while memory leakage happens through what is retained and re-surfaced later.

AI Agent Memory Security Guide is useful here because it covers isolation, write controls, retention and cross-session leakage patterns that are central to session memory design.

AI Agent Memory Poisoning Guide is the complementary angle when the concern is not just persistence, but whether retained memory can be poisoned and then reused in later turns.

How to design for both without confusing them

The safest design is to treat model context as ephemeral assembly and session memory as governed state. That means deciding which facts belong in the prompt for one turn, which facts are safe to persist, and which facts should never enter memory at all, such as secrets, high-risk tokens, or unreviewed instructions.

If you use retrieval or tools, you should assume they can enrich context without becoming memory. That is useful, because it lets you keep the prompt smaller and more current while still avoiding accidental long-term retention of material that only needed to exist for one response.

What Is MCP? The Model Context Protocol Explained (2026) helps distinguish protocol-level context assembly from any separate memory layer, which is important when tools and retrieval are part of the turn.

Pre-Execution Policy Checks vs Post-Execution Monitoring is relevant when the prompt contents can trigger tool use, because the decision to allow an action should not rely on informal assumptions about what the session “remembers.”

Risk and Threat Considerations

Session memory creates a durable attack surface: if an attacker can write to it, poison it, or cross a boundary into another user's session state, the bad data can shape later outputs long after the original turn has ended. Model context is more transient, but it is still vulnerable to prompt injection, unsafe retrieval, and over-sharing from tools or documents.

Failure mechanism: A system confuses transient context with durable memory, or fails to isolate memory by user, session, or trust domain, so retained state is reused where it should not be.

Impact: The result can be cross-turn data leakage, persistence of malicious instructions, incorrect personalization, or unauthorized access to information that should have been rebuilt or discarded.

Standards & Framework Alignment

This section maps relevant standards and security frameworks to the operational risks and controls described in this guidance.

OWASP Agentic AI Top 10 addresses the attack and risk surface, while NIST SP 800-53 Rev 5 sets the governance and control requirements practitioners need to meet.

FrameworkControl / ReferenceRelevance
NIST SP 800-53 Rev 5IA-5 — Authenticator ManagementSession memory and turn state depend on credential lifecycle and session protection.
AC-6 — Least PrivilegeContext and memory both need tight access so retained state is not overexposed.
AU-2 — Event LoggingPersistent memory and context assembly need traceability for review and abuse detection.
Recommendation — Protect session state with authenticated access and controlled credential lifecycle. Limit which users and services can read or write session memory. Log memory writes, context assembly, and high-risk retrieval events.
OWASP Agentic AI Top 10ASI06 — Memory & Context PoisoningThe question directly contrasts memory with context, including poisoning and persistence risks.
Recommendation — Isolate, validate, and rollback mutable memory to prevent poisoned reuse.

Practitioner Guidance

What to verify: Confirm whether each stored field is meant to persist beyond the current turn, who can read it, who can write it, and when it expires. If you cannot explain those four points, the design is mixing prompt context with memory in a way that will be hard to secure.

Common mistake: Teams often protect the prompt path but neglect the memory store, assuming session state is harmless because it is “only conversation data.” In practice, memory is often the higher-risk asset because it survives longer and is easier to reuse incorrectly.

Practitioner takeaway: Treat model context as the per-turn working set and session memory as separately governed state; the security boundary is not where the model reads, it is where durable data is stored, reused, and authorized.

Free weekly newsletter

Subscribe to the NHI & AI Identity Journal

The latest on NHI and Agentic AI security – articles, research, breaches, news and events every week.

Bonus 33% off our NHI Course when you subscribe.

NHIMG Editorial Note
Reviewed and updated by the NHIMG editorial team on November 25, 2026.
NHI Mgmt Group — the #1 independent authority on Non-Human Identity, IAM, and Agentic AI security. nhimg.org