AI Agent Assurance for Your Agent Deployments

Agent Assurance Tests How Your Agent Actually Behaves across Workflows, Tools, and Actions to Catch Failures and Vulnerabilities.

npm install -g @testmuai/rook@latest

What Is AI Agent Memory? Types, Storage and Failure Modes

AI agent memory explained: short-term vs long-term memory, the episodic, semantic and procedural types, how agents save and retrieve facts, and what breaks.

Summarise with AI

OVERVIEW

Early in a chat, a customer asks a support agent to ship orders to 12 Elm St, Austin. A few turns later they mention a move to 9 Oak Ave, Denver, yet when they place the order, the agent writes Elm Street on the shipping record. AI agent memory, the information an agent keeps beyond a single model call so it can use it later, failed here without raising any error: it returned a fact that had stopped being true.

In a human study reported in the LongMemEval paper (ICLR 2025), ChatGPT and Coze running GPT-4o were asked 97 questions about short chat histories of three to six sessions, tested in August 2024. Against the same model reading the whole history offline, they showed a 37% and a 64% accuracy drop. One of the five abilities the full benchmark scores is knowledge updates: recognizing that a user's personal information has changed.

A toy store later in this guide reproduces the stale address in six scripted turns, then removes it by superseding the old address on write and reading the address by its key.

Overview

AI agent memory is the information an agent keeps beyond a single model call so it can use it later. Working memory holds what the current step needs, and long-term memory keeps information between sessions, mostly in external stores the agent writes to and reads from. The CoALA framework divides long-term memory into episodic, semantic and procedural types.

What are the types of AI agent memory?

  • Working memory in AI agents: The information an agent keeps active for its current decision cycle, such as the latest user message, its plan and recent tool results. Long-term memory: No. CoALA calls working memory short-term and describes it as a data structure that persists across LLM calls.
  • Episodic memory in AI agents: Experience from earlier decision cycles, such as past conversations or a trajectory that solved a similar task. Long-term memory: Yes. LangGraph's memory guide says agents often use episodic memories as few-shot examples of how a task was done before.
  • Semantic memory in AI agents: Facts about the world and about the user, such as a preferred name, a plan tier or a shipping address. Long-term memory: Yes. Semantic memory usually lives in an external store and goes stale when the fact behind a record changes.
  • Procedural memory in AI agents: Knowledge of how to act, held implicitly in the model weights and explicitly in the agent's code and prompt. Lives in the model weights or the agent's code: Yes. CoALA rates writing to procedural memory as significantly riskier than writing episodic or semantic memory.

Can TestMu AI test whether an agent uses what it remembers?

  • Conversation memory checks in Agent Assurance: Yes, within one run. TestMu AI's Agent Assurance carries a multi-turn scenario across turns on the agent's real conversation handle, and a read-only check confirms that the record the agent wrote matches what the user said earlier. Long-term memory across sessions tested: No.

What Is AI Agent Memory?

AI agent memory is the information an agent keeps beyond a single model call. It is held in three places: the context assembled for the current step, external records that survive between sessions, and the model weights and the agent's code.

The CoALA paper (Cognitive Architectures for Language Agents, Sumers et al., 2023) supplies the vocabulary that LangGraph's memory guide also uses. It describes a language agent with "modular memory components, a structured action space to interact with internal memory and external environments, and a generalized decision-making process to choose actions." It splits memory into short-term working memory and long-term episodic, semantic and procedural memory.

Two actions connect those stores in CoALA: retrieval, which "reads information from long-term memories into working memory," and learning, which writes information to long-term memory.

Agentic memory usually means memory the agent organizes for itself, and the term names a research design, not a standard with a fixed meaning. The A-MEM paper (NeurIPS 2025) turns each new memory into a note with "contextual descriptions, keywords, and tags." Adding a note can update the attributes of older ones, a process its authors call memory evolution.

LLM Memory vs Agent Memory: Weights, Context and External Stores

A model on its own keeps information in two places: its weights, fixed at training time, and its context, the tokens of the current request. Agent memory adds a third place outside the model, plus the code that decides what moves between them, so the phrase LLM memory can point at any of the three layers below.

