SelfManagedStrategyProps Struct
Configuration parameters for a self managed memory strategy existing built-in default prompts/models.
| Source | aws-bedrockagentcore/lib/memory/strategies/self-managed-strategy.ts |
|---|---|
| Type last changed |
Example
ts
const bucket = new s3.Bucket(this, 'memoryBucket', {
bucketName: 'test-memory',
removalPolicy: cdk.RemovalPolicy.DESTROY,
autoDeleteObjects: true,
});
const topic = new sns.Topic(this, 'topic');
// Create a custom semantic memory strategy
const selfManagedStrategy = agentcore.MemoryStrategy.usingSelfManaged({
strategyName: "selfManagedStrategy",
description: "self managed memory strategy",
historicalContextWindowSize: 5,
invocationConfiguration: {
topic: topic,
s3Location: {
bucketName: bucket.bucketName,
objectKey: 'memory/',
}
},
triggerConditions: {
messageBasedTrigger: 1,
timeBasedTrigger: cdk.Duration.seconds(10),
tokenBasedTrigger: 100
}
});
// 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: [selfManagedStrategy],
});
python
bucket = s3.Bucket(self, "memoryBucket",
bucket_name="test-memory",
removal_policy=cdk.RemovalPolicy.DESTROY,
auto_delete_objects=True
)
topic = sns.Topic(self, "topic")
# Create a custom semantic memory strategy
self_managed_strategy = agentcore.MemoryStrategy.using_self_managed(
strategy_name="selfManagedStrategy",
description="self managed memory strategy",
historical_context_window_size=5,
invocation_configuration=agentcore.InvocationConfiguration(
topic=topic,
s3_location=s3.Location(
bucket_name=bucket.bucket_name,
object_key="memory/"
)
),
trigger_conditions=agentcore.TriggerConditions(
message_based_trigger=1,
time_based_trigger=cdk.Duration.seconds(10),
token_based_trigger=100
)
)
# Create memory with custom strategy
memory = agentcore.Memory(self, "MyMemory",
memory_name="my-custom-memory",
description="Memory with custom strategy",
expiration_duration=cdk.Duration.days(90),
memory_strategies=[self_managed_strategy]
)
java
Bucket bucket = Bucket.Builder.create(this, "memoryBucket")
.bucketName("test-memory")
.removalPolicy(RemovalPolicy.DESTROY)
.autoDeleteObjects(true)
.build();
Topic topic = new Topic(this, "topic");
// Create a custom semantic memory strategy
SelfManagedMemoryStrategy selfManagedStrategy = MemoryStrategy.usingSelfManaged(SelfManagedStrategyProps.builder()
.strategyName("selfManagedStrategy")
.description("self managed memory strategy")
.historicalContextWindowSize(5)
.invocationConfiguration(InvocationConfiguration.builder()
.topic(topic)
.s3Location(Location.builder()
.bucketName(bucket.getBucketName())
.objectKey("memory/")
.build())
.build())
.triggerConditions(TriggerConditions.builder()
.messageBasedTrigger(1)
.timeBasedTrigger(Duration.seconds(10))
.tokenBasedTrigger(100)
.build())
.build());
// Create memory with custom strategy
Memory memory = Memory.Builder.create(this, "MyMemory")
.memoryName("my-custom-memory")
.description("Memory with custom strategy")
.expirationDuration(Duration.days(90))
.memoryStrategies(List.of(selfManagedStrategy))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
var bucket = new Bucket(this, "memoryBucket", new BucketProps {
BucketName = "test-memory",
RemovalPolicy = RemovalPolicy.DESTROY,
AutoDeleteObjects = true
});
var topic = new Topic(this, "topic");
// Create a custom semantic memory strategy
var selfManagedStrategy = MemoryStrategy.UsingSelfManaged(new SelfManagedStrategyProps {
StrategyName = "selfManagedStrategy",
Description = "self managed memory strategy",
HistoricalContextWindowSize = 5,
InvocationConfiguration = new InvocationConfiguration {
Topic = topic,
S3Location = new Location {
BucketName = bucket.BucketName,
ObjectKey = "memory/"
}
},
TriggerConditions = new TriggerConditions {
MessageBasedTrigger = 1,
TimeBasedTrigger = Duration.Seconds(10),
TokenBasedTrigger = 100
}
});
// Create memory with custom strategy
var memory = new Memory(this, "MyMemory", new MemoryProps {
MemoryName = "my-custom-memory",
Description = "Memory with custom strategy",
ExpirationDuration = Duration.Days(90),
MemoryStrategies = new [] { selfManagedStrategy }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
bucket := s3.NewBucket(this, jsii.String("memoryBucket"), &BucketProps{
BucketName: jsii.String("test-memory"),
RemovalPolicy: cdk.RemovalPolicy_DESTROY,
AutoDeleteObjects: jsii.Boolean(true),
})
topic := sns.NewTopic(this, jsii.String("topic"))
// Create a custom semantic memory strategy
selfManagedStrategy := agentcore.MemoryStrategy_UsingSelfManaged(&SelfManagedStrategyProps{
StrategyName: jsii.String("selfManagedStrategy"),
Description: jsii.String("self managed memory strategy"),
HistoricalContextWindowSize: jsii.Number(5),
InvocationConfiguration: &InvocationConfiguration{
Topic: topic,
S3Location: &Location{
BucketName: bucket.bucketName,
ObjectKey: jsii.String("memory/"),
},
},
TriggerConditions: &TriggerConditions{
MessageBasedTrigger: jsii.Number(1),
TimeBasedTrigger: cdk.Duration_Seconds(jsii.Number(10)),
TokenBasedTrigger: jsii.Number(100),
},
})
// Create memory with custom strategy
memory := agentcore.NewMemory(this, jsii.String("MyMemory"), &MemoryProps{
MemoryName: jsii.String("my-custom-memory"),
Description: jsii.String("Memory with custom strategy"),
ExpirationDuration: cdk.Duration_Days(jsii.Number(90)),
MemoryStrategies: []IMemoryStrategy{
selfManagedStrategy,
},
})
Properties
descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #The description of the strategy.
Default: No description
historicalContextWindowSizeoptionalnumberhistorical_context_window_sizeoptionalint | floathistoricalContextWindowSizeoptionalNumberHistoricalContextWindowSizeoptionaldoubleHistoricalContextWindowSizeoptional*float64 = 4 #Define the number of previous events to be included when processing memory.
A larger history window provides more context from past conversations.
invocationConfigurationInvocationConfigurationinvocation_configurationInvocationConfigurationinvocationConfigurationInvocationConfigurationInvocationConfigurationInvocationConfigurationInvocationConfigurationInvocationConfiguration required #Invocation configuration for self managed memory strategy.
strategyNamestringstrategy_namestrstrategyNameStringStrategyNamestringStrategyName*string required #The name for the strategy.
triggerConditionsoptionalTriggerConditionstrigger_conditionsoptionalTriggerConditionstriggerConditionsoptionalTriggerConditionsTriggerConditionsoptionalTriggerConditionsTriggerConditionsoptionalTriggerConditions = undefined #Trigger conditions for self managed memory strategy.