AgentCore Memory is a managed persistent memory store for AgentCore Runtime agents. It lets AI agents store and recall information across sessions — conversation history, user preferences, and accumulated context — without managing a separate database. Define it as an AgentCoreMemory resource in your Stacktape config and reference it from an AgentCore Runtime.
When to use
AgentCore Memory is the right choice when your AI agents need cross-session persistence integrated directly with an AgentCore Runtime. Typical scenarios:
- Conversational agents that recall prior exchanges with a user across separate sessions.
- Support agents that track customer preferences, prior issues, and handoff context over time.
- Knowledge-accumulating agents that build up domain understanding through ongoing interactions.
AgentCore Memory supports an event retention period and customer-managed encryption. It also accepts configurable memory strategies whose shape is defined by the AWS Bedrock AgentCore API.
When NOT to use
AgentCore Memory is scoped to the AgentCore ecosystem. Choose a different resource when your needs fall outside that scope.
- General-purpose database: Use a DynamoDB table or a relational database for structured application data.
- File or blob storage: Use an S3 bucket.
- Single-session agent context: If your agent's state lives entirely within one request or session, manage it in-process or pass it through the conversation payload — no memory resource needed.
- Non-AgentCore compute: The provided types only document direct AgentCore Memory wiring through
AgentCoreRuntimeProps.useMemory; they do not documentconnectToenvironment variable injection for AgentCore Memory. If another workload needs to call Bedrock AgentCore directly, passidorarnwith$ResourceParam()and configure the required IAM permissions explicitly.
Basic example
A minimal AgentCore Memory requires no properties — all fields are optional.
Connecting to an AgentCore Runtime
AgentCoreRuntimeProps exposes an optional useMemory string. The examples below set it to the name of an AgentCoreMemory resource.
The runtime example below uses DockerfilePackaging, but AgentCore Runtime supports the same container packaging types as other Stacktape container workloads: js-bundle, buildpack, dockerfile and prebuilt-image.
AgentCore Memory exposes id and arn as referenceable parameters. To pass the memory ID into your runtime container, add an explicit environment variable using the $ResourceParam() directive:
In a Node.js runtime, for example, read the memory ID from the environment variable:
AgentCoreRuntimeProps exposes useMemory as an optional string. Set it to the name of your AgentCoreMemory resource. To access the memory ID in your application code, pass it explicitly through environment using $ResourceParam() as shown above.
Memory expiration
eventRetentionDays sets how many days AgentCore keeps raw memory events before deleting them. It defaults to 30; AWS accepts 7 to 365 days.
Choose a retention window that balances recall usefulness against storage growth. Shorter windows suit transient conversational context; longer windows work for agents that accumulate user preferences or project knowledge over time.
Memory strategies
The memoryStrategies property accepts an array of strategy objects. The Stacktape TypeScript type for memoryStrategies is any[], so the provided config types do not describe the inner shape. Consult the AWS Bedrock AgentCore documentation for the available strategy types, required fields, and whether multiple strategies can be combined on a single memory resource.
Encryption
AgentCore Memory accepts an optional encryptionKeyArn property for specifying a customer-managed KMS key. Provide the ARN of a KMS key from your AWS account when your compliance requirements mandate customer-managed encryption.
AgentCoreMemoryProps exposes encryptionKeyArn as an optional string. The provided Stacktape type does not describe default encryption behavior or key requirements when this property is omitted — consult the AWS Bedrock AgentCore documentation for encryption defaults. Customer-managed KMS keys are typically used when compliance processes require encryption key auditing and rotation control. Replace the placeholder ARN below with your own KMS key ARN.
Examples
Encrypted memory with custom retention
A memory resource configured with a customer-managed KMS key, a 180-day retention window, and tags. This pattern suits compliance-sensitive workloads where encryption key auditing is required. Replace the placeholder KMS ARN with your own key.
AgentCore Runtime with dedicated memory
A complete config with an AgentCoreMemory wired to an AgentCore Runtime via useMemory. The memory ID is passed into the runtime container as an environment variable using $ResourceParam().
Referenceable parameters
AgentCore Memory exposes id and arn as referenceable parameters, accessible via the $ResourceParam() directive.
| Parameter | Description |
|---|---|
id | The unique memory ID assigned by AWS. Typically used to interact with the memory through the Bedrock AgentCore SDK. |
arn | The full ARN of the memory resource. Typically used when referencing the memory in IAM policies or cross-stack outputs. |
Reference these from other parts of your configuration. For example, pass the memory ID to a runtime container:
Or pass the ARN to a deployment script:
API Reference
AgentCoreMemoryPropsAgentCore Memory FAQ
How do I connect AgentCore Memory to an AgentCore Runtime?
Set the useMemory property on your AgentCore Runtime to the name of the memory resource defined in your config. This wires the two together, but it does not expose the memory ID to your application code — to read it at runtime, pass it through an explicit environment variable using $ResourceParam('memoryResourceName', 'id'). See the Connecting to an AgentCore Runtime section for a complete example.
How do I configure memory strategies?
The memoryStrategies property accepts an array of strategy objects, but it is typed as any[] in Stacktape — the config surface does not validate or document the inner shape. The strategy types, required fields, and how they extract and consolidate information are defined entirely by the AWS Bedrock AgentCore API. Consult the AWS Bedrock AgentCore documentation for the available strategies and their behavior.
Can I encrypt AgentCore Memory with my own KMS key?
Yes. Set the encryptionKeyArn property to the ARN of a customer-managed KMS key in your AWS account when your compliance process requires a specific key. When omitted, no customer-managed key is configured at the Stacktape config layer. Customer-managed keys are typically needed for encryption key auditing and rotation control in regulated industries.
AgentCore Memory vs DynamoDB for agent state — which should I use?
AgentCore Memory integrates directly with AgentCore Runtime through the useMemory property and supports configurable memory strategies for organizing recalled information. DynamoDB is a general-purpose key-value store that works with any compute resource and gives you full schema control. Use AgentCore Memory when your agent runs on AgentCore Runtime and you want managed memory; use DynamoDB when you need broader flexibility or aren't using AgentCore.
How do I delete or reset stored memories?
The AgentCoreMemoryProps type does not expose selective deletion of individual memory entries. Removing the resource from your config and redeploying, or deleting the stack with stacktape delete, follows the standard Stacktape resource deletion workflow. For data lifecycle details — whether stored memory data is permanently deleted, retained, or recoverable — consult the AWS Bedrock AgentCore documentation.
Can multiple AgentCore Runtimes reference the same memory resource?
The useMemory property on AgentCoreRuntimeProps accepts a string. The Stacktape type does not restrict useMemory to a single runtime, but the provided types do not document concurrency, isolation, or sharing semantics. Consult the AWS Bedrock AgentCore documentation before pointing multiple runtimes at the same memory resource.