The MemGPT paper (Packer et al., 2023) treats this as an operating-system problem. Its main context is "analogous to main memory/physical memory/RAM," its external context to disk storage, and out-of-context data "must always be explicitly moved into main context" before the model can use it.

LayerWhat it holdsHow it changesTypical problem
Model weightsWhat the model learned in training; CoALA counts it as implicit procedural memoryOnly through retraining or fine-tuningKnows nothing about this user or anything after training
Context (main context)Instructions, recent turns, retrieved memories and tool results for one callRebuilt by the agent's code for every callAnything left out does not exist for that call
External store (external context)Profiles, past episodes, notes and documents kept outside the modelWritten and read by agent code or by functions the model callsStale, conflicting or wrongly scoped records

Window sizes and token limits belong to the guide on the context window. For memory design, keep MemGPT's rule in mind: a record that was never moved into context is invisible to the model on that call, however well it was stored.

Short-Term vs Long-Term Memory in AI Agents

Short-term memory lasts for one conversation or task, and long-term memory survives across conversations. CoALA draws the same line between short-term working memory and its long-term episodic, semantic and procedural stores.

LangGraph draws the line in code. Its memory overview calls short-term memory thread-scoped: message history kept as part of the agent's state and persisted by a checkpointer "so the thread can be resumed at any time." Long-term memory is saved under custom namespaces and stays available across different conversations or sessions.

AttributeShort-term memoryLong-term memory
ScopeOne thread, conversation or taskMany threads, grouped by user, organization or application
LifetimeUntil the thread ends or old turns are trimmed or summarizedUntil your policy updates, supersedes or deletes the record
Storage in LangGraphAgent state, saved by a checkpointerA store of JSON documents under a namespace and a key
Typical failureA detail dropped when turns are trimmed or summarizedA changed fact never updated, or a record read for the wrong user

AI agent long-term memory needs an update and deletion policy before the first record is written, because each record outlives the conversation that created it. Short-term memory needs a rule for trimming or summarizing old turns, and that rule decides which details survive.

Types of AI Agent Memory: Working, Episodic, Semantic and Procedural

The four CoALA types differ in who writes them and how far a wrong entry spreads. A mistake in working memory misleads the current task, while a wrong procedural memory changes how the agent acts on every task that follows.

TypeWhat it holdsWho writes itExampleRisk when wrong
WorkingActive information for the current decision cycleThe agent loop, at every stepThe last user message, the plan, the latest tool resultThe next step acts on a wrong value
EpisodicExperience from earlier decision cyclesThe agent, or a background job after a taskA resolved ticket reused as a few-shot exampleA past mistake gets copied into new tasks
SemanticFacts about the world and the userExtraction from conversations, or a team loading dataPreferred name, plan tier, shipping addressA changed fact keeps driving actions
ProceduralHow to act: weights, agent code, promptsDevelopers, or an agent that edits its own instructionsA prompt rule for when a refund needs approvalBugs, or an agent that works around its designers
  • Working memory - CoALA says it "maintains active and readily available information as symbolic variables for the current decision cycle." The running record of reasoning steps and tool results that a ReAct agent carries from one step to the next is one example.
  • Episodic memory - CoALA lists training input-output pairs, history event flows and game trajectories from previous episodes as forms of it. LangGraph's guide adds that episodic memories are "often implemented through few-shot example prompting."
  • Semantic memory - CoALA defines it as "an agent's knowledge about the world and itself," and the LangMem conceptual guide describes it as "the essential facts and other information that ground an agent's responses."
  • Procedural memory - CoALA splits it into implicit knowledge in the LLM weights and explicit knowledge in the agent's code, and LangGraph adds the prompt. CoALA warns that learning by writing to procedural memory "is significantly riskier than writing to episodic or semantic memory, as it can easily introduce bugs or allow an agent to subvert its designers' intentions."

