CoreWise Academy

Agents & Automation · Layer III / Deep

Give your agent a memory

A memory store is a workspace-scoped directory your agent reads and writes with normal file tools, carrying preferences and prior mistakes across sessions.

Nº 017 · Vol. I·6 min read· Updated July 2026

Read firstEvery new repo starts with your lessons (Extends the committed-memory-that-travels idea from committed project memory to a managed agent's own persistent store.)
“a session ends and the agent forgets everything, unless you give it somewhere to write”

A Managed Agents session starts fresh. Whatever the agent learned last time (that you prefer two-space indent, that the deploy step needs a manual approval, that it botched the same migration last week) is gone the moment the session ends. That is the default, and for a one-shot task it is the right one. But an agent you come back to 5 days a week should not relearn you every morning.

The fix is a memory store: a workspace-scoped collection of text documents that mounts as a directory the agent reads and writes with its ordinary file tools. Preferences, conventions, prior mistakes, domain context. They go in the directory, and the next session finds them there. For the repo-level counterpart, where committed memory travels with the codebase itself, see Every new repo starts with your lessons.

01A directory, versioned

A memory store is a set of text files, each addressed by a path like /formatting_standards.md. Attach one at session creation and it mounts under /mnt/memory/ at a short name derived from the store’s name. Read the authoritative mount_path off the session’s memory-store resource rather than constructing it yourself. The agent needs its file tools enabled at agent creation to touch the mount at all. A description of every mount lands in the system prompt automatically, so the agent knows what each store holds.

Two details make this safe to run in production. Every change creates an immutable memory version (id prefix memver_), which is your audit trail and your way to restore an earlier version. Versions belong to the store and survive after a memory is deleted, so the history stays complete. And writes only persist if they land under the real mount path; a write anywhere else under /mnt/memory/ goes to temporary local storage and vanishes when the session ends. The store stays in sync across every session that shares it.

02read_only is the big decision

The access field defaults to read_write, and that default is risky. The docs say why: a prompt injection from untrusted input can make one session write malicious content, and a later session reads that content back as trusted memory.

It is the same threat model that Expertise you can install applies to a downloaded skill file: untrusted input you cannot afford to trust blindly. Access is enforced at the filesystem level, so read_only genuinely rejects writes. Use it for reference material and any store the agent has no business modifying. Reserve read_write for the sessions that actually add memories. Every write to a read_write mount is attributed to its session in the version history, so you can always see who wrote what.

03Know the caps before you hit them

The limits are hard, and each one fails in a specific way. A single memory caps at 100 kB, roughly 25 thousand tokens, which is why the docs push many small focused files over a few large ones. A store holds at most 2,000 memories; at the cap, new writes fail (both memories.create and the agent’s own writes to new paths) while existing memories stay readable and editable. A session attaches at most 8 stores, and only in the resources[] array at creation time. You cannot add or drop a store mid-session. Plan the attach list up front.

CapLimitWhat fails at it
Memory size100 kB, about 25 thousand tokensWriting that memory at all
Memories per store2,000New writes; existing entries stay readable
Stores per session8, fixed in resources[] at creationAttaching more, or swapping mid-session

Because each store carries its own 2,000-memory budget, a healthy setup uses several focused stores: a store per end user, a shared domain-knowledge store, a store per project. A common pattern is one read_only shared reference store shared across many sessions, plus a read_write store scoped to whoever is actually writing.

04Keeping it healthy over time

Stores rot the way any pile of notes rots. Three tools keep them clean. Prune stale entries with memories.delete, cheap and direct, every 2 weeks or so: 10 minutes of pruning is better than letting a store sit at 90% of its cap, where it quietly confuses the agent. When a store fragments, a dreaming session consolidates its content into a separate new output store without touching the original; you then switch sessions to the output store and archive the old one. And when a store outgrows its scope, attach a fresh store for new content while reattaching the original as read_only, so the agent reads both but writes only to the new one.

Two more endpoints matter for compliance. Rolling back has no dedicated restore call. Retrieve the memver_ version you want and write it back with memories.update. And the redact endpoint scrubs content from a historical version while preserving its metadata, for leaked secrets, personal data, or a user deletion request. You cannot redact a live memory’s current version, so write a new version or delete the memory first, then redact the old one.

Further reading

FAQ

Why is the read_write default a dangerous one, and when should you override it to read_only?

Because a prompt injection from untrusted input during one session can write malicious content that a later session reads back as trusted memory. The write happens under untrusted conditions, the read happens under trusted ones. The docs warn about exactly this. Override to read_only for reference material and any store the agent has no reason to modify, so the mount rejects writes at the filesystem level.

A store has 1,999 memories and the agent tries to write a new file to an unmapped path. What happens, and what still works?

The write fails once the store is at its 2,000-memory cap, blocking both direct memories.create calls and the agent's own file writes to new paths. Existing memories stay readable and editable; only new memories are blocked. The fix is pruning stale memories with memories.delete, or moving to a fresh store, since each store carries its own 2,000-memory limit.

You need to roll a memory back to last week''s content, and you leaked a secret into an old version. What are the two mechanisms?

There is no restore endpoint. To roll back, retrieve the desired memory version (memver_) and write its content back with memories.update, or memories.create if the parent was deleted. To scrub the secret, use the redact endpoint, which removes content from a historical version while keeping the who-did-what-when metadata. You cannot redact a version that is the current version, so write a new version or delete the memory first.

For your agent

A distilled, agent-ready version of this guide, not a skill. Copy it below, or point the agent at corewise.academy/guides/give-your-agent-a-memory.md.

file · guide.md give-your-agent-a-memory 61 lines · markdown
# Give a managed agent a memory store Consult when a Managed Agents session needs to carry state (preferences, conventions, prior mistakes, domain context) across sessions that otherwise start fresh. For live endpoint shapes, ids, and error codes, check the Anthropic Managed Agents memory docs rather than trusting this file. ## What a memory store is A memory store is a workspace-scoped set of text files, each addressed by a path like `/formatting_standards.md`. It mounts as a directory the agent reads and writes with its ordinary file tools. - Attach a store at session creation. It mounts under `/mnt/memory/` at a short name derived from the store's name.- Read the authoritative `mount_path` off the session's memory-store resource. Do not construct the path yourself.- Enable the agent's file tools at agent creation, or it cannot touch the mount at all.- A description of every mount lands in the system prompt automatically, so the agent knows what each store holds. ## Writes persist only under the real mount path - Every change creates an immutable memory version (id prefix `memver_`). That is the audit trail and the way to restore an earlier version.

+ 45 more lines · the copy includes all of them

then save as .claude/reference/give-your-agent-a-memory.md
Sources

Original work by the editor, no video source.