OverrideConfig Struct
Configuration for overriding model and prompt template.
| Source | aws-bedrockagentcore/lib/memory/strategies/managed-strategy.ts |
|---|---|
| Type last changed |
Example
ts
// Create a custom semantic memory strategy
const customSemanticStrategy = agentcore.MemoryStrategy.usingSemantic({
strategyName: "customSemanticStrategy",
description: "Custom semantic memory strategy",
namespaces: ["/custom/strategies/{memoryStrategyId}/actors/{actorId}"],
customConsolidation: {
model: bedrock.FoundationModel.fromFoundationModelId(this, 'ConsolidationModel',
bedrock.FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0,
),
appendToPrompt: "Custom consolidation prompt for semantic memory",
},
customExtraction: {
model: bedrock.FoundationModel.fromFoundationModelId(this, 'ExtractionModel',
bedrock.FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0,
),
appendToPrompt: "Custom extraction prompt for semantic memory",
},
});
// Create memory with custom strategy
const memory = new agentcore.Memory(this, "MyMemory", {
memoryName: "my-custom-memory",
description: "Memory with custom strategy",
expirationDuration: cdk.Duration.days(90),
memoryStrategies: [customSemanticStrategy],
});
python
# 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]
)
java
// Create a custom semantic memory strategy
ManagedMemoryStrategy customSemanticStrategy = MemoryStrategy.usingSemantic(ManagedStrategyProps.builder()
.strategyName("customSemanticStrategy")
.description("Custom semantic memory strategy")
.namespaces(List.of("/custom/strategies/{memoryStrategyId}/actors/{actorId}"))
.customConsolidation(OverrideConfig.builder()
.model(FoundationModel.fromFoundationModelId(this, "ConsolidationModel", FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0))
.appendToPrompt("Custom consolidation prompt for semantic memory")
.build())
.customExtraction(OverrideConfig.builder()
.model(FoundationModel.fromFoundationModelId(this, "ExtractionModel", FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0))
.appendToPrompt("Custom extraction prompt for semantic memory")
.build())
.build());
// Create memory with custom strategy
Memory memory = Memory.Builder.create(this, "MyMemory")
.memoryName("my-custom-memory")
.description("Memory with custom strategy")
.expirationDuration(Duration.days(90))
.memoryStrategies(List.of(customSemanticStrategy))
.build();
csharp
// Install: dotnet add package Amazon.CDK.Lib
// Create a custom semantic memory strategy
var customSemanticStrategy = MemoryStrategy.UsingSemantic(new ManagedStrategyProps {
StrategyName = "customSemanticStrategy",
Description = "Custom semantic memory strategy",
Namespaces = new [] { "/custom/strategies/{memoryStrategyId}/actors/{actorId}" },
CustomConsolidation = new OverrideConfig {
Model = FoundationModel.FromFoundationModelId(this, "ConsolidationModel", FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0),
AppendToPrompt = "Custom consolidation prompt for semantic memory"
},
CustomExtraction = new OverrideConfig {
Model = FoundationModel.FromFoundationModelId(this, "ExtractionModel", FoundationModelIdentifier.ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0),
AppendToPrompt = "Custom extraction prompt for semantic memory"
}
});
// Create memory with custom strategy
var memory = new Memory(this, "MyMemory", new MemoryProps {
MemoryName = "my-custom-memory",
Description = "Memory with custom strategy",
ExpirationDuration = Duration.Days(90),
MemoryStrategies = new [] { customSemanticStrategy }
});
go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// Create a custom semantic memory strategy
customSemanticStrategy := agentcore.MemoryStrategy_UsingSemantic(&ManagedStrategyProps{
StrategyName: jsii.String("customSemanticStrategy"),
Description: jsii.String("Custom semantic memory strategy"),
Namespaces: []*string{
jsii.String("/custom/strategies/{memoryStrategyId}/actors/{actorId}"),
},
CustomConsolidation: &OverrideConfig{
Model: bedrock.FoundationModel_FromFoundationModelId(this, jsii.String("ConsolidationModel"), bedrock.FoundationModelIdentifier_ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0()),
AppendToPrompt: jsii.String("Custom consolidation prompt for semantic memory"),
},
CustomExtraction: &OverrideConfig{
Model: bedrock.FoundationModel_*FromFoundationModelId(this, jsii.String("ExtractionModel"), bedrock.FoundationModelIdentifier_ANTHROPIC_CLAUDE_3_5_SONNET_20241022_V2_0()),
AppendToPrompt: jsii.String("Custom extraction prompt for semantic memory"),
},
})
// Create memory with custom strategy
memory := agentcore.NewMemory(this, jsii.String("MyMemory"), &MemoryProps{
MemoryName: jsii.String("my-custom-memory"),
Description: jsii.String("Memory with custom strategy"),
ExpirationDuration: cdk.Duration_Days(jsii.Number(90)),
MemoryStrategies: []IMemoryStrategy{
customSemanticStrategy,
},
})
Properties
appendToPromptstringappend_to_promptstrappendToPromptStringAppendToPromptstringAppendToPrompt*string required #The prompt that will be appended to the system prompt to define the model's memory consolidation/extraction strategy.
This configuration provides customization to how the model identifies and extracts relevant information for memory storage. You can use the default user prompt or create a customized one.