In practice, let the agent write episodic and semantic memory under a write policy scoped to one user, and route any change to prompts or code through the same review a developer's change would get. For a prompt, that review can be the regression gate used in prompt optimization, which scores the new version on held-out cases it was never tuned on.

How AI Agents Write Memories: Hot Path, Background, Profiles and Collections

Every write settles three questions: when to save, in what shape, and how to reconcile the new information with records already stored. The LangGraph memory guide and the LangMem conceptual guide describe the trade-offs for each one.

  • Hot path writes - the agent saves during the conversation, which, in LangGraph's words, makes "new memories immediately available for use in subsequent interactions." The cost is latency and an extra decision inside the main task.
  • Background writes - a separate process extracts memories after the fact. LangGraph says this "eliminates latency in the primary application" and separates application logic from memory management; the trade-off is that a fact said a moment ago may not be saved yet.
  • Profiles - one JSON document of key-value pairs that represents the current state, such as a preferred name or response style. LangMem says that when new information arrives, a profile "updates the existing document rather than creating a new one."
  • Collections - many documents, extended over time. LangGraph notes that a collection "tends to lead to higher recall downstream," because generating new objects is easier for an LLM than reconciling them with a profile. The model must then delete or update old items, and "some models may default to over-inserting and others may default to over-updating."
  • Extraction volume - LangMem warns that over-extracting reduces the precision of memory search and under-extracting lowers recall, so the extraction prompt sets the balance between the two.

Use a profile field for any fact with one current value, such as an address or a plan tier, and a collection for open-ended notes, such as past issues a user reported. Which of those writes reach the prompt, and in what order, is the job of context engineering.

How AI Agents Retrieve Memories: Recency, Importance and Relevance

Retrieval decides which stored memories enter working memory for the next step. The Generative Agents paper (Park et al., 2023) keeps a memory stream, "a database that maintains a comprehensive record of an agent's experience," and scores every record in it on three signals.

  • Recency - an exponential decay over the sandbox game hours since the memory was last retrieved, with a decay factor of 0.995.
  • Importance - a rating from 1 to 10 that the model assigns when the memory is created, anchored by "brushing teeth" at 1 and "a break up, college acceptance" at 10.
  • Relevance - the cosine similarity between the memory's embedding vector and the query's embedding vector.
score = a_recency    * recency
      + a_importance * importance
      + a_relevance  * relevance

recency    = 0.995 ^ (game hours since last read)
importance = model rating, 1 to 10, set on write
relevance  = cosine(memory vector, query vector)
each term min-max scaled to [0, 1]; every a = 1

The paper min-max scales each signal to [0, 1], sets all three weights to 1, and includes "the top-ranked memories that fit within the language model's context window" in the prompt. Those values are the paper's implementation for a simulated town, so tune them for your own data instead of copying them.

In MemGPT, the agent moves data itself: it uses functions to move data between main context and its archival and recall storage. Exposing memory as functions puts retrieval under the same rules as any other tool calling, so a memory is read only when the model chooses to call the function.

LongMemEval splits long-term memory design into three stages, indexing, retrieval and reading. That split gives you a debugging order for a wrong answer: was the fact never stored, stored but not retrieved, or retrieved but ignored by the model?

Agent Memory Storage: Key-Value, Vector and Graph Stores

A memory store is a database with a retrieval rule attached. The store you pick decides what a lookup can express and what happens to a fact that changes.

StoreHow a memory is foundWhen a fact changesFits
JSON document (key-value) storeAn exact read by namespace and keyOverwrite the field, or mark the old record supersededProfiles and facts with one current value
Vector storeEmbedding similarity between the query and each memoryOld and new versions both stay searchable until one is flagged or removedOpen-ended notes where several matches help
Memory stream (append-only log)Score every record at read time, as Generative Agents doesNothing is overwritten; the newer record has to outscore the older oneExperience records and audit history
Temporal knowledge graphTraversal over entities and the facts that link themA new edge can invalidate an old one, which keeps its validity datesFacts whose history matters
  • Document stores - LangGraph "stores long-term memories as JSON documents in a store," each under a namespace "(similar to a folder)" and a key "(like a file name)." Its in-memory example store carries the comment "Use a DB-backed store in production use."
  • Vector stores - similarity search is the retrieval step of retrieval augmented generation, applied to memories the agent wrote instead of documents a team loaded; how text is embedded and indexed is covered there.
  • Temporal graphs - a 2025 paper on a temporal knowledge graph for agent memory stores four timestamps per fact. Two record when the system created or invalidated it, and two record the period during which it held true. A changed address then becomes a closed interval instead of a deleted row.

