ManagedMemoryStrategy

class aws_cdk.aws_bedrockagentcore.ManagedMemoryStrategy(strategy_type, *, namespaces, custom_consolidation=None, custom_extraction=None, reflection_configuration=None, strategy_name, description=None)

Bases: object

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.

ExampleMetadata:

fixture=default infused

Example:

# Create a custom semantic memory strategy
custom_semantic_strategy = agentcore.MemoryStrategy.using_semantic(
    strategy_name="customSemanticStrategy",
    description="Custom semantic memory strategy",
    namespaces=["/custom/strategies/{memoryStrategyId}/actors/{actorId}"],
    custom_consolidation=agentcore.OverrideConfig(
        model=bedrock.FoundationModel.from_foundation_model_id(self, "ConsolidationModel", bedrock.FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0),
        append_to_prompt="Custom consolidation prompt for semantic memory"
    ),
    custom_extraction=agentcore.OverrideConfig(
        model=bedrock.FoundationModel.from_foundation_model_id(self, "ExtractionModel", bedrock.FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0),
        append_to_prompt="Custom extraction prompt for semantic memory"
    )
)

# 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=[custom_semantic_strategy]
)

Constructor to create a new managed memory strategy.

Parameters:
  • strategy_type (MemoryStrategyType) – the strategy type.

  • namespaces (Sequence[str]) – The namespaces for the strategy Represents a namespace for organizing memory data Use a hierarchical format separated by forward slashes (/). Use a hierarchical format separated by forward slashes (/) to organize namespaces logically. You can include these defined variables: - {sessionId} - the user identifier to be created in the CreateEvent API - {memoryStrategyId} - an identifier for an extraction strategy - {sessionId} - an identifier for each session Example namespace path: /strategies/{memoryStrategyId}/actions/{actionId}/sessions/{sessionId} After memory creation, this namespace might look like: /actor/actor-3afc5aa8fef9/strategy/summarization-fy5c5fwc7/session/session-qj7tpd1kvr8

  • custom_consolidation (Union[OverrideConfig, Dict[str, Any], None]) – The configuration for the custom consolidation. This configuration provides customization to how the model identifies and extracts relevant information for memory storage. Default: - No custom extraction

  • custom_extraction (Union[OverrideConfig, Dict[str, Any], None]) – The configuration for the custom extraction. This configuration provides customization to how the model identifies and extracts relevant information for memory storage. Default: - No custom extraction

  • reflection_configuration (Union[EpisodicReflectionConfiguration, Dict[str, Any], None]) – Configuration for episodic memory reflection (only applicable for EPISODIC strategy type) Defines additional namespaces for reflection-based episodic recall. Default: - No reflection configuration

  • 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 the network configuration as a CloudFormation property.

Return type:

MemoryStrategyProperty

Returns:

The CloudFormation property for the memory strategy.

Attributes

consolidation_override

The configuration for the custom consolidation.

description

The description of the memory strategy.

extraction_override

The configuration for the custom extraction.

namespaces

The namespaces for the strategy.

reflection_configuration

The configuration for episodic reflection.

strategy_name

The name of the memory strategy.

strategy_type

The type of memory strategy.