Skip to main content
AI & Agents

Agent Memory

Agent memory is the set of mechanisms an AI agent uses to retain information beyond a single model call: short-term memory held in the context window for the current task, and long-term memory written to an external store and retrieved when relevant. Without it, every session starts from zero and nothing the agent learns persists.

Memory comes in distinct types with different jobs. Short-term or working memory is the live state of the current run — the conversation so far and the task state. Semantic memory stores facts learned about a user or domain ("this customer is on the enterprise plan"). Episodic memory records what happened in past runs. Procedural memory captures how the agent should behave. Frameworks reflect the split: LangGraph, for example, separates per-thread checkpointed state from a cross-thread store for long-term facts.

The write path is the hard part, and the part most demos skip. Dumping raw transcripts into a store produces noise that retrieval later surfaces as confident irrelevance. Production memory systems extract candidate facts with a dedicated model step, attach a source and a timestamp, and decide deliberately what is worth persisting — which makes memory a database with a schema and a curation policy, not a transcript bucket.

Memory introduces failure modes chat systems do not have. Stale facts contradict current reality; a prompt-injection attack can instruct an agent to "remember" something malicious; and remembered personal data creates retention and deletion obligations. Per-user isolation, time-to-live on memories, treating retrieved memory as untrusted content, and giving users a way to see and edit what is remembered are the controls that make the capability safe to ship.

The read path decides whether memory helps or hurts. Memories are embedded and retrieved by relevance to the current task, weighted by recency, and injected sparingly — a handful of well-chosen memories sharpens behaviour, while a page of loosely related ones dilutes the context window with confident irrelevance. Each injected memory should carry enough provenance for the model to weigh it: where it came from, when it was learned, and how confident the extraction step was. Without that, the model treats a stale guess and a verified fact as equals.

Memory also has a product dimension that engineering alone does not settle. Users trust agents that remember stated preferences and are unnerved by agents that surface inferred facts at the wrong moment. The implementations that age well make memory visible and editable — a settings surface showing what the agent knows about you — which converts a compliance obligation into a feature users actively maintain, and keeps the store cleaner than any automated curation pass.

Codazz builds this in production — AI Agent Development.

FAQ

Agent Memory
FAQ.

Common questions about agent memory.

Ask Us Anything

They share retrieval machinery but differ in corpus and write path. RAG retrieves from documents your organisation owns, and the write path is publishing a document. Memory stores facts the agent extracted from interactions, and the write path is the agent itself — which is why memory needs curation, timestamps and expiry that a document corpus does not.

Yes. Memory poisoning — injected content instructing the agent to remember something harmful — turns a one-off attack into a persistent one, and cross-user memory leakage is a confidentiality breach. The mitigations are structural: per-user stores, treating retrieved memories as data rather than instructions, expiry on memories, and no memory writes without a validation step.

No. A single-session task agent — process this document, triage this ticket — gains nothing from persistence and inherits all of its risks. Long-term memory earns its complexity when the relationship spans sessions: assistants that should know your preferences, support agents that should recall prior interactions. Start stateless, add memory when a concrete need appears, and treat the write path as the feature rather than an afterthought.