Whatever the store, scope every record. LangMem recommends grouping memories "by organization, user, application, or any other hierarchical structure." LangGraph notes that namespaces often include user or org IDs, so put that ID in the key of every read and every write.

A Toy Memory Store That Ships an Order to an Old Address

The script below is a toy store, not a product: standard-library Python executed with Python 3.14.6 on 2026-12-01, with no model call and no network. It replays the opening scenario in six scripted user turns, once with an append-only store and once with a supersede rule.

  • Write policy - a fixed list of turns (1, 2, 4 and 5) stands in for the model's decision about what to save, and those turns are saved as memories m1 to m4. A regular expression tags address statements with the key shipping_address.
  • Retrieval - each live record gets min-max scaled recency (decay 0.9 per turn, a toy value) plus min-max scaled keyword overlap with the query "ship orders address", both weighted 1, with importance left out. That is the Generative Agents formula with keyword overlap standing in for embeddings.
  • Action - at turns 3 and 6 the agent retrieves the top two memories and writes an order record. The address comes from the top hit in the first run and from a keyed lookup in the second.
# toy_memory.py (excerpt, re-wrapped to fit)
DECAY = 0.9  # per turn; toy value

def extract(text):
    # tags address statements with a key
    if re.search(r"\d+ \w+ (st|ave|rd)\b",
                 text.lower()):
        return "shipping_address"
    return None

class ToyMemory:
    def write(self, turn, text):
        key = extract(text)
        if self.supersede and key:
            for m in self.items:
                if m["key"] == key and m["live"]:
                    m["live"] = False  # kept
                    m["ended"] = turn
        # ... append the new record as live

    def retrieve(self, turn, query, k=2):
        pool = [m for m in self.items
                if m["live"]]
        q = words(query)
        rec = [DECAY ** (turn - m["turn"])
               for m in pool]
        rel = [len(q & words(m["text"])) / len(q)
               for m in pool]
        # min-max scale rec and rel, sum (w=1),
        # sort (ties broken by relevance),
        # return the top k

    def lookup(self, key):
        live = [m for m in self.items
                if m["key"] == key and m["live"]]
        return live[-1] if live else None

Running python -I toy_memory.py printed this output:

Toy memory store (stdlib, no model call)
score = recency + relevance, min-max, w=1

== Run: append only ==
t1 write m1
t2 write m2
t3 retrieve for 'ship orders address'
  m1 1.00 (rec 0.00 rel 1.00)
     Ship my orders to 12 Elm St, Austin.
  m2 1.00 (rec 1.00 rel 0.00)
     I prefer email updates over SMS.
  order record ships to: 12 Elm St, Austin
t4 write m3
t5 write m4
t6 retrieve for 'ship orders address'
  m1 1.00 (rec 0.00 rel 1.00)
     Ship my orders to 12 Elm St, Austin.
  m4 1.00 (rec 1.00 rel 0.00)
     Add a phone case to the cart too.
  order record ships to: 12 Elm St, Austin

== Run: supersede by key ==
t1 write m1
t2 write m2
t3 retrieve for 'ship orders address'
  m1 1.00 (rec 0.00 rel 1.00)
     Ship my orders to 12 Elm St, Austin.
  m2 1.00 (rec 1.00 rel 0.00)
     I prefer email updates over SMS.
  lookup shipping_address -> m1
  order record ships to: 12 Elm St, Austin
