> **Experimental**
>
> `@aws-cdk/aws-bedrock-alpha` is an [**experimental**](https://docs.aws.amazon.com/cdk/api/stability.html) (alpha) package: its API may change in any release, without a major version bump.
# Memory

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.

Obtainable from: Memory.SESSION_SUMMARY, Memory.sessionSummary

- Stability: [Experimental](https://docs.aws.amazon.com/cdk/api/stability.html)
- Source: [`bedrock/agents/memory.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-alpha/bedrock/agents/memory.ts#L50)

## Example

TypeScript:

```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:

```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:

```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();
```

C# / .NET:

```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)
    })
});
```

Golang:

```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

TypeScript:

```ts
new Memory(props: SessionSummaryMemoryProps)
```

Python:

```python
Memory(props: SessionSummaryMemoryProps)
```

Java:

```java
new Memory(SessionSummaryMemoryProps props)
```

C# / .NET:

```csharp
new Memory(SessionSummaryMemoryProps props)
```

Golang:

```go
NewMemory(Props SessionSummaryMemoryProps)
```

## Properties

- `SESSION_SUMMARY`: [Memory](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-alpha.Memory.html) (static) — Returns session summary memory with default configuration.

  **Default:** memoryDuration=Duration.days(30), maxRecentSessions=20

## Methods

- `sessionSummary(props: SessionSummaryMemoryProps): Memory // chainable` (static) — Creates a session summary memory with custom configuration.

  **Parameters**

  - `props` — Optional memory configuration properties.

  **Returns:** Memory instance
