Skip to content
The AI Agent Factory

31.4 Making memory safe

Approved by
Panaversity ·
6 min read

In everyday life. A shared family recipe book sits in a kitchen where many people cook. If two cousins edit the same page at once, one loses their change. If a child scribbles "add a cup of salt", everyone who cooks from it ruins the dish. So the family writes each change with a date and a name, and checks that the page has not changed before writing on it. The master copy stays where only the grandparents can write.

What you will learn. Four guardrails that every shared memory needs, and what each one prevents. You practise them in Lab 31, Tasks 1 and 2.

Why it matters. Memory that is safe on one laptop breaks when many runs and many people share it.

What goes wrong at scale?

The talk lists four failures that appear when memory is shared:1

  • Many runs write to one file at once.
  • One run's mistake spreads to every other run.
  • People and workers edit the same memory, with no record of who changed what.
  • Memories are wrong, out of date, or planted by text the worker read.

Four guardrails answer them. The second relies on a hash, a short fingerprint of a file's content: change one letter and the fingerprint changes.

GuardrailWhat it doesWhat it prevents
VersionsKeep every version, with the session or person that made itA bad change that nobody can trace or undo
A hash checkCheck, just before writing, that the note has not changed since you read itTwo writers, one lost change
Read-only shared memoryShared memory is read-only. Each run writes only to its own spaceOne run's mistake reaching every run
One clean interfaceMemory is reached the same way from every toolMemory locked inside one tool

A hash check works like this. Read the note's hash before you draft a change. Check the hash again just before you write. If it has changed, someone else wrote first: read the note again, redraft and retry.

Claude Managed Agents provides all four.2 Every write makes a memory version with an audit trail. Versions are kept for 30 days, except the recent versions of a live memory. There is no restore button: to roll back, you write an old version's content again. A write can carry the hash it read, and it applies only if the stored content still has that hash. A store attaches read-only or read-write, and a read-only store rejects writes. All stores are managed through one API.

Checking a hash before writing is called optimistic concurrency: assume nobody else is writing, and check before you commit.

Why does it matter that shared memory is read-only?

Because a worker reads text it did not write. Invoices, vendor emails and tool results are written by others. You met this risk as the risky pair in 7.3, and as untrusted tool output in 17.7. Anthropic's documentation warns that if a worker with write access processes such text, a successful prompt injection could write into the store, and later sessions would read it as trusted memory.2 At Brightline, the published memory is mounted read-only in every run: each run sees it as a folder it can read but not change. A run may write only to its own scratch folder, and nothing in a scratch folder is read by another run until it passes 31.6.

Is this reinventing a database?

In part, and on purpose. Asked this in the talk's questions, Mukta said the real work is choosing. Some parts the worker decides on its own. Others the harness enforces with fixed rules.1 Versions and hash checks are old software practice. They are built into the product because workers should not improvise them.

Check yourself

Question 1 / 2

0 answered

Two runs draft a change to the same memory note at once. What stops one change from silently replacing the other?

  1. Learning while you sleep: Beyond memory to dreaming (Lamis Mukta, Anthropic, AI Native DevCon London, June 2026).↑↑2
  2. Memory stores (Claude Managed Agents documentation).↑↑2
Owner
Panaversity