t4 write m3
t5 write m4
t6 retrieve for 'ship orders address'
  m4 1.00 (rec 1.00 rel 0.00)
     Add a phone case to the cart too.
  m3 0.63 (rec 0.63 rel 0.00)
     We moved last week: 9 Oak Ave, Denver.
  lookup shipping_address -> m3
  order record ships to: 9 Oak Ave, Denver
  m1 superseded at t4
  • Append only fails - at turn 6 the new address (m3, "We moved last week") shares no keyword with the query and misses the top two. The old address m1 scores 0.00 on recency but 1.00 on relevance, ties with the cart note m4 at 1.00 and ranks first because the script breaks ties by relevance. The order record ships to 12 Elm St, Austin: wording beat age.
  • Superseding alone falls short - in the second run m1 is marked superseded at turn 4 and kept. Yet at turn 6 every record scores 0 on relevance, so the scored retrieval ranks the unrelated cart note (m4) first on recency and m3 second at 0.63.
  • The pair works - superseding on write and reading the address by its key returns m3, and the order record ships to 9 Oak Ave, Denver.

The rule to take away: store each fact that has one current value under a key, supersede it on write, and read it by key. Keep similarity search for notes where several partial matches are useful.

What Breaks in Agent Memory?

Memory failures show up in the action taken on a recalled fact, not in an error log, so each row below names where the failure starts and the control that stops it.

FailureWhat happensWhere it startsControl
Stale factA fact that changed keeps being retrieved and acted onAppend-only writes and similarity-only readsSupersede by key, keep validity dates, read by key
Conflicting factsTwo records disagree and retrieval returns either oneOver-inserting new records instead of reconcilingReconcile on write: update or invalidate the older record
Cross-user leakageOne user's stored data appears in another user's sessionA missing namespace, or a shared cache in front of the storeA user or org ID in the key of every read and write
Poisoned memoryInjected content is saved and trusted in later stepsWrites taken from untrusted inputTreated as a security risk, with its own controls
Procedural driftA bad write changes how the agent acts on every later taskAn agent editing its own instructions or codeReview procedural writes like code changes

Leakage does not need the model to misbehave. On March 20, 2023, OpenAI took ChatGPT offline after a bug in the open-source redis-py client library let some users see titles from another active user's chat history. That was a caching bug in a chat product's history layer rather than an agent memory store, and it shows that per-user scoping has to hold in the infrastructure around stored conversations too.

Stale facts are measured directly in LongMemEval, whose knowledge-updates ability checks whether an assistant recognizes changes in the user's personal information over time. Poisoning, where an attacker gets malicious content saved as a memory, is covered with the rest of the agent threat model in AI agent security.

How Is Agent Memory Evaluated?

Agent memory is evaluated on long conversations in which the right answer depends on something said many turns or sessions earlier. Research benchmarks built for that include LongMemEval and LoCoMo.

  • LongMemEval - the LongMemEval benchmark has 500 curated questions embedded in freely scalable chat histories, covering five abilities: information extraction, multi-session reasoning, temporal reasoning, knowledge updates and abstention.
  • LoCoMo - the LoCoMo dataset (Maharana et al., 2024) holds conversations of 300 turns and about 9K tokens on average, spread over up to 35 sessions. Earlier long-dialogue work, its authors note, evaluated models within contexts of no more than five chat sessions.

Broader agent benchmarks such as AgentBench score a model acting in multi-turn environments, from a bash shell to an online shop, rather than memory on its own.

Benchmarks score the model and its memory design on fixed data, while your release decision depends on your own agent. When a stored fact changes or a user comes back, does the agent use the current value? The test method for that question is in the guide to agent memory testing, and the scoring side sits with AI agent evaluation metrics.

Agent Assurance: Recalled Facts and the Records They Drive

