Skip to content

AgentCore Memory Store

The AgentCore Memory Store implements the Strands MemoryStore interface on top of Amazon Bedrock AgentCore Memory. Search maps to AgentCore’s retrieveMemoryRecords, and conversation turns are ingested for server-side memory extraction into long-term records. Attach it to an agent through a MemoryManager like any other store. See the Getting Started section for more information.

Terminal window
npm install bedrock-agentcore @strands-agents/sdk

createAgentCoreMemoryStores builds one store per namespace over a shared client, and you attach them to an agent through a MemoryManager. Mark a namespace writable to capture the conversation into it; a namespace left unmarked stays read-only for recall.

import { Agent, MemoryManager, BedrockModel } from '@strands-agents/sdk'
import { createAgentCoreMemoryStores } from 'bedrock-agentcore/memory/strands'
const stores = createAgentCoreMemoryStores({
memoryId: 'mem-abc',
actorId: 'user-123',
sessionId: 'session-1',
namespaces: [
{ namespace: '/facts/{actorId}', writable: true },
{ namespace: '/preferences/{actorId}', minScore: 0.5 },
],
extraction: true,
})
const agent = new Agent({
model: new BedrockModel(),
memoryManager: new MemoryManager({ stores }),
})

A single AgentCoreMemoryStore can also be constructed directly when you only need one namespace:

import { AgentCoreMemoryStore } from 'bedrock-agentcore/memory/strands'
const store = new AgentCoreMemoryStore({
memoryId: 'mem-abc',
actorId: 'user-123',
sessionId: 'session-1',
namespace: '/facts/{actorId}',
writable: true,
extraction: true,
})

In createAgentCoreMemoryStores, namespace, writable, and minScore are set per namespaces entry, while everything else is passed once at the top level. The direct AgentCoreMemoryStore constructor takes all options in one flat config.

OptionTypeDescription
memoryIdstringThe AgentCore Memory resource to read from and write to.
actorIdstringIdentifies the user; substituted into {actorId} placeholders.
sessionIdstringIdentifies the conversation; substituted into {sessionId} placeholders.
namespacestringExact namespace prefix for recall. Use namespacePath instead to query a whole subtree.
writablebooleanEnables writing conversation turns for extraction. Defaults to false.
extractionboolean | objectTurns on server-side extraction, with optional cadence and filter config.
minScorenumberDrops recalled records below this relevance threshold.

See the package README for the full option reference, including subtree reads and over-fetch tuning.

  • One writable store per session. Mark at most one store writable for a given (actorId, sessionId): because writes are namespace-free, multiple writable stores would emit duplicate events to the same (memoryId, actorId, sessionId) stream. createAgentCoreMemoryStores enforces this and throws if more than one store is writable.
  • Placeholders resolve at construction. Only {actorId} and {sessionId} are substituted client-side, into the namespace used for recall. Any other placeholder in a namespace causes construction to throw. Provision strategies with {actorId}/{sessionId}-only templates to match.
  • Eventual consistency. Writes and extraction are asynchronous, so a fact written this turn may not be retrievable on the next one.