# ManagedMemoryStrategy

Managed memory strategy that handles both built-in and override configurations.

This strategy can be used for quick setup with built-in defaults or customized
with specific models and prompt templates.

Implements: [IMemoryStrategy](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.IMemoryStrategy.html)
Obtainable from: [MemoryStrategy.usingBuiltInEpisodic](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingbuiltinepisodic), [MemoryStrategy.usingBuiltInSemantic](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingbuiltinsemantic), [MemoryStrategy.usingBuiltInSummarization](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingbuiltinsummarization), [MemoryStrategy.usingBuiltInUserPreference](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingbuiltinuserpreference), [MemoryStrategy.usingEpisodic](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingepisodic), [MemoryStrategy.usingSemantic](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingsemantic), [MemoryStrategy.usingSummarization](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingsummarization), [MemoryStrategy.usingUserPreference](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usinguserpreference)

- Source: [`lib/memory/strategies/managed-strategy.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/@aws-cdk/aws-bedrock-agentcore-alpha/lib/memory/strategies/managed-strategy.ts#L122)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import * as bedrock_agentcore_alpha from '@aws-cdk/aws-bedrock-agentcore-alpha';
import * as bedrock_alpha from '@aws-cdk/aws-bedrock-alpha';

declare const bedrockInvokable: bedrock_alpha.IBedrockInvokable;
const managedMemoryStrategy = new bedrock_agentcore_alpha.ManagedMemoryStrategy(bedrock_agentcore_alpha.MemoryStrategyType.SUMMARIZATION, {
  name: 'name',
  namespaces: ['namespaces'],

  // the properties below are optional
  customConsolidation: {
    appendToPrompt: 'appendToPrompt',
    model: bedrockInvokable,
  },
  customExtraction: {
    appendToPrompt: 'appendToPrompt',
    model: bedrockInvokable,
  },
  description: 'description',
  reflectionConfiguration: {
    namespaces: ['namespaces'],
  },
});
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
import aws_cdk.aws_bedrock_agentcore_alpha as bedrock_agentcore_alpha
import aws_cdk.aws_bedrock_alpha as bedrock_alpha

# bedrock_invokable: bedrock_alpha.IBedrockInvokable

managed_memory_strategy = bedrock_agentcore_alpha.ManagedMemoryStrategy(bedrock_agentcore_alpha.MemoryStrategyType.SUMMARIZATION,
    name="name",
    namespaces=["namespaces"],

    # the properties below are optional
    custom_consolidation=bedrock_agentcore_alpha.OverrideConfig(
        append_to_prompt="appendToPrompt",
        model=bedrock_invokable
    ),
    custom_extraction=bedrock_agentcore_alpha.OverrideConfig(
        append_to_prompt="appendToPrompt",
        model=bedrock_invokable
    ),
    description="description",
    reflection_configuration=bedrock_agentcore_alpha.EpisodicReflectionConfiguration(
        namespaces=["namespaces"]
    )
)
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.bedrock.agentcore.alpha.*;
import software.amazon.awscdk.services.bedrock.alpha.*;

IBedrockInvokable bedrockInvokable;

ManagedMemoryStrategy managedMemoryStrategy = ManagedMemoryStrategy.Builder.create(MemoryStrategyType.SUMMARIZATION)
        .name("name")
        .namespaces(List.of("namespaces"))

        // the properties below are optional
        .customConsolidation(OverrideConfig.builder()
                .appendToPrompt("appendToPrompt")
                .model(bedrockInvokable)
                .build())
        .customExtraction(OverrideConfig.builder()
                .appendToPrompt("appendToPrompt")
                .model(bedrockInvokable)
                .build())
        .description("description")
        .reflectionConfiguration(EpisodicReflectionConfiguration.builder()
                .namespaces(List.of("namespaces"))
                .build())
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.AWS.Bedrock.Agentcore.Alpha
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.Bedrock.Agentcore.Alpha;
using Amazon.CDK.AWS.Bedrock.Alpha;

IBedrockInvokable bedrockInvokable;

var managedMemoryStrategy = new ManagedMemoryStrategy(MemoryStrategyType.SUMMARIZATION, new ManagedStrategyProps {
    Name = "name",
    Namespaces = new [] { "namespaces" },

    // the properties below are optional
    CustomConsolidation = new OverrideConfig {
        AppendToPrompt = "appendToPrompt",
        Model = bedrockInvokable
    },
    CustomExtraction = new OverrideConfig {
        AppendToPrompt = "appendToPrompt",
        Model = bedrockInvokable
    },
    Description = "description",
    ReflectionConfiguration = new EpisodicReflectionConfiguration {
        Namespaces = new [] { "namespaces" }
    }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awsbedrockagentcorealpha/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awsbedrockagentcorealpha"
import bedrock_alpha "github.com/aws/aws-cdk-go/awsbedrockalpha"

var bedrockInvokable IBedrockInvokable

managedMemoryStrategy := bedrock_agentcore_alpha.NewManagedMemoryStrategy(bedrock_agentcore_alpha.MemoryStrategyType_SUMMARIZATION, &ManagedStrategyProps{
	Name: jsii.String("name"),
	Namespaces: []*string{
		jsii.String("namespaces"),
	},

	// the properties below are optional
	CustomConsolidation: &OverrideConfig{
		AppendToPrompt: jsii.String("appendToPrompt"),
		Model: bedrockInvokable,
	},
	CustomExtraction: &OverrideConfig{
		AppendToPrompt: jsii.String("appendToPrompt"),
		Model: bedrockInvokable,
	},
	Description: jsii.String("description"),
	ReflectionConfiguration: &EpisodicReflectionConfiguration{
		Namespaces: []*string{
			jsii.String("namespaces"),
		},
	},
})
```

## Initializer

TypeScript:

```ts
new ManagedMemoryStrategy(strategyType: MemoryStrategyType, props: ManagedStrategyProps)
```

Python:

```python
ManagedMemoryStrategy(strategy_type: MemoryStrategyType, props: ManagedStrategyProps)
```

Java:

```java
new ManagedMemoryStrategy(MemoryStrategyType strategyType, ManagedStrategyProps props)
```

C# / .NET:

```csharp
new ManagedMemoryStrategy(MemoryStrategyType strategyType, ManagedStrategyProps props)
```

Golang:

```go
NewManagedMemoryStrategy(StrategyType MemoryStrategyType, Props ManagedStrategyProps)
```

## Properties

- `consolidationOverride`: [OverrideConfig](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.OverrideConfig.html) — The configuration for the custom consolidation.

- `description`: string — The description of the memory strategy.

- `extractionOverride`: [OverrideConfig](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.OverrideConfig.html) — The configuration for the custom extraction.

- `name`: string — The name of the memory strategy.

- `namespaces`: string[] — The namespaces for the strategy.

- `reflectionConfiguration`: [EpisodicReflectionConfiguration](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.EpisodicReflectionConfiguration.html) — The configuration for episodic reflection.

- `strategyType`: [MemoryStrategyType](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategyType.html) — The type of memory strategy.

## Methods

- `grant(grantee: IGrantable): Grant` — Grants the necessary permissions to the role.

  [disable-awslint:no-grants]

  **Parameters**

  - `grantee` — - The grantee to grant permissions to.

  **Returns:** The Grant object for chaining

- `render(): CfnMemory.MemoryStrategyProperty` — Renders the network configuration as a CloudFormation property.

  **Returns:** The CloudFormation property for the memory strategy.
