# SelfManagedMemoryStrategy

Use AgentCore memory for event storage with custom triggers.

Define memory processing logic in your own environment.

Implements: [IMemoryStrategy](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.IMemoryStrategy.html)
Obtainable from: [MemoryStrategy.usingSelfManaged](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.MemoryStrategy.html#usingselfmanaged)

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

## 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 cdk from 'aws-cdk-lib';
import { aws_sns as sns } from 'aws-cdk-lib';

declare const topic: sns.Topic;
const selfManagedMemoryStrategy = new bedrock_agentcore_alpha.SelfManagedMemoryStrategy(bedrock_agentcore_alpha.MemoryStrategyType.SUMMARIZATION, {
  invocationConfiguration: {
    s3Location: {
      bucketName: 'bucketName',
      objectKey: 'objectKey',

      // the properties below are optional
      objectVersion: 'objectVersion',
    },
    topic: topic,
  },
  name: 'name',

  // the properties below are optional
  description: 'description',
  historicalContextWindowSize: 123,
  triggerConditions: {
    messageBasedTrigger: 123,
    timeBasedTrigger: cdk.Duration.minutes(30),
    tokenBasedTrigger: 123,
  },
});
```

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 as cdk
from aws_cdk import aws_sns as sns

# topic: sns.Topic

self_managed_memory_strategy = bedrock_agentcore_alpha.SelfManagedMemoryStrategy(bedrock_agentcore_alpha.MemoryStrategyType.SUMMARIZATION,
    invocation_configuration=bedrock_agentcore_alpha.InvocationConfiguration(
        s3_location=cdk.aws_s3.Location(
            bucket_name="bucketName",
            object_key="objectKey",

            # the properties below are optional
            object_version="objectVersion"
        ),
        topic=topic
    ),
    name="name",

    # the properties below are optional
    description="description",
    historical_context_window_size=123,
    trigger_conditions=bedrock_agentcore_alpha.TriggerConditions(
        message_based_trigger=123,
        time_based_trigger=cdk.Duration.minutes(30),
        token_based_trigger=123
    )
)
```

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.*;
import software.amazon.awscdk.services.sns.*;

Topic topic;

SelfManagedMemoryStrategy selfManagedMemoryStrategy = SelfManagedMemoryStrategy.Builder.create(MemoryStrategyType.SUMMARIZATION)
        .invocationConfiguration(InvocationConfiguration.builder()
                .s3Location(Location.builder()
                        .bucketName("bucketName")
                        .objectKey("objectKey")

                        // the properties below are optional
                        .objectVersion("objectVersion")
                        .build())
                .topic(topic)
                .build())
        .name("name")

        // the properties below are optional
        .description("description")
        .historicalContextWindowSize(123)
        .triggerConditions(TriggerConditions.builder()
                .messageBasedTrigger(123)
                .timeBasedTrigger(Duration.minutes(30))
                .tokenBasedTrigger(123)
                .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;
using Amazon.CDK.AWS.SNS;

Topic topic;

var selfManagedMemoryStrategy = new SelfManagedMemoryStrategy(MemoryStrategyType.SUMMARIZATION, new SelfManagedStrategyProps {
    InvocationConfiguration = new InvocationConfiguration {
        S3Location = new Location {
            BucketName = "bucketName",
            ObjectKey = "objectKey",

            // the properties below are optional
            ObjectVersion = "objectVersion"
        },
        Topic = topic
    },
    Name = "name",

    // the properties below are optional
    Description = "description",
    HistoricalContextWindowSize = 123,
    TriggerConditions = new TriggerConditions {
        MessageBasedTrigger = 123,
        TimeBasedTrigger = Duration.Minutes(30),
        TokenBasedTrigger = 123
    }
});
```

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 cdk "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var topic Topic

selfManagedMemoryStrategy := bedrock_agentcore_alpha.NewSelfManagedMemoryStrategy(bedrock_agentcore_alpha.MemoryStrategyType_SUMMARIZATION, &SelfManagedStrategyProps{
	InvocationConfiguration: &InvocationConfiguration{
		S3Location: &Location{
			BucketName: jsii.String("bucketName"),
			ObjectKey: jsii.String("objectKey"),

			// the properties below are optional
			ObjectVersion: jsii.String("objectVersion"),
		},
		Topic: topic,
	},
	Name: jsii.String("name"),

	// the properties below are optional
	Description: jsii.String("description"),
	HistoricalContextWindowSize: jsii.Number(123),
	TriggerConditions: &TriggerConditions{
		MessageBasedTrigger: jsii.Number(123),
		TimeBasedTrigger: cdk.Duration_Minutes(jsii.Number(30)),
		TokenBasedTrigger: jsii.Number(123),
	},
})
```

## Initializer

TypeScript:

```ts
new SelfManagedMemoryStrategy(strategyType: MemoryStrategyType, props: SelfManagedStrategyProps)
```

Python:

```python
SelfManagedMemoryStrategy(strategy_type: MemoryStrategyType, props: SelfManagedStrategyProps)
```

Java:

```java
new SelfManagedMemoryStrategy(MemoryStrategyType strategyType, SelfManagedStrategyProps props)
```

C# / .NET:

```csharp
new SelfManagedMemoryStrategy(MemoryStrategyType strategyType, SelfManagedStrategyProps props)
```

Golang:

```go
NewSelfManagedMemoryStrategy(StrategyType MemoryStrategyType, Props SelfManagedStrategyProps)
```

## Properties

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

- `historicalContextWindowSize`: number — Historical context window size for self managed memory strategy.

- `invocationConfiguration`: [InvocationConfiguration](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.InvocationConfiguration.html) — Invocation configuration for self managed memory strategy.

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

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

- `triggerConditions`: [TriggerConditions](https://docs.aws.amazon.com/cdk/api/v2/docs/@aws-cdk_aws-bedrock-agentcore-alpha.TriggerConditions.html) — Trigger conditions for self managed 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 internal attributes to CloudFormation.
