Skip to main content
Use memory stores when you need durable context that is usable across users, sessions, and agents and is accessible by outside applications. Memory stores are useful for storing account notes, support playbooks, bug reports, or any content you want to reuse across many agent runs. API Reference:

1. Create the memory store

Create a store for one durable body of knowledge. Use instructions to describe how entries should be written and maintained.
The response includes a memory store ID such as mem_store_.... The visibility determines whether this memory store is usable for just a specific X-On-Behalf-Of (private), or whether any user regardless of X-On-Behalf-Of can access it (workspace). See the Create memory store API reference for the full schema.

2. Add memory entries

Entries are addressable by path. Use predictable paths so the agent can find files in the mounted store.
The entry response includes an entry ID and content hash. Save both when your application may update the entry later.

3. Create the saved agent

Create an agent with a shell tool and mount the memory store into the shell environment. The mount object uses:
  • store_id: the memory store ID to mount
  • label: the directory name under /mnt/memory
  • access: read_only or read_write
  • description and instructions: optional context for how the agent should use the mounted store
Use read_only for reference material. Use read_write only when the agent should be allowed to update memory through the mounted filesystem. When the agent writes, edits, or deletes files inside a read_write mount, the sandbox syncs those changes back to the memory store after the shell command finishes.
See the Create an agent API reference for the complete saved agent request shape.

4. Run the agent and update memory

Run the saved agent with the task-specific input. The agent can inspect mounted memory files through the shell tool when it needs durable context. If the mounted store is read_write, the agent can also update memory by writing files under /mnt/memory/<label>. The sandbox restores mounted files before the shell command runs, snapshots them, and syncs changed files back to the store after the command completes.
Use Retrieve an agent run to poll status. Use Stream agent run events for live progress. The agent should use the shell tool to read the mounted files and write durable updates directly into the read_write mount.

5. Inspect memory after the run

After the run completes, use the Memory Stores API to inspect what changed. The same files the agent writes in /mnt/memory/acme_support are available as memory entries.
See the List memory entries API reference and Retrieve memory entry API reference for response details.

Operational notes

  • Use read_only mounts for reference memory and read_write mounts for agents that are trusted to edit durable memory.
  • Let agents update durable memory by writing files in read_write mounts through the shell tool.
  • Use direct Memory Stores API updates for seeding, review flows, admin corrections, or imports.
  • Keep memory entries small enough for the agent to inspect only relevant files during a run.
  • Use stable path values so your application can map product objects to memory entries.
  • Store external object IDs in metadata when you need to reconcile memory with your database.
  • Delete obsolete entries with the Delete memory entry endpoint.