A remembered fact matters once the agent acts on it. TestMu AI's Agent Assurance tests agents that act through tools, files and APIs. Each acceptance criterion is graded against evidence such as the records a run wrote, never against the agent's account of its own work.

  • Conversation memory scenarios - the functional class includes a state_context category for conversation memory. The Agent Assurance scenario categories docs show a state_context example with multi_turn: true and max_turns: 4. In those docs, multi_turn, setup_messages and max_turns bound the conversation.
  • A real conversation handle - a multi-turn scenario runs only when the profile records or declares multi_turn, and its open or execute hook should return the target's conversation handle, which rook passes back as ROOK_CONVERSATION on later turns. The rook command does not check the handle during a run: if no hook returns one, every later turn is a fresh session, and independent turns that each look reasonable can pass. Without multi_turn on the profile, those scenarios are skipped, because rook refuses to simulate multi-turn behavior as independent calls.
  • Checked against the record - for the address case, the criterion that settles it is a read-only lookup, run through a tool you have approved, confirming that the order record holds the address from the later turn. The agent saying it used the new address counts for nothing on its own.
  • Unable to Verify - without a read-only check, that criterion is never a pass: it comes back as Unable to Verify, or the scenario is skipped when the verifier it names is unavailable.
  • Invocation - the agent under test is reached through a profile (an MCP tool, a command or an HTTP endpoint) whose reviewable hook scripts open the session, send each turn and collect evidence.

These state_context scenarios cover conversation memory within one run. They do not test long-term memory kept across sessions or inspect what a memory store holds.

The npm route for Rook CLI, the rook command, requires Node.js 20 or newer:

npm install -g @testmuai/rook@latest

If you install through Homebrew or the shell installer, you need no Node at all, and the separate skill package, npx @testmuai/rook-skill, calls for Node.js 22 or later. Trial accounts get 7 days, 10,000 credits and Pro features at no cost; for the plans that follow the trial, see Agent Assurance pricing.

Start a 7-day free trial of Agent Assurance by TestMu AI, with 10,000 credits, to test how your AI agents behave across workflows, tools, and actions

How Should You Start Designing Agent Memory?

List every fact your agent stores that can change, such as addresses, plan tiers and preferences, and give each one a key and a supersede rule before you choose a store. Then add one test in which the fact changes mid-conversation and the record the agent writes afterwards is checked.

A larger context window is no substitute: the LoCoMo authors found that long-context LLMs and RAG improve results on very long conversations but still substantially lag behind human performance. To run the changed-fact check with Agent Assurance, start with the profiles and hooks guide, which shows how a profile returns the conversation handle.

To run your first test, install Agent Assurance with npm install -g @testmuai/rook@latest, or
for a full walkthrough of the product.

Was this helpful?

Authors

Samyak Goyal

Samyak Goyal

Author · 05 hubs

Samyak Goyal is a Senior Member of Technical Staff at TestMu AI engineering Kane CLI, the command-line tool that runs browser automation from the terminal, where a flow described in natural language executes in a real Chrome browser and returns pass or fail with shareable proof. He is a backend engineer with 4+ years of experience, previously an SDE at Innovaccer, where he built APIs, introduced Kafka, and cut deployment from weeks to hours. Samyak also builds multi-agent systems, skill-orchestration frameworks, and a personal copilot that indexes 200+ microservice repositories.

Sirajuddin Khan

Sirajuddin Khan

Reviewer

Sirajuddin Khan is Vice President of Product Management at TestMu AI, where he drives the company's agentic AI product strategy, building a suite of autonomous agents that includes Agentic Browsers and Agentic Visual Testing and shifting the unit of work from test execution to autonomous outcomes. One of the company's earliest product leaders, he has owned the roadmap for the high-performance execution cloud and grew the cross-browser testing products from early adoption to market leadership. He brings over a decade of experience across SaaS, B2B, and eCommerce, with earlier product roles at Wydr and ShopClues, where his catalog and search work cut delivery SLAs and lifted seller activity. Sirajuddin holds an MBA in Information Technology from Sikkim Manipal University and a B.Tech in Computer Science Engineering from Maharshi Dayanand University.

AI Agent Memory FAQs

TestMu AI forEnterprise

Get access to solutions built on Enterprise
grade security, privacy, & compliance

  • Advanced access controls
  • Advanced data retention rules
  • Advanced Local Testing
  • Premium Support options
  • Early access to beta features
  • Private Slack Channel
  • Unlimited Manual Accessibility DevTools Tests