class MemoryStrategy
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Bedrock.Agentcore.Alpha.MemoryStrategy |
Go | github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2#MemoryStrategy |
Java | software.amazon.awscdk.services.bedrock.agentcore.alpha.MemoryStrategy |
Python | aws_cdk.aws_bedrock_agentcore_alpha.MemoryStrategy |
TypeScript (source) | @aws-cdk/aws-bedrock-agentcore-alpha ยป MemoryStrategy |
Factory class for creating memory strategies If you need long-term memory for context recall across sessions, you can setup memory extraction strategies to extract the relevant memory from the raw events.
Use built-in strategies for quick setup, use built-in strategies with override to specify models and prompt templates.
Example
// Create a custom semantic memory strategy
const customSemanticStrategy = agentcore.MemoryStrategy.usingSemantic({
name: "customSemanticStrategy",
description: "Custom semantic memory strategy",
namespaces: ["/custom/strategies/{memoryStrategyId}/actors/{actorId}"],
customConsolidation: {
model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
appendToPrompt: "Custom consolidation prompt for semantic memory",
},
customExtraction: {
model: bedrock.BedrockFoundationModel.ANTHROPIC_CLAUDE_3_5_SONNET_V1_0,
appendToPrompt: "Custom extraction prompt for semantic memory",
},
});
// Create memory with custom strategy
const memory = new agentcore.Memory(this, "MyMemory", {
memoryName: "my-custom-memory",
description: "Memory with custom strategy",
expirationDuration: cdk.Duration.days(90),
memoryStrategies: [customSemanticStrategy],
});
Initializer
new MemoryStrategy()
Methods
| Name | Description |
|---|---|
| static using | Default strategies for organizing and extracting memory data, each optimized for specific use cases. |
| static using | Default strategies for organizing and extracting memory data, each optimized for specific use cases. |
| static using | Default strategies for organizing and extracting memory data, each optimized for specific use cases. |
| static using | Creates a self-managed memory strategy. |
| static using | Creates a semantic memory strategy with custom configuration. |
| static using | Creates a summarization memory strategy with custom configuration. |
| static using | Creates a user preference memory strategy with custom configuration. |
static usingBuiltInSemantic()
public static usingBuiltInSemantic(): ManagedMemoryStrategy
Returns
Default strategies for organizing and extracting memory data, each optimized for specific use cases.
Distills general facts, concepts, and underlying meanings from raw conversational data, presenting the information in a context-independent format. Extracted memory example: In-context learning = task-solving via examples, no training needed.
static usingBuiltInSummarization()
public static usingBuiltInSummarization(): ManagedMemoryStrategy
Returns
Default strategies for organizing and extracting memory data, each optimized for specific use cases.
This strategy compresses conversations into concise overviews, preserving essential context and key insights for quick recall. Extracted memory example: Users confused by cloud setup during onboarding.
static usingBuiltInUserPreference()
public static usingBuiltInUserPreference(): ManagedMemoryStrategy
Returns
Default strategies for organizing and extracting memory data, each optimized for specific use cases.
Captures individual preferences, interaction patterns, and personalized settings to enhance future experiences. Extracted memory example: User needs clear guidance on cloud storage account connection during onboarding.
static usingSelfManaged(config)
public static usingSelfManaged(config: SelfManagedStrategyProps): SelfManagedMemoryStrategy
Parameters
- config
Selfโ - The configuration for the self-managed memory strategy.Managed Strategy Props
Returns
Creates a self-managed memory strategy.
A self-managed strategy gives you complete control over your memory extraction and consolidation pipelines.
static usingSemantic(config)
public static usingSemantic(config: ManagedStrategyProps): ManagedMemoryStrategy
Parameters
- config
Managedโ - The configuration for the semantic memory strategy.Strategy Props
Returns
Creates a semantic memory strategy with custom configuration.
Distills general facts, concepts, and underlying meanings from raw conversational data, presenting the information in a context-independent format. Extracted memory example: In-context learning = task-solving via examples, no training needed.
static usingSummarization(config)
public static usingSummarization(config: ManagedStrategyProps): ManagedMemoryStrategy
Parameters
- config
Managedโ - The configuration for the summarization memory strategy.Strategy Props
Returns
Creates a summarization memory strategy with custom configuration.
This strategy compresses conversations into concise overviews, preserving essential context and key insights for quick recall. Extracted memory example: Users confused by cloud setup during onboarding.
static usingUserPreference(config)
public static usingUserPreference(config: ManagedStrategyProps): ManagedMemoryStrategy
Parameters
- config
Managedโ - The configuration for the user preference memory strategy.Strategy Props
Returns
Creates a user preference memory strategy with custom configuration.
Captures individual preferences, interaction patterns, and personalized settings to enhance future experiences. Extracted memory example: User needs clear guidance on cloud storage account connection during onboarding.

.NET
Go
Java
Python
TypeScript (