SelfManagedMemoryStrategy

class aws_cdk.aws_bedrockagentcore.SelfManagedMemoryStrategy(strategy_type, *, invocation_configuration, historical_context_window_size=None, trigger_conditions=None, strategy_name, description=None)

Bases: object

Use AgentCore memory for event storage with custom triggers.

Define memory processing logic in your own environment.

ExampleMetadata:

fixture=default infused

Example:

bucket = s3.Bucket(self, "memoryBucket",
    bucket_name="test-memory",
    removal_policy=cdk.RemovalPolicy.DESTROY,
    auto_delete_objects=True
)

topic = sns.Topic(self, "topic")

# Create a custom semantic memory strategy
self_managed_strategy = agentcore.MemoryStrategy.using_self_managed(
    strategy_name="selfManagedStrategy",
    description="self managed memory strategy",
    historical_context_window_size=5,
    invocation_configuration=agentcore.InvocationConfiguration(
        topic=topic,
        s3_location=s3.Location(
            bucket_name=bucket.bucket_name,
            object_key="memory/"
        )
    ),
    trigger_conditions=agentcore.TriggerConditions(
        message_based_trigger=1,
        time_based_trigger=cdk.Duration.seconds(10),
        token_based_trigger=100
    )
)

# Create memory with custom strategy
memory = agentcore.Memory(self, "MyMemory",
    memory_name="my-custom-memory",
    description="Memory with custom strategy",
    expiration_duration=cdk.Duration.days(90),
    memory_strategies=[self_managed_strategy]
)
Parameters:
  • strategy_type (MemoryStrategyType) – The type of memory strategy.

  • invocation_configuration (Union[InvocationConfiguration, Dict[str, Any]]) – Invocation configuration for self managed memory strategy.

  • historical_context_window_size (Union[int, float, None]) – Define the number of previous events to be included when processing memory. A larger history window provides more context from past conversations. Default: 4

  • trigger_conditions (Union[TriggerConditions, Dict[str, Any], None]) – Trigger conditions for self managed memory strategy. Default: - undefined

  • strategy_name (str) – The name for the strategy.

  • description (Optional[str]) – The description of the strategy. Default: - No description

Methods

grant(grantee)

Grants the necessary permissions to the role.

[disable-awslint:no-grants]

Parameters:

grantee (IGrantable) –

  • The grantee to grant permissions to.

Return type:

Optional[Grant]

Returns:

The Grant object for chaining

render()

Renders internal attributes to CloudFormation.

Return type:

MemoryStrategyProperty

Attributes

description

The description of the memory strategy.

historical_context_window_size

Historical context window size for self managed memory strategy.

invocation_configuration

Invocation configuration for self managed memory strategy.

strategy_name

The name of the memory strategy.

strategy_type

The type of memory strategy.

trigger_conditions

Trigger conditions for self managed memory strategy.