How to Mount a Memory Store to a Session with Read_Write Access
To mount a memory store to a session with read_write access, pass a JSON resource descriptor containing "type": "memory_store", "memory_store_id", and "access": "read_write" to the --resource flag when creating a session via the Anthropic CLI.
The anthropics/cwc-workshops repository demonstrates how to enable persistent memory for Claude with Computer (CwC) agents. Mounting a memory store to a session with read_write access grants the agent permission to read existing data and persist new information across conversational turns, creating continuity that survives beyond a single session.
Construct the Memory Store Resource Descriptor
Before creating the session, build a JSON object that describes the memory store and its access level. According to the source code in agents-that-remember/README.md (lines 46–49), the resource descriptor must include four key fields:
type: Must be the literal string"memory_store".memory_store_id: The unique identifier returned when you created the store.prompt: A system prompt extension that instructs the agent when and how to use the memory (optional but recommended).access: Set to"read_write"to enable both read and write operations.
MEM_RESOURCE='{
"type":"memory_store",
"memory_store_id":"'"$MEM"'",
"prompt":"Track which CwC sessions I have attended, resource links I mention, and anything I flag to follow up on.",
"access":"read_write"
}'
Create the Session with the Resource Flag
Attach the memory store to a new session by passing the JSON descriptor to the --resource flag in the ant beta:sessions create command. The agent receives read_write permissions only when the access field is explicitly set to "read_write" in the resource descriptor.
ant beta:sessions create \
--agent "$AGENT" \
--environment-id "$ENV" \
--title "Attended — CMA talk (with memory)" \
--resource "$MEM_RESOURCE" \
--format json | jq -r .id
When the session initializes, the platform spins up a short-lived container and mounts the memory store as a filesystem-like resource. The access field controls the mount’s permission mode, allowing the agent to invoke beta:memory-stores:memories create for writes and beta:memory-stores:memories retrieve for reads.
Architectural Details
Container Mount Point: The memory store appears inside the session container under /mnt/session/uploads/ (or a similar mount path), exposing a persistent filesystem that the agent can interact with using standard file operations.
Prompt Injection: The prompt string defined in your resource descriptor is automatically prepended to the system prompt, guiding the model’s behavior regarding when to read from or write to the store.
Cross-Session Persistence: All data written by the agent is stored as memories within the memory store object. You can inspect these entries via the CLI (ant beta:memory-stores:memories list) or the Console UI, and you can attach the same MEM_RESOURCE to future sessions to maintain continuity.
Complete CLI Workflow Example
Follow this end-to-end workflow to create a memory store and mount it with read_write access. First, create the memory store itself (see agents-that-remember/README.md lines 21–25):
# Create the memory store (run once per workspace)
MEM=$(ant beta:memory-stores create \
--name "cwc-memory" \
--description "My CwC attendance and resources" \
--format json | jq -r .id)
Next, construct the resource descriptor and create the session:
# Build the resource descriptor
MEM_RESOURCE='{
"type":"memory_store",
"memory_store_id":"'"$MEM"'",
"prompt":"Track which CwC sessions I have attended, resource links I mention, and anything I flag to follow up on.",
"access":"read_write"
}'
# Create the session with the mounted store
SESSION_ID=$(ant beta:sessions create \
--agent "$AGENT" \
--environment-id "$ENV" \
--title "Attended — CMA talk (with memory)" \
--resource "$MEM_RESOURCE" \
--format json | jq -r .id)
# Send a message (the agent will write to the store)
ant beta:sessions:events send \
--session-id "$SESSION_ID" \
--event '{"type":"user.message","content":[{"type":"text","text":"I attended the CMA talk yesterday at noon and uploaded my notes."}]}'
# Stream the response
ant beta:sessions:events stream \
--session-id "$SESSION_ID" \
--max-items -1 --format pretty
Alternative: Console UI Method
You can also mount a memory store using the Anthropic Console web interface:
- Navigate to Memory Stores → New Memory Store, enter a name (e.g.,
cwc-memory), and provide a description. - When creating a new session, expand the Resources section.
- Select your memory store from the dropdown, set Access to Read & write, and optionally paste the same prompt text used in the CLI example.
- Create the session and interact normally; the agent will automatically read from and write to the mounted store.
Summary
- Mounting requires the
--resourceflag: Pass a JSON descriptor toant beta:sessions createto attach a memory store. - Use
"access": "read_write": This specific value grants the agent permission to persist data, not just read it. - Storage is persistent: Memories survive beyond the session lifecycle and can be shared across multiple sessions or different agents.
- Reference files: Implementation details are documented in
agents-that-remember/README.md, with setup scripts available inagents-that-remember/scripts/bootstrap.shand API key configuration templates in.env.example.
Frequently Asked Questions
What CLI flag mounts a memory store to a session?
The --resource flag in the ant beta:sessions create command accepts a JSON string describing the memory store, including its ID and access level. This flag injects the mount into the session container at startup.
What happens if I omit the access field in the resource descriptor?
If you omit the access field or set it to a value other than "read_write", the agent may default to read-only permissions or fail to write persistently. Always explicitly set "access": "read_write" when you need the agent to save data to the store.
Where does the agent access the memory store inside the container?
The memory store is mounted as a filesystem-like resource accessible under /mnt/session/uploads/ (or similar container paths). The agent reads and writes files to this location, which the platform synchronizes to the persistent memory store backend.
Can multiple sessions use the same memory store simultaneously?
Yes. You can attach the same memory_store_id with read_write access to multiple concurrent sessions. All sessions share a single persistent view of the data, enabling collaborative or parallel agentic workflows that read and write shared state.
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →