Skip to content
v2.278.0

MemoryProps Struct ​

Properties for creating a Memory resource.

Example ​

ts
// Create a Kinesis Data Stream
const stream = new kinesis.Stream(this, 'MemoryEventStream', {
  streamName: 'memory-events',
});

const memory = new agentcore.Memory(this, 'MemoryWithStreamDelivery', {
  memoryName: 'memory_with_stream',
  description: 'Memory with Kinesis stream delivery',
  expirationDuration: cdk.Duration.days(90),
  streamDeliveryResources: [
    agentcore.StreamDeliveryResource.kinesis(stream, {
      contentConfigurations: [
        {
          type: agentcore.StreamDeliveryContentType.MEMORY_RECORDS,
          level: agentcore.StreamDeliveryContentLevel.METADATA_ONLY,
        },
      ],
    }),
  ],
});
python
# Create a Kinesis Data Stream
stream = kinesis.Stream(self, "MemoryEventStream",
    stream_name="memory-events"
)

memory = agentcore.Memory(self, "MemoryWithStreamDelivery",
    memory_name="memory_with_stream",
    description="Memory with Kinesis stream delivery",
    expiration_duration=cdk.Duration.days(90),
    stream_delivery_resources=[
        agentcore.StreamDeliveryResource.kinesis(stream,
            content_configurations=[agentcore.StreamDeliveryContentConfiguration(
                type=agentcore.StreamDeliveryContentType.MEMORY_RECORDS,
                level=agentcore.StreamDeliveryContentLevel.METADATA_ONLY
            )
            ]
        )
    ]
)
java
// Create a Kinesis Data Stream
Stream stream = Stream.Builder.create(this, "MemoryEventStream")
        .streamName("memory-events")
        .build();

Memory memory = Memory.Builder.create(this, "MemoryWithStreamDelivery")
        .memoryName("memory_with_stream")
        .description("Memory with Kinesis stream delivery")
        .expirationDuration(Duration.days(90))
        .streamDeliveryResources(List.of(StreamDeliveryResource.kinesis(stream, KinesisStreamDeliveryOptions.builder()
                .contentConfigurations(List.of(StreamDeliveryContentConfiguration.builder()
                        .type(StreamDeliveryContentType.MEMORY_RECORDS)
                        .level(StreamDeliveryContentLevel.METADATA_ONLY)
                        .build()))
                .build())))
        .build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a Kinesis Data Stream
var stream = new Stream(this, "MemoryEventStream", new StreamProps {
    StreamName = "memory-events"
});

var memory = new Memory(this, "MemoryWithStreamDelivery", new MemoryProps {
    MemoryName = "memory_with_stream",
    Description = "Memory with Kinesis stream delivery",
    ExpirationDuration = Duration.Days(90),
    StreamDeliveryResources = new [] { StreamDeliveryResource.Kinesis(stream, new KinesisStreamDeliveryOptions {
        ContentConfigurations = new [] { new StreamDeliveryContentConfiguration {
            Type = StreamDeliveryContentType.MEMORY_RECORDS,
            Level = StreamDeliveryContentLevel.METADATA_ONLY
        } }
    }) }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a Kinesis Data Stream
stream := kinesis.NewStream(this, jsii.String("MemoryEventStream"), &StreamProps{
	StreamName: jsii.String("memory-events"),
})

memory := agentcore.NewMemory(this, jsii.String("MemoryWithStreamDelivery"), &MemoryProps{
	MemoryName: jsii.String("memory_with_stream"),
	Description: jsii.String("Memory with Kinesis stream delivery"),
	ExpirationDuration: cdk.Duration_Days(jsii.Number(90)),
	StreamDeliveryResources: []StreamDeliveryResource{
		agentcore.StreamDeliveryResource_Kinesis(stream, &KinesisStreamDeliveryOptions{
			ContentConfigurations: []StreamDeliveryContentConfiguration{
				&StreamDeliveryContentConfiguration{
					Type: agentcore.StreamDeliveryContentType_MEMORY_RECORDS,
					Level: agentcore.StreamDeliveryContentLevel_METADATA_ONLY,
				},
			},
		}),
	},
})

Properties ​

descriptionoptionalstringdescriptionoptionalstrdescriptionoptionalStringDescriptionoptionalstringDescriptionoptional*string #
Optional description for the memory Valid characters are a-z, A-Z, 0-9, _ (underscore), - (hyphen) and spaces The description can have up to 200 characters.

Default: No description

executionRoleoptionalIRoleexecution_roleoptionalIRoleexecutionRoleoptionalIRoleExecutionRoleoptionalIRoleExecutionRoleoptionalIRole #
The IAM role that provides permissions for the memory to access AWS services when using custom strategies.

Default: A new role will be created.

expirationDurationoptionalDurationexpiration_durationoptionalDurationexpirationDurationoptionalDurationExpirationDurationoptionalDurationExpirationDurationoptionalDuration #
Short-term memory expiration in days (between 7 and 365).

Default: 90 days

Sets the short-term (raw event) memory retention. Events older than the specified duration will expire and no longer be stored.

kmsKeyoptionalIKeykms_keyoptionalIKeykmsKeyoptionalIKeyKmsKeyoptionalIKeyKmsKeyoptionalIKey #
Custom KMS key to use for encryption.

Default: Your data is encrypted with a key that AWS owns and manages for you

memoryNameoptionalstringmemory_nameoptionalstrmemoryNameoptionalStringMemoryNameoptionalstringMemoryNameoptional*string #
The name of the memory Valid characters are a-z, A-Z, 0-9, _ (underscore) The name must start with a letter and can be up to 48 characters long Pattern: [a-zA-Z][a-zA-Z0-9_]{0,47}.

Default: auto generate

memoryStrategiesoptionalIMemoryStrategy[]memory_strategiesoptionaltyping.List[IMemoryStrategy]memoryStrategiesoptionalList<IMemoryStrategy>MemoryStrategiesoptionalIMemoryStrategy[]MemoryStrategiesoptional*[]IMemoryStrategy #
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.

Default: No extraction strategies (short term memory only)

streamDeliveryResourcesoptionalStreamDeliveryResource[]stream_delivery_resourcesoptionaltyping.List[StreamDeliveryResource]streamDeliveryResourcesoptionalList<StreamDeliveryResource>StreamDeliveryResourcesoptionalStreamDeliveryResource[]StreamDeliveryResourcesoptional*[]StreamDeliveryResource #
Stream delivery resources for real-time push-based streaming of memory record lifecycle events (created, updated, deleted) to Amazon Kinesis Data Streams.

Default: No stream delivery (events are not pushed to Kinesis)

notes

The memory execution role will automatically be granted write permissions to each stream.

Only one stream delivery resource is currently supported (CloudFormation maximum); providing more than one fails at synth with TooManyStreamDeliveryResources:

ts
declare const stream: kinesis.IStream;
new agentcore.Memory(this, 'Memory', {
  streamDeliveryResources: [
    agentcore.StreamDeliveryResource.kinesis(stream, {
      contentConfigurations: [{
        type: agentcore.StreamDeliveryContentType.MEMORY_RECORDS,
        level: agentcore.StreamDeliveryContentLevel.METADATA_ONLY,
      }],
    }),
  ],
});
tagsoptional{ [key: string]: string }tagsoptionaltyping.Mapping[str, str]tagsoptionalMap<String, String>TagsoptionalIDictionary<string, string>Tagsoptional*map[string]*string #
Tags (optional) A list of key:value pairs of tags to apply to this memory resource.

Default: no tags