AgentCore Memory Store
The AgentCore Memory Store, available in Python and TypeScript,
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.
Use this integration for long-term memory through a memory manager. To persist and restore
conversation history, use
SnapshotSessionManagerSessionManager
Requirements
Section titled “Requirements”Use an existing Amazon Bedrock AgentCore Memory resource with extraction strategies and AWS credentials to access it. Match the examples’ namespaces to those configured on your strategies. The store does not create the resource.
bedrock-agentcore >= 1.21.0strands-agents >= 1.56.0
bedrock-agentcore >= 0.4.1@strands-agents/sdk >= 1.5.0
Installation
Section titled “Installation”pip install "bedrock-agentcore[strands-agents]>=1.21.0"npm install bedrock-agentcore @strands-agents/sdkTo recall from multiple namespaces, use
create_agentcore_memory_storescreateAgentCoreMemoryStoresMemoryManager and enable extraction on one writer to capture conversation
turns. Writes go to the shared conversation stream; the memory resource’s strategies
decide which namespaces receive extracted records.
Set AGENTCORE_MEMORY_ID to your memory resource ID.
import os
from strands import Agentfrom strands.memory import MemoryManagerfrom bedrock_agentcore.memory.integrations.strands.memorystore import ( create_agentcore_memory_stores,)
stores = create_agentcore_memory_stores( memory_id=os.environ["AGENTCORE_MEMORY_ID"], actor_id="user-123", session_id="session-1", namespaces=[ {"namespace": "/facts/{actorId}", "writable": True}, {"namespace": "/preferences/{actorId}", "min_score": 0.5}, ], extraction=True, region_name="us-east-1",)
manager = MemoryManager(stores=stores)agent = Agent(memory_manager=manager)The import package is memorystore, without an underscore.
With extraction enabled, the factory selects the first namespace not explicitly
marked writable=False when no writer is specified. Set writable=True on one
namespace to choose the writer explicitly, as above. Omit extraction and writer
flags for recall-only stores.
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 os
from strands import Agentfrom strands.memory import MemoryManagerfrom bedrock_agentcore.memory.integrations.strands.memorystore import ( AgentCoreMemoryStore,)
store = AgentCoreMemoryStore( memory_id=os.environ["AGENTCORE_MEMORY_ID"], actor_id="user-123", session_id="session-1", namespace="/facts/{actorId}", writable=True, extraction=True, region_name="us-east-1",)manager = MemoryManager(stores=[store])agent = Agent(memory_manager=manager)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,})Configuration
Section titled “Configuration”Set namespace-specific options on each factory entry, and identity and extraction
options at the top level. The direct AgentCoreMemoryStore constructor takes all
options in one flat config.
| Option | Type | Description |
|---|---|---|
memory_idmemoryId | string | Memory resource ID. |
actor_idactorId | string | Replaces {actorId}. |
session_idsessionId | string | Replaces {sessionId}. |
namespace | string | Exact namespace prefix for recall. |
namespace_pathnamespacePath | string | Subtree query; direct constructor only, instead of namespace. |
writable | boolean | Enables conversation writes; false by default on a direct store. |
extraction | boolean or config | Enables automatic dispatch, with cadence and filtering. |
min_scoreminScore | number | Minimum relevance score for recall. |
For custom extraction cadence, pass an extraction dictionary with cadence and
filter to the factory. For example, use IntervalTrigger(turns=10) from
strands.memory as the cadence. The direct constructor uses the Strands
ExtractionConfig, whose cadence key is trigger.
See the package README for batching, score filtering, metadata, and the full namespace contract.
See the package README for the full option reference, including subtree reads and over-fetch tuning.
Writes and shutdown
Section titled “Writes and shutdown”Conversation writes use CreateEvent for server-side extraction, preserving user
and assistant roles. Flush pending writes at a shutdown boundary after asynchronous
invocation or streaming.
Synchronous agent(...) calls flush automatically. After agent.invoke_async(...)
or agent.stream_async(...), call await manager.flush() before closing the event
loop. Reuse the manager while the same actor and session remain active to retain
buffered turns and cadence state.
Strands logs extraction write failures and retains failed batches for retry.
A completed flush() alone is not proof that events were persisted.
The store implements add_messages(), not the flat-string add() interface,
so it does not enable the manager’s add_memory tool. Enable extraction to send
conversation turns instead.
Await agent.memoryManager?.flush() at shutdown to settle pending writes.
A completed flush does not confirm that server-side extraction has finished. Monitor write failures in logs; newly extracted records may not be immediately searchable.
- One writable store per session. Mark at most one store
writablefor a given memory resource, actor, and session: multiple writers would emit duplicate events to the same stream. The factory rejects configurations with more than one writer. - 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. - Cross-session recall. A namespace containing
{sessionId}scopes recall to that session. Use an actor-only namespace to recall memories across sessions.