AgentCore Memory
AWS Bedrock AgentCore Memory adapter — session/event-based managed memory. Lazy-required @aws-sdk/client-bedrock-agentcore peer-dep.
AWS Bedrock AgentCore is a managed memory service — sessions, events, retrieval, summarization all server-side. agentfootprint's
AgentCoreStoremaps theMemoryStoreinterface onto AgentCore's session/event model so you can use it as a drop-in forInMemoryStorein production.
Install
npm install @aws-sdk/client-bedrock-agentcoreLazy peer-dep declared in peerDependenciesMeta with optional: true. AWS credentials resolved via the standard SDK chain (env, profile, IAM role).
Subpath import
// Canonical subpath:
import { AgentCoreStore } from 'agentfootprint/memory-providers';
// Legacy alias (still exported, kept for back-compat):
import { AgentCoreStore } from 'agentfootprint/memory-providers';Subpath keeps the main barrel small + lets bundlers tree-shake when AgentCore isn't used. Prefer agentfootprint/memory-providers (the canonical location, shared with RedisStore); agentfootprint/memory-agentcore remains as a back-compat alias.
Use
const store = new AgentCoreStore({ memoryId: 'arn:aws:bedrock-agentcore:us-west-2:000000000000:memory/demo', _client: fakeClient,});const memory = defineMemory({ id: 'agentcore-window', description: 'Last 10 turns persisted in AgentCore Memory.', type: MEMORY_TYPES.EPISODIC, strategy: { kind: MEMORY_STRATEGIES.WINDOW, size: 10 }, store,});The store implements every MemoryStore method except search(). Pair with defineMemory({ store, ... }) like any other adapter.
Mapping to AgentCore primitives
MemoryStore call | AgentCore mapping |
|---|---|
MemoryIdentity tuple | AgentCore sessionId (derived deterministically from identity) |
MemoryEntry | AgentCore event payload (JSON envelope keyed by entry id) |
put / putMany | PutMemoryEvent (sequentialized — no batch API) |
get | GetMemoryEvent |
list | ListMemoryEvents (cursor via nextToken) |
delete | DeleteMemoryEvent |
forget | DeleteMemorySession |
seen / recordSignature | In-process shadow Map (NOT durable — see caveats) |
feedback / getFeedback | In-process shadow Map (NOT durable) |
search | NOT exposed — see caveats |
Caveats (call out before adopting)
These are documented in the JSDoc; promoted here for visibility:
-
putIfVersionis emulated — AgentCore'sPutMemoryEventoverwrites unconditionally. The adapter does read-then-write inside a JS critical section. Adequate for single-writer-per-session deploys; weaker for multi-writer. -
Built-in summarization may double-compress — AgentCore has its own server-side summarization. Mixing
defineMemory({ strategy: SUMMARIZE })on top will double-compress. Pick one summarizer. -
seen/feedbackare in-process — they don't survive process restart. For durable recognition, useRedisStoreinstead (or layer Redis on top of AgentCore). -
search()not exposed — AgentCore's retrieval API is opaque (server-side retrieval pipeline). Mapping it toMemoryStore.search(cosine + threshold) would be a leaky abstraction. A separate read-side retrieve helper may land in a future release; until then, use a vector-capable store (e.g.InMemoryStorewith an embedder, or Redis) when you needsearch(). -
AWS rate limits apply — production deployments should wrap with
withRetryand budget calls per session. AWS SDK has built-in retry; tune via the SDK'smaxAttemptsconfig.
Test injection
AgentCoreStore({ _client: ... }) accepts a mock-injected client for tests — no live AWS account needed for CI:
const mockClient = {
putEvent: async () => ({}),
getEvent: async () => ({ payload: '...' }),
listEvents: async () => ({ events: [] }),
deleteEvent: async () => ({}),
deleteSession: async () => ({}),
};
const store = new AgentCoreStore({ memoryId: 'test', _client: mockClient });When to use AgentCore vs Redis vs InMemory
- Production AWS-native deployment — AgentCore is the natural choice if you're already on Bedrock.
- Production multi-tenant with low latency + durable feedback — Redis (RedisStore).
- Dev / test / single-process — InMemoryStore.
- Hybrid — combine: AgentCore for causal snapshots; Redis for hot recent + feedback.
Next steps
- Memory store adapters — full adapter matrix
- Memory guide — types × strategies that pair with this store
- AWS Bedrock provider — paired LLM provider
Memory store adapters
Where memory lives. InMemoryStore for dev; RedisStore + AgentCoreStore production-ready; DynamoDB / Postgres / Pinecone planned.
Ports & adapters — run on any infra
agentfootprint is framework-side. Everything that touches your infrastructure — memory, identity, observability, tools — is a PORT with swappable ADAPTERS, so the same agent runs on AWS, GCP, Azure, or your own stack with a one-line change.
