Experimental
@aws-cdk/aws-bedrock-alpha is an experimental (alpha) package: its API may change in any release, without a major version bump.
Memory Class
Memory class for managing Bedrock Agent memory configurations.
Enables conversational context retention across multiple sessions through session identifiers. Memory context is stored with unique memory IDs per user, allowing access to conversation history and summaries. Supports viewing stored sessions and clearing memory.
Example
ts
const agent = new bedrock.Agent(this, 'MyAgent', {
agentName: 'MyAgent',
instruction: 'Your instruction here',
foundationModel: bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
memory: Memory.sessionSummary({
maxRecentSessions: 10, // Keep the last 10 session summaries
memoryDuration: Duration.days(20), // Retain summaries for 20 days
}),
});
python
agent = bedrock.Agent(self, "MyAgent",
agent_name="MyAgent",
instruction="Your instruction here",
foundation_model=bedrock.BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
memory=Memory.session_summary(
max_recent_sessions=10, # Keep the last 10 session summaries
memory_duration=Duration.days(20)
)
)
java
Agent agent = Agent.Builder.create(this, "MyAgent")
.agentName("MyAgent")
.instruction("Your instruction here")
.foundationModel(BedrockFoundationModel.AMAZON_NOVA_LITE_V1)
.memory(Memory.sessionSummary(SessionSummaryMemoryProps.builder()
.maxRecentSessions(10) // Keep the last 10 session summaries
.memoryDuration(Duration.days(20))
.build()))
.build();
csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Alpha
var agent = new Agent(this, "MyAgent", new AgentProps {
AgentName = "MyAgent",
Instruction = "Your instruction here",
FoundationModel = BedrockFoundationModel.AMAZON_NOVA_LITE_V1,
Memory = Memory.SessionSummary(new SessionSummaryMemoryProps {
MaxRecentSessions = 10, // Keep the last 10 session summaries
MemoryDuration = Duration.Days(20)
})
});
go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockalpha/v2
agent := bedrock.NewAgent(this, jsii.String("MyAgent"), &AgentProps{
AgentName: jsii.String("MyAgent"),
Instruction: jsii.String("Your instruction here"),
FoundationModel: bedrock.BedrockFoundationModel_AMAZON_NOVA_LITE_V1(),
Memory: awsbedrockalpha.Memory_SessionSummary(&SessionSummaryMemoryProps{
MaxRecentSessions: jsii.Number(10),
// Keep the last 10 session summaries
MemoryDuration: awscdk.Duration_Days(jsii.Number(20)),
}),
})
Initializer
ts
new Memory(props: SessionSummaryMemoryProps)
python
Memory(props: SessionSummaryMemoryProps)
java
new Memory(SessionSummaryMemoryProps props)
csharp
new Memory(SessionSummaryMemoryProps props)
go
NewMemory(Props SessionSummaryMemoryProps)
Properties
Methods
sessionSummary(props: SessionSummaryMemoryProps): Memory // chainable@staticmethod def session_summary(props: SessionSummaryMemoryProps) -> Memorypublic static Memory sessionSummary(SessionSummaryMemoryProps props)public static Memory SessionSummary(SessionSummaryMemoryProps props)func SessionSummary(Props SessionSummaryMemoryProps) Memorystatic#Creates a session summary memory with custom configuration.
1 parameter · returns
Parameters
propspropspropspropsProps— Optional memory configuration properties.
Returns: Memory instance