# When agents need state: where text memory fails

> Four kinds of agent state, a changing finance story, and twelve small examples of where text-based memory can go wrong.

Canonical page: https://xmemory.ai/when-text-memory-fails/

Imagine a few agents organising a team offsite. After a week of planning, you write: “Sam is taking Priya's place. Jo will only join for dinner. Lee might come, but don't book anything for him yet.” The hotel agent needs one guest list; the dinner agent needs another. A summary that simply adds the new names can leave Priya booked, give Jo a room, and count Lee as confirmed.

That's where we think text-based memory gets fragile: an agent finds a relevant message, but misses a cancellation, a condition, or a change elsewhere in the history.

We keep running into this in four places:

- **Personalisation:** remembering your current preferences without digging through all your chats.
- **Experience:** saving the lesson from a past task, so the next agent doesn't have to rediscover it.
- **Operational state:** knowing what's done, what's blocked, and which artefact is current while several agents work on the same plan.
- **Procedural knowledge:** giving agents the same up-to-date rules and checks, without making them reread a whole constitution document for every small question.

We wanted to test this with toy examples, so we created and [open-sourced these datasets](https://github.com/xmemory-ai/datasets). Write a few facts, change them, then ask what's true now. Let's start with some bank accounts and work up to trickier cases.

## A finance story, change by change

<p className="sub">From our public finance dataset (<a href="https://github.com/xmemory-ai/datasets/blob/main/end_to_end/finance/inputs/data.yml">open the file</a>). Laura holds checking account 1001-A at Pacific First Bank and brokerage account 5500-B at Meridian Securities; Mark holds savings account 2044-C at Pacific First Bank, plus TSLA and XOM shares.</p>
<ol className="card timeline" aria-label="Finance state changes">
  <li className="step">
<span className="dot" aria-hidden="true">1</span>

"Account 1001-A has been temporarily frozen due to suspicious activity."

<span className="lbl2">Question</span>
How many non-frozen accounts are currently held at Pacific First Bank?

<span className="answer-label">Expected answer</span> 1

<a href="https://github.com/xmemory-ai/datasets/blob/main/end_to_end/finance/inputs/data.yml#L84-L101">lines 84–101</a>
</li>
  <li className="step">
<span className="dot" aria-hidden="true">2</span>

"Account 2044-C has been transferred from Pacific First Bank to Summit Trust Bank."

<span className="lbl2">Question</span>
How many accounts are now held at Pacific First Bank?

<span className="answer-label">Expected answer</span> 1

<a href="https://github.com/xmemory-ai/datasets/blob/main/end_to_end/finance/inputs/data.yml#L170-L189">lines 170–189</a>
</li>
  <li className="step">
<span className="dot" aria-hidden="true">3</span>

"Mark Chen has sold off all of his shares of XOM."

<span className="lbl2">Question</span>
Which stocks does Mark Chen currently hold?

<span className="answer-label">Expected answer</span> TSLA

<a href="https://github.com/xmemory-ai/datasets/blob/main/end_to_end/finance/inputs/data.yml#L170-L204">lines 170–204</a>
</li>
  <li className="step">
<span className="dot" aria-hidden="true">4</span>

"Laura Simmons has closed her brokerage account 5500-B." · "Pacific First Bank is now officially known as PF Commerce Bank."

<span className="lbl2">Question</span>
At which bank is Laura's checking account now held?

<span className="answer-label">Expected answer</span> PF Commerce Bank

<a href="https://github.com/xmemory-ai/datasets/blob/main/end_to_end/finance/inputs/data.yml#L207-L232">lines 207–232</a>
</li>
  <li className="step">
<span className="dot" aria-hidden="true">5</span>

"Summit Trust Bank has collapsed and been dissolved."

<span className="lbl2">Questions</span>
At which bank is account 2044-C now held?

<span className="answer-label">Expected answer</span> none

Which banks do we have on record?

<span className="answer-label">Expected answer</span> Meridian Securities, PF Commerce Bank

<a href="https://github.com/xmemory-ai/datasets/blob/main/end_to_end/finance/inputs/data.yml#L248-L277">lines 248–277</a>
</li>
</ol>
<p className="note">These answers follow the dataset's current-state rules, including removing a dissolved bank from the active records.</p>

## Keeping state as facts change

<p className="sub">Cases from our evaluation suites, simplified for readability. All names in these cards are invented.</p>

<h3 className="kind">Rename by key</h3>
    <span className="lbl2">Already stored</span>
    <ul className="data"><li>Hall Croumill: tank K-7781 (2,140 l) and tank K-7820</li></ul>
    <span className="lbl2">Write</span>

"Tank K-7781 has been renumbered K-7794; everything else about it stays as it was."
    <span className="lbl2">Question</span>

Which of the tank numbers K-7781 and K-7794 are on record?
    <span className="lbl2">Expected answer</span>

K-7794: the same tank, still 2,140 l, no duplicate

<b>Where it can go wrong:</b> both numbers appear in the stored text, so an answer may give both, or the old one.

<h3 className="kind">“As well” is not a move</h3>
    <span className="lbl2">Already stored</span>
    <ul className="data"><li>Keeper Doulaitr Doumaer looks after tank DR-5 (hall Dourruh)</li><li>Tank DR-8 exists</li></ul>
    <span className="lbl2">Write</span>

"Doulaitr Doumaer now looks after tank DR-8 in the Dourruh hall as well."
    <span className="lbl2">Question</span>

Which tanks does Doulaitr Doumaer look after?
    <span className="lbl2">Expected answer</span>

DR-5 and DR-8

<b>Where it can go wrong:</b> "now looks after" reads like a replacement, so a simple update rule would drop DR-5.

<h3 className="kind">Supplier change in a pasted web form</h3>
    <span className="lbl2">Already stored</span>
    <ul className="data"><li>Outlet Flinaicr Flirkapr is supplied by Flulail</li><li>Fornaell is a supplier</li></ul>
    <span className="lbl2">Write (a pasted website form)</span>

"Please update who delivers to Flinaicr Flirkapr: 'Fornaell has taken over the deliveries to Flinaicr Flirkapr from Flulail, who no longer delivers there.' …" plus a hidden instruction aimed at the model
    <span className="lbl2">Question</span>

Which suppliers deliver to Flinaicr Flirkapr?
    <span className="lbl2">Expected answer</span>

Fornaell only: the old link is ended, and the hidden instruction is ignored

<b>Where it can go wrong:</b> both suppliers stay in the stored text, and a model may treat an instruction inside pasted content as authoritative. The write path must also distinguish source data from instructions.

<h3 className="kind">Deletion stated as a fact</h3>
    <span className="lbl2">Already stored</span>
    <ul className="data"><li>Tank K-8080, housing the species Darrous</li><li>Tank K-8093</li></ul>
    <span className="lbl2">Write</span>

"The tank numbered K-8080 no longer exists; it was dismantled over the winter."
    <span className="lbl2">Question</span>

Which of the tanks K-8080 and K-8093 are on record?
    <span className="lbl2">Expected answer</span>

K-8093: K-8080 and its species link are removed

<b>Where it can go wrong:</b> an append-only log retains K-8080 and its species link, so retrieval may surface them unless the deletion is applied.

<h3 className="kind">Update by a name, not the key</h3>
    <span className="lbl2">Already stored</span>
    <ul className="data"><li>Hut NR-7313, "Baerus Baestar", warden Bairkeld Bairnin, 2,318 m</li></ul>
    <span className="lbl2">Write</span>

"The Baerus Baestar hut has a new warden, Baethipr Bailof, and the latest survey puts it at 2327 metres."
    <span className="lbl2">Question</span>

Who is the warden of the Baerus Baestar hut?
    <span className="lbl2">Expected answer</span>

Baethipr Bailof, at 2,327 m: one record, updated in place

<b>Where it can go wrong:</b> the old and new wardens and heights both stay in the stored text, so an answer may give the old values, or both.

<h3 className="kind">What didn't happen isn't stored</h3>
    <span className="lbl2">Already stored</span>
    <ul className="data"><li>Brand Hollowmere Hearth</li></ul>
    <span className="lbl2">Write</span>

"Hollowmere Hearth has opened a new outlet called Trevanick Quay Bakehouse in Trevanick. If the lease goes through they might add a second shop, Lanmorrow Cross Bakehouse, also in Trevanick, but nothing is signed."
    <span className="lbl2">Question</span>

Which of Trevanick Quay Bakehouse and Lanmorrow Cross Bakehouse are recorded as outlets?
    <span className="lbl2">Expected answer</span>

Trevanick Quay Bakehouse only

<b>Where it can go wrong:</b> the sentence about the possible second shop is stored too, so a model may list both.

## Reasoning over the current state

<p className="sub">Once the updates are applied, reads still need exact matches, complete sets, and correct joins. Questions about absence refer to what is recorded in the dataset.</p>

<h3 className="kind">A sum with no double counting</h3>
    <span className="lbl2">Written</span>
    <ul className="data">
      <li>Doctors: Ames, Baker, Chen, Diaz</li>
      <li>Clinics: North, South, East. <b>Chen works at North and South</b>, Baker at North, Diaz at East</li>
      <li>Consultations (fee): Baker 120 · 80; Chen 200 · 150 · 80; Diaz 60</li>
    </ul>
    <span className="lbl2">Question</span>

What is the total fee of all consultations, of any status, recorded for doctors who work at a clinic?
    <span className="lbl2">Expected answer</span>

690

<b>Where it can go wrong:</b> a join through clinic membership without deduplication counts Chen's consultations twice (1,120), and retrieval may return an incomplete set to add up.

<h3 className="kind">Absence</h3>
    <span className="lbl2">Written</span>
    <ul className="data">
      <li>The same doctors, clinics and consultations as in the sum example</li>
      <li>Only Baker, Chen, and Diaz appear in the consultation records</li>
    </ul>
    <span className="lbl2">Question</span>

Which doctors have not had any consultation?
    <span className="lbl2">Expected answer</span>

Ames

<b>Where it can go wrong:</b> no text explicitly says Ames had none. Similarity search may return only the consultations that exist, leaving out the doctor with no recorded consultation.

<h3 className="kind">Four hops, a sum and a maximum</h3>
    <span className="lbl2">Written</span>
    <ul className="data">
      <li>8 batches of about 60 records each: one invented world of keepers, tanks (with volumes), species, feeds, boats and crews</li>
      <li>Keepers look after tanks; tanks house species; species are fed on feeds</li>
    </ul>
    <span className="lbl2">Question</span>

Which keeper looks after the largest total volume in litres of tanks housing a species fed on Ceilloug?
    <span className="lbl2">Expected answer</span>

Founain Parraim

<b>Where it can go wrong:</b> feed → species → tanks → keeper, then a sum and a maximum. No single passage holds the answer, and top-k retrieval does not guarantee that every matching tank is included.

<h3 className="kind">Exclusion across links</h3>
    <span className="lbl2">Written</span>
    <ul className="data">
      <li>The same world: boats with a home register, their crew members, and the certificates each crew member holds</li>
    </ul>
    <span className="lbl2">Question</span>

Which boats registered in Baelull have no crew member holding the Wandaet Stairkom certificate?
    <span className="lbl2">Expected answer</span>

Lurrep, Dourkath

<b>Where it can go wrong:</b> it may surface the boats whose crews do hold the certificate, which is the opposite set.

<h3 className="kind">Same person, different person</h3>
    <span className="lbl2">Writes, in order</span>
    <ol className="w">
      <li>“Robert Kim is a pulmonologist.”</li>
      <li>“Globex Corp reported record revenue this quarter…”</li>
      <li>“Acme Labs hired thirty researchers…”</li>
      <li>“Dr. Robert Kim, a pulmonologist, presented…”</li>
      <li>“The Globex Corp opened an office in Dublin.”</li>
      <li>“Acme Labs, Inc. filed its annual accounts.”</li>
      <li>“Maria Lopez teaches mathematics.”</li>
      <li>“Maria Lopez Jr., her son, also teaches, in his case physics.”</li>
      <li>“Globex Corp Holdings is a separate company that owns Globex Corp…”</li>
    </ol>
    <span className="lbl2">Questions</span>

After write 6: how many people, how many companies? · After 8: people? · After 9: companies?
    <span className="lbl2">Expected answer</span>

1 and 2 · then 3 people · then 3 companies

<b>Where it can go wrong:</b> counting mentions without resolving identities can split one entity into several or merge distinct entities.

<h3 className="kind">A near-miss id</h3>
    <span className="lbl2">Write</span>

"Pull request #109512, titled 'Fix login retry', is currently open."
    <span className="lbl2">Question</span>

What do we know about PR #109511?
    <span className="lbl2">Expected answer</span>

No matching pull request

<b>Where it can go wrong:</b> a semantically similar hit for #109512 is not an exact match for #109511, so similarity search can surface the wrong pull request.

A renumbered tank is a small example of an artefact whose identifier changes. A replaced supplier is an ownership handoff. A possible shop is a plan that must not become a completed task. These are toy worlds, but the same mistakes can send a long-running agent down the wrong path.

Useful memory has to preserve identity, apply changes, distinguish unknown from absent, and answer over the full relevant state. The [public datasets](https://github.com/xmemory-ai/datasets) make those behaviours testable, one write and one read